@fluid-topics/ft-wc-utils 1.3.14 → 1.3.15

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.
@@ -1,5 +1,9 @@
1
1
  import { PropertyDeclaration } from "@lit/reactive-element";
2
2
  export declare const customElement: (tagName: string) => (clazz: CustomElementConstructor) => void;
3
3
  export declare function jsonProperty(defaultValue: any, options?: PropertyDeclaration): PropertyDecorator;
4
+ /**
5
+ * @deprecated use numberProperty instead
6
+ */
4
7
  export declare function optionalNumberProperty(options?: PropertyDeclaration): PropertyDecorator;
8
+ export declare function numberProperty(options?: PropertyDeclaration): PropertyDecorator;
5
9
  export declare function isNumber(value: any): boolean;
@@ -23,17 +23,24 @@ export function jsonProperty(defaultValue, options) {
23
23
  },
24
24
  toAttribute: (value) => {
25
25
  return JSON.stringify(value);
26
- }
26
+ },
27
27
  },
28
28
  hasChanged,
29
- ...(options !== null && options !== void 0 ? options : {})
29
+ ...(options !== null && options !== void 0 ? options : {}),
30
30
  });
31
31
  }
32
+ /**
33
+ * @deprecated use numberProperty instead
34
+ */
32
35
  export function optionalNumberProperty(options) {
36
+ return numberProperty(options);
37
+ }
38
+ export function numberProperty(options) {
33
39
  return property({
34
40
  type: Object,
35
41
  converter: {
36
42
  fromAttribute: (value) => {
43
+ console.log("from attribute", value, options);
37
44
  if (value == null) {
38
45
  return undefined;
39
46
  }
@@ -41,9 +48,10 @@ export function optionalNumberProperty(options) {
41
48
  },
42
49
  toAttribute: (value) => {
43
50
  return value == null ? undefined : "" + value;
44
- }
51
+ },
45
52
  },
46
- ...(options !== null && options !== void 0 ? options : {})
53
+ useDefault: true,
54
+ ...(options !== null && options !== void 0 ? options : {}),
47
55
  });
48
56
  }
49
57
  export function isNumber(value) {
@@ -1,3 +1,4 @@
1
1
  import { ComputePositionReturn, Placement, Strategy } from "@floating-ui/dom";
2
+ import { FtCssVariable } from "@fluid-topics/design-system-variables";
2
3
  export declare function computeOffsetPosition(reference: HTMLElement, element: HTMLElement, placement: Placement): Promise<ComputePositionReturn>;
3
- export declare function computeOffsetAutoPosition(reference: HTMLElement, element: HTMLElement, placement?: Placement, allowedPlacements?: Placement[], strategy?: Strategy, maxHeightCssVariable?: string, offsetValue?: number): Promise<ComputePositionReturn>;
4
+ export declare function computeOffsetAutoPosition(reference: HTMLElement, element: HTMLElement, placement?: Placement, allowedPlacements?: Placement[], strategy?: Strategy, maxHeightCssVariable?: string | FtCssVariable, offsetValue?: number): Promise<ComputePositionReturn>;
package/build/floating.js CHANGED
@@ -29,8 +29,11 @@ export async function computeOffsetAutoPosition(reference, element, placement, a
29
29
  autoPlacement({ allowedPlacements: allowedPlacements }),
30
30
  size({
31
31
  apply({ availableHeight, elements }) {
32
+ if (typeof maxHeightCssVariable === "string") {
33
+ maxHeightCssVariable = `var(${maxHeightCssVariable})`;
34
+ }
32
35
  if (maxHeightCssVariable) {
33
- elements.floating.style.maxHeight = `min(${Math.max(0, availableHeight)}px, var(${maxHeightCssVariable}))`;
36
+ elements.floating.style.maxHeight = `min(${Math.max(0, availableHeight)}px, ${maxHeightCssVariable})`;
34
37
  }
35
38
  else {
36
39
  elements.floating.style.maxHeight = `${Math.max(0, availableHeight)}px`;