@fluid-topics/ft-wc-utils 1.4.4 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,10 @@ export declare function jsonProperty(defaultValue: any, options?: PropertyDeclar
5
5
  * @deprecated use numberProperty instead
6
6
  */
7
7
  export declare function optionalNumberProperty(options?: PropertyDeclaration): PropertyDecorator;
8
- export declare function numberProperty(options?: PropertyDeclaration): PropertyDecorator;
8
+ export type NumberPropertyOptions = PropertyDeclaration & {
9
+ min?: number;
10
+ max?: number;
11
+ };
12
+ export declare function numberProperty(options?: NumberPropertyOptions): PropertyDecorator;
9
13
  export declare function isNumber(value: any): boolean;
10
14
  export declare function dateProperty(options?: PropertyDeclaration): PropertyDecorator;
@@ -1,5 +1,5 @@
1
1
  import { property } from "lit/decorators.js";
2
- import { hasChanged } from "./helpers";
2
+ import { hasChanged, minmax } from "./helpers";
3
3
  export const customElement = (tagName) => (clazz) => {
4
4
  if (!window.customElements.get(tagName)) {
5
5
  window.customElements.define(tagName, clazz);
@@ -40,10 +40,13 @@ export function numberProperty(options) {
40
40
  type: Object,
41
41
  converter: {
42
42
  fromAttribute: (value) => {
43
+ var _a, _b;
43
44
  if (value == null) {
44
45
  return undefined;
45
46
  }
46
- return isNumber(value) ? +value : undefined;
47
+ const min = (_a = options === null || options === void 0 ? void 0 : options.min) !== null && _a !== void 0 ? _a : -Infinity;
48
+ const max = (_b = options === null || options === void 0 ? void 0 : options.max) !== null && _b !== void 0 ? _b : Infinity;
49
+ return isNumber(value) ? minmax(min, +value, max) : undefined;
47
50
  },
48
51
  toAttribute: (value) => {
49
52
  return value == null ? undefined : "" + value;