property.d.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * @license
  3. * Copyright 2017 Google LLC
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. import { PropertyDeclaration } from '../reactive-element.js';
  7. import { ClassElement } from './base.js';
  8. /**
  9. * A property decorator which creates a reactive property that reflects a
  10. * corresponding attribute value. When a decorated property is set
  11. * the element will update and render. A {@linkcode PropertyDeclaration} may
  12. * optionally be supplied to configure property features.
  13. *
  14. * This decorator should only be used for public fields. As public fields,
  15. * properties should be considered as primarily settable by element users,
  16. * either via attribute or the property itself.
  17. *
  18. * Generally, properties that are changed by the element should be private or
  19. * protected fields and should use the {@linkcode state} decorator.
  20. *
  21. * However, sometimes element code does need to set a public property. This
  22. * should typically only be done in response to user interaction, and an event
  23. * should be fired informing the user; for example, a checkbox sets its
  24. * `checked` property when clicked and fires a `changed` event. Mutating public
  25. * properties should typically not be done for non-primitive (object or array)
  26. * properties. In other cases when an element needs to manage state, a private
  27. * property decorated via the {@linkcode state} decorator should be used. When
  28. * needed, state properties can be initialized via public properties to
  29. * facilitate complex interactions.
  30. *
  31. * ```ts
  32. * class MyElement {
  33. * @property({ type: Boolean })
  34. * clicked = false;
  35. * }
  36. * ```
  37. * @category Decorator
  38. * @ExportDecoratedItems
  39. */
  40. export declare function property(options?: PropertyDeclaration): (protoOrDescriptor: Object | ClassElement, name?: PropertyKey | undefined) => any;
  41. //# sourceMappingURL=property.d.ts.map