@fluid-topics/ft-wc-utils 1.3.21 → 1.3.22

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.
@@ -7,3 +7,4 @@ export declare function jsonProperty(defaultValue: any, options?: PropertyDeclar
7
7
  export declare function optionalNumberProperty(options?: PropertyDeclaration): PropertyDecorator;
8
8
  export declare function numberProperty(options?: PropertyDeclaration): PropertyDecorator;
9
9
  export declare function isNumber(value: any): boolean;
10
+ export declare function dateProperty(options?: PropertyDeclaration): PropertyDecorator;
@@ -40,7 +40,6 @@ export function numberProperty(options) {
40
40
  type: Object,
41
41
  converter: {
42
42
  fromAttribute: (value) => {
43
- console.log("from attribute", value, options);
44
43
  if (value == null) {
45
44
  return undefined;
46
45
  }
@@ -57,3 +56,25 @@ export function numberProperty(options) {
57
56
  export function isNumber(value) {
58
57
  return !isNaN(parseFloat(value));
59
58
  }
59
+ export function dateProperty(options) {
60
+ return property({
61
+ type: Object,
62
+ converter: {
63
+ fromAttribute: (value) => {
64
+ if (value == null) {
65
+ return undefined;
66
+ }
67
+ const date = new Date(Date.parse(value));
68
+ if (isNaN(date.valueOf())) {
69
+ return undefined;
70
+ }
71
+ return date;
72
+ },
73
+ toAttribute: (value) => {
74
+ return value === null || value === void 0 ? void 0 : value.toISOString();
75
+ },
76
+ },
77
+ useDefault: true,
78
+ ...(options !== null && options !== void 0 ? options : {}),
79
+ });
80
+ }