@brytdesigns/web-component-core 1.1.7 → 3.0.0

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.
Files changed (84) hide show
  1. package/dist/main/animation/awaitAllAnimations.js +28 -32
  2. package/dist/main/animation/awaitAllAnimations.js.map +1 -1
  3. package/dist/main/animation/content.js +156 -0
  4. package/dist/main/animation/content.js.map +1 -0
  5. package/dist/main/animation/controlsToPromise.js +6 -5
  6. package/dist/main/animation/controlsToPromise.js.map +1 -1
  7. package/dist/main/animation/getTransitionConfig.js +52 -51
  8. package/dist/main/animation/getTransitionConfig.js.map +1 -1
  9. package/dist/main/animation/index.d.ts +61 -1
  10. package/dist/main/animation/index.js +5 -5
  11. package/dist/main/focusTrap/index.d.ts +1 -1
  12. package/dist/main/focusTrap/index.js +10 -14
  13. package/dist/main/focusTrap/index.js.map +1 -1
  14. package/dist/main/hooks/index.d.ts +14 -9
  15. package/dist/main/hooks/index.js +5 -6
  16. package/dist/main/hooks/internal/getValueFromPath.js +9 -10
  17. package/dist/main/hooks/internal/getValueFromPath.js.map +1 -1
  18. package/dist/main/hooks/makePathContextHooks.js +58 -68
  19. package/dist/main/hooks/makePathContextHooks.js.map +1 -1
  20. package/dist/main/hooks/makePathDataArrayComponent.js +61 -67
  21. package/dist/main/hooks/makePathDataArrayComponent.js.map +1 -1
  22. package/dist/main/hooks/makePathDataArrayItemComponent.js +17 -21
  23. package/dist/main/hooks/makePathDataArrayItemComponent.js.map +1 -1
  24. package/dist/main/hooks/makePathDataComponent.js +31 -33
  25. package/dist/main/hooks/makePathDataComponent.js.map +1 -1
  26. package/dist/main/index.d.ts +304 -27
  27. package/dist/main/index.js +28 -7
  28. package/dist/main/promise/abortablePromise.js +10 -15
  29. package/dist/main/promise/abortablePromise.js.map +1 -1
  30. package/dist/main/promise/index.js +2 -3
  31. package/dist/main/utils/a11y.js +133 -0
  32. package/dist/main/utils/a11y.js.map +1 -0
  33. package/dist/main/utils/body-scroll-lock.js +40 -18
  34. package/dist/main/utils/body-scroll-lock.js.map +1 -1
  35. package/dist/main/utils/checkLoaded.js +4 -4
  36. package/dist/main/utils/checkLoaded.js.map +1 -1
  37. package/dist/main/utils/createRemoteContext.js +85 -0
  38. package/dist/main/utils/createRemoteContext.js.map +1 -0
  39. package/dist/main/utils/disclosure.js +52 -0
  40. package/dist/main/utils/disclosure.js.map +1 -0
  41. package/dist/main/utils/formatValue.js +14 -18
  42. package/dist/main/utils/formatValue.js.map +1 -1
  43. package/dist/main/utils/getContextFromProvider.js +15 -10
  44. package/dist/main/utils/getContextFromProvider.js.map +1 -1
  45. package/dist/main/utils/getTemplateContent.js +6 -7
  46. package/dist/main/utils/getTemplateContent.js.map +1 -1
  47. package/dist/main/utils/guarded-effect.js +72 -0
  48. package/dist/main/utils/guarded-effect.js.map +1 -0
  49. package/dist/main/utils/index.d.ts +237 -20
  50. package/dist/main/utils/index.js +15 -12
  51. package/dist/main/utils/invokeOnLoaded.js +13 -13
  52. package/dist/main/utils/invokeOnLoaded.js.map +1 -1
  53. package/dist/main/utils/isCustomElement.js +4 -3
  54. package/dist/main/utils/isCustomElement.js.map +1 -1
  55. package/dist/main/utils/nested-overlays.js +36 -0
  56. package/dist/main/utils/nested-overlays.js.map +1 -0
  57. package/dist/main/utils/solid-element.js +48 -88
  58. package/dist/main/utils/solid-element.js.map +1 -1
  59. package/dist/main/utils/toHyphenated.js +4 -3
  60. package/dist/main/utils/toHyphenated.js.map +1 -1
  61. package/package.json +16 -15
  62. package/dist/esm/animation/index.js +0 -97
  63. package/dist/esm/animation/index.js.map +0 -1
  64. package/dist/esm/focusTrap/index.js +0 -18
  65. package/dist/esm/focusTrap/index.js.map +0 -1
  66. package/dist/esm/hooks/index.js +0 -235
  67. package/dist/esm/hooks/index.js.map +0 -1
  68. package/dist/esm/index.js +0 -547
  69. package/dist/esm/index.js.map +0 -1
  70. package/dist/esm/promise/index.js +0 -20
  71. package/dist/esm/promise/index.js.map +0 -1
  72. package/dist/esm/utils/index.js +0 -236
  73. package/dist/esm/utils/index.js.map +0 -1
  74. package/dist/main/animation/index.js.map +0 -1
  75. package/dist/main/hooks/index.js.map +0 -1
  76. package/dist/main/hooks/internal/index.js +0 -3
  77. package/dist/main/hooks/internal/index.js.map +0 -1
  78. package/dist/main/hooks/internal/types.js +0 -3
  79. package/dist/main/hooks/internal/types.js.map +0 -1
  80. package/dist/main/index.js.map +0 -1
  81. package/dist/main/promise/index.js.map +0 -1
  82. package/dist/main/utils/createWithElementContext.js +0 -64
  83. package/dist/main/utils/createWithElementContext.js.map +0 -1
  84. package/dist/main/utils/index.js.map +0 -1
@@ -1,14 +1,13 @@
1
+ //#region src/hooks/internal/getValueFromPath.ts
1
2
  function getValueFromPath(obj, path) {
2
- return path.split(".").reduce((acc, key) => {
3
- if (acc === null || acc === void 0) return void 0;
4
- const isArrayIndex = !isNaN(Number(key)) && key.trim() !== "";
5
- if (Array.isArray(acc) && isArrayIndex) {
6
- return acc[Number(key)];
7
- }
8
- return acc[key];
9
- }, obj);
3
+ return path.split(".").reduce((acc, key) => {
4
+ if (acc === null || acc === void 0) return void 0;
5
+ const isArrayIndex = !isNaN(Number(key)) && key.trim() !== "";
6
+ if (Array.isArray(acc) && isArrayIndex) return acc[Number(key)];
7
+ return acc[key];
8
+ }, obj);
10
9
  }
11
-
10
+ //#endregion
12
11
  export { getValueFromPath };
13
- //# sourceMappingURL=getValueFromPath.js.map
12
+
14
13
  //# sourceMappingURL=getValueFromPath.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/hooks/internal/getValueFromPath.ts"],"names":[],"mappings":"AA6BO,SAAS,gBAAA,CACd,KACA,IACiB,EAAA;AACjB,EAAA,OAAO,KAAK,KAAM,CAAA,GAAG,EAAE,MAAY,CAAA,CAAC,KAAK,GAAQ,KAAA;AAC/C,IAAA,IAAI,GAAQ,KAAA,IAAA,IAAQ,GAAQ,KAAA,MAAA,EAAkB,OAAA,MAAA;AAE9C,IAAM,MAAA,YAAA,GAAe,CAAC,KAAM,CAAA,MAAA,CAAO,GAAG,CAAC,CAAA,IAAK,GAAI,CAAA,IAAA,EAAW,KAAA,EAAA;AAC3D,IAAA,IAAI,KAAM,CAAA,OAAA,CAAQ,GAAG,CAAA,IAAK,YAAc,EAAA;AACtC,MAAO,OAAA,GAAA,CAAI,MAAO,CAAA,GAAG,CAAC,CAAA;AAAA;AAGxB,IAAA,OAAO,IAAI,GAAG,CAAA;AAAA,KACb,GAAG,CAAA;AACR","file":"getValueFromPath.js","sourcesContent":["export type Path<T> = T extends readonly (infer U)[]\n ? `${number}` | `${number}.${Path<U>}` // Allows indexing into readonly arrays\n : T extends object\n ? {\n [K in keyof T & (string | number)]: T[K] extends object | any[]\n ? `${K}` | `${K}.${Path<T[K]>}`\n : `${K}`;\n }[keyof T & (string | number)]\n : never;\n\nexport type PathValue<\n T,\n P extends string,\n> = P extends `${infer Key}.${infer Rest}`\n ? Key extends keyof T\n ? PathValue<T[Key], Rest>\n : Key extends `${number}`\n ? T extends readonly (infer U)[]\n ? PathValue<U, Rest>\n : undefined\n : undefined\n : P extends keyof T\n ? T[P]\n : P extends `${number}`\n ? T extends readonly (infer U)[]\n ? U\n : undefined\n : undefined;\n\nexport function getValueFromPath<T, P extends Path<T>>(\n obj: T,\n path: P\n): PathValue<T, P> {\n return path.split(\".\").reduce<any>((acc, key) => {\n if (acc === null || acc === undefined) return undefined;\n\n const isArrayIndex = !isNaN(Number(key)) && key.trim() !== \"\";\n if (Array.isArray(acc) && isArrayIndex) {\n return acc[Number(key)];\n }\n\n return acc[key];\n }, obj) as PathValue<T, P>;\n}\n"]}
1
+ {"version":3,"file":"getValueFromPath.js","names":[],"sources":["../../../../src/hooks/internal/getValueFromPath.ts"],"sourcesContent":["export type Path<T> = T extends readonly (infer U)[]\n\t? `${number}` | `${number}.${Path<U>}` // Allows indexing into readonly arrays\n\t: T extends object\n\t\t? {\n\t\t\t\t[K in keyof T & (string | number)]: T[K] extends object | any[]\n\t\t\t\t\t? `${K}` | `${K}.${Path<T[K]>}`\n\t\t\t\t\t: `${K}`;\n\t\t\t}[keyof T & (string | number)]\n\t\t: never;\n\nexport type PathValue<\n\tT,\n\tP extends string,\n> = P extends `${infer Key}.${infer Rest}`\n\t? Key extends keyof T\n\t\t? PathValue<T[Key], Rest>\n\t\t: Key extends `${number}`\n\t\t\t? T extends readonly (infer U)[]\n\t\t\t\t? PathValue<U, Rest>\n\t\t\t\t: undefined\n\t\t\t: undefined\n\t: P extends keyof T\n\t\t? T[P]\n\t\t: P extends `${number}`\n\t\t\t? T extends readonly (infer U)[]\n\t\t\t\t? U\n\t\t\t\t: undefined\n\t\t\t: undefined;\n\nexport function getValueFromPath<T, P extends Path<T>>(\n\tobj: T,\n\tpath: P,\n): PathValue<T, P> {\n\treturn path.split(\".\").reduce<any>((acc, key) => {\n\t\tif (acc === null || acc === undefined) return undefined;\n\n\t\tconst isArrayIndex = !isNaN(Number(key)) && key.trim() !== \"\";\n\t\tif (Array.isArray(acc) && isArrayIndex) {\n\t\t\treturn acc[Number(key)];\n\t\t}\n\n\t\treturn acc[key];\n\t}, obj) as PathValue<T, P>;\n}\n"],"mappings":";AA6BA,SAAgB,iBACf,KACA,MACkB;CAClB,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,QAAa,KAAK,QAAQ;EAChD,IAAI,QAAQ,QAAQ,QAAQ,KAAA,GAAW,OAAO,KAAA;EAE9C,MAAM,eAAe,CAAC,MAAM,OAAO,GAAG,CAAC,KAAK,IAAI,KAAK,MAAM;EAC3D,IAAI,MAAM,QAAQ,GAAG,KAAK,cACzB,OAAO,IAAI,OAAO,GAAG;EAGtB,OAAO,IAAI;CACZ,GAAG,GAAG;AACP"}
@@ -1,71 +1,61 @@
1
- import { createMemo } from 'solid-js';
2
- import { createContext, provide, consume } from 'component-register';
3
- import { getValueFromPath } from './internal/index.js';
4
- import { formatValue } from '../utils/index.js';
5
-
6
- const makeFullPropertyPathContext = () => {
7
- function createFullPathPropertyContext(options) {
8
- return options.path;
9
- }
10
- const Context = createContext(createFullPathPropertyContext);
11
- function provide$1({
12
- element,
13
- path
14
- }) {
15
- return provide(Context, { path }, element);
16
- }
17
- function useFullPropertyPathContext(context) {
18
- return context;
19
- }
20
- function usePath(props) {
21
- const context = consume(Context, props.element);
22
- const basePath = useFullPropertyPathContext(context);
23
- return createMemo(() => {
24
- if (typeof basePath !== "function" && typeof props.path === "function") {
25
- return props.path();
26
- } else if (typeof basePath === "function" && typeof props.path !== "function") {
27
- return basePath();
28
- } else if (typeof basePath === "function" && typeof props.path === "function") {
29
- return `${basePath()}.${props.path()}`;
30
- }
31
- return "";
32
- });
33
- }
34
- function usePathValue(options) {
35
- return createMemo(() => {
36
- const data = options.data();
37
- if (typeof options.path !== "function") return data;
38
- const path = options.path();
39
- if (!path) return data;
40
- const v = getValueFromPath(data, path);
41
- if (v === void 0 || v === null) return null;
42
- return v;
43
- });
44
- }
45
- function useFormattedValue(options) {
46
- const value = usePathValue({ path: options.path, data: options.data });
47
- const formattedValue = createMemo(() => {
48
- const v = value();
49
- if (v === null) return null;
50
- if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
51
- return formatValue(options.format || "", v);
52
- }
53
- console.warn(
54
- `useFormattedValue: Unsupported value type. Expected string, number, or boolean. Received: ${typeof v}.`,
55
- v
56
- );
57
- return null;
58
- });
59
- return formattedValue;
60
- }
61
- return {
62
- provide: provide$1,
63
- usePath,
64
- usePathValue,
65
- useFormattedValue
66
- };
1
+ import { formatValue } from "../utils/formatValue.js";
2
+ import "../utils/index.js";
3
+ import { getValueFromPath } from "./internal/getValueFromPath.js";
4
+ import { createMemo } from "solid-js";
5
+ import { consume, createContext, provide } from "component-register";
6
+ //#region src/hooks/makePathContextHooks.ts
7
+ var makeFullPropertyPathContext = () => {
8
+ function createFullPathPropertyContext(options) {
9
+ return options.path;
10
+ }
11
+ const Context = createContext(createFullPathPropertyContext);
12
+ function provide$1({ element, path }) {
13
+ return provide(Context, { path }, element);
14
+ }
15
+ function useFullPropertyPathContext(context) {
16
+ return context;
17
+ }
18
+ function usePath(props) {
19
+ const basePath = useFullPropertyPathContext(consume(Context, props.element));
20
+ return createMemo(() => {
21
+ if (typeof basePath !== "function" && typeof props.path === "function") return props.path();
22
+ else if (typeof basePath === "function" && typeof props.path !== "function") return basePath();
23
+ else if (typeof basePath === "function" && typeof props.path === "function") return `${basePath()}.${props.path()}`;
24
+ return "";
25
+ });
26
+ }
27
+ function usePathValue(options) {
28
+ return createMemo(() => {
29
+ const data = options.data();
30
+ if (typeof options.path !== "function") return data;
31
+ const path = options.path();
32
+ if (!path) return data;
33
+ const v = getValueFromPath(data, path);
34
+ if (v === void 0 || v === null) return null;
35
+ return v;
36
+ });
37
+ }
38
+ function useFormattedValue(options) {
39
+ const value = usePathValue({
40
+ path: options.path,
41
+ data: options.data
42
+ });
43
+ return createMemo(() => {
44
+ const v = value();
45
+ if (v === null) return null;
46
+ if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") return formatValue(options.format || "", v);
47
+ console.warn(`useFormattedValue: Unsupported value type. Expected string, number, or boolean. Received: ${typeof v}.`, v);
48
+ return null;
49
+ });
50
+ }
51
+ return {
52
+ provide: provide$1,
53
+ usePath,
54
+ usePathValue,
55
+ useFormattedValue
56
+ };
67
57
  };
68
-
58
+ //#endregion
69
59
  export { makeFullPropertyPathContext };
70
- //# sourceMappingURL=makePathContextHooks.js.map
60
+
71
61
  //# sourceMappingURL=makePathContextHooks.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/makePathContextHooks.ts"],"names":["provide","_provide","_consume"],"mappings":";;;;;AAgBO,MAAM,8BAA8B,MAAsB;AAS/D,EAAA,SAAS,8BACP,OAC0B,EAAA;AAC1B,IAAA,OAAO,OAAQ,CAAA,IAAA;AAAA;AAGjB,EAAM,MAAA,OAAA,GAAU,cAAc,6BAA6B,CAAA;AAE3D,EAAA,SAASA,SAAQ,CAAA;AAAA,IACf,OAAA;AAAA,IACA;AAAA,GAI8B,EAAA;AAC9B,IAAA,OAAOC,OAAS,CAAA,OAAA,EAAS,EAAE,IAAA,IAAQ,OAAO,CAAA;AAAA;AAG5C,EAAA,SAAS,2BAA2B,OAAsC,EAAA;AACxE,IAAO,OAAA,OAAA;AAAA;AAGT,EAAA,SAAS,QAAQ,KAGY,EAAA;AAC3B,IAAA,MAAM,OAAU,GAAAC,OAAA,CAAS,OAAS,EAAA,KAAA,CAAM,OAAO,CAAA;AAC/C,IAAM,MAAA,QAAA,GAAW,2BAA2B,OAAO,CAAA;AACnD,IAAA,OAAO,WAAW,MAAM;AACtB,MAAA,IAAI,OAAO,QAAa,KAAA,UAAA,IAAc,OAAO,KAAA,CAAM,SAAS,UAAY,EAAA;AACtE,QAAA,OAAO,MAAM,IAAK,EAAA;AAAA,iBAElB,OAAO,QAAA,KAAa,cACpB,OAAO,KAAA,CAAM,SAAS,UACtB,EAAA;AACA,QAAA,OAAO,QAAS,EAAA;AAAA,iBAEhB,OAAO,QAAA,KAAa,cACpB,OAAO,KAAA,CAAM,SAAS,UACtB,EAAA;AACA,QAAA,OAAO,GAAG,QAAS,EAAC,CAAI,CAAA,EAAA,KAAA,CAAM,MAAM,CAAA,CAAA;AAAA;AAEtC,MAAO,OAAA,EAAA;AAAA,KACR,CAAA;AAAA;AAQH,EAAA,SAAS,aACP,OACkC,EAAA;AAClC,IAAA,OAAO,WAAW,MAAM;AACtB,MAAM,MAAA,IAAA,GAAO,QAAQ,IAAK,EAAA;AAC1B,MAAA,IAAI,OAAO,OAAA,CAAQ,IAAS,KAAA,UAAA,EAAmB,OAAA,IAAA;AAC/C,MAAM,MAAA,IAAA,GAAO,QAAQ,IAAK,EAAA;AAC1B,MAAI,IAAA,CAAC,MAAa,OAAA,IAAA;AAClB,MAAM,MAAA,CAAA,GAAI,gBAAiB,CAAA,IAAA,EAAM,IAAW,CAAA;AAC5C,MAAA,IAAI,CAAM,KAAA,MAAA,IAAa,CAAM,KAAA,IAAA,EAAa,OAAA,IAAA;AAC1C,MAAO,OAAA,CAAA;AAAA,KACR,CAAA;AAAA;AASH,EAAA,SAAS,kBACP,OACkC,EAAA;AAClC,IAAM,MAAA,KAAA,GAAQ,aAAa,EAAE,IAAA,EAAM,QAAQ,IAAM,EAAA,IAAA,EAAM,OAAQ,CAAA,IAAA,EAAM,CAAA;AAErE,IAAM,MAAA,cAAA,GAAiB,WAAW,MAAM;AACtC,MAAA,MAAM,IAAI,KAAM,EAAA;AAChB,MAAI,IAAA,CAAA,KAAM,MAAa,OAAA,IAAA;AACvB,MACE,IAAA,OAAO,MAAM,QACb,IAAA,OAAO,MAAM,QACb,IAAA,OAAO,MAAM,SACb,EAAA;AACA,QAAA,OAAO,WAAY,CAAA,OAAA,CAAQ,MAAU,IAAA,EAAA,EAAI,CAAC,CAAA;AAAA;AAE5C,MAAQ,OAAA,CAAA,IAAA;AAAA,QACN,CAAA,0FAAA,EAA6F,OAAO,CAAC,CAAA,CAAA,CAAA;AAAA,QACrG;AAAA,OACF;AACA,MAAO,OAAA,IAAA;AAAA,KACR,CAAA;AAED,IAAO,OAAA,cAAA;AAAA;AAGT,EAAO,OAAA;AAAA,aACLF,SAAA;AAAA,IACA,OAAA;AAAA,IACA,YAAA;AAAA,IACA;AAAA,GACF;AACF","file":"makePathContextHooks.js","sourcesContent":["import type { Path, PathValue } from \"./internal\";\nimport { createMemo, type Accessor } from \"solid-js\";\nimport {\n createContext,\n consume as _consume,\n provide as _provide,\n type ICustomElement,\n} from \"component-register\";\n\nimport { getValueFromPath } from \"./internal/index.js\";\nimport { formatValue, type Format } from \"../utils/index.js\";\n\ntype WalkableNode = Parameters<typeof _provide>[2];\n\nexport type { Path, PathValue };\n\nexport const makeFullPropertyPathContext = <RootData = any>() => {\n type FullPropertyPathContextType = ReturnType<\n typeof createFullPathPropertyContext\n >;\n\n type Options = {\n path: Accessor<Path<RootData>>;\n element: HTMLElement & ICustomElement;\n };\n function createFullPathPropertyContext(\n options: Options,\n ): Accessor<Path<RootData>> {\n return options.path;\n }\n\n const Context = createContext(createFullPathPropertyContext);\n\n function provide({\n element,\n path,\n }: {\n element: WalkableNode;\n path: Accessor<Path<RootData>>;\n }): FullPropertyPathContextType {\n return _provide(Context, { path }, element);\n }\n\n function useFullPropertyPathContext(context: FullPropertyPathContextType) {\n return context;\n }\n\n function usePath(props: {\n element: HTMLElement & ICustomElement;\n path?: Accessor<Path<RootData>>;\n }): Accessor<Path<RootData>> {\n const context = _consume(Context, props.element);\n const basePath = useFullPropertyPathContext(context);\n return createMemo(() => {\n if (typeof basePath !== \"function\" && typeof props.path === \"function\") {\n return props.path();\n } else if (\n typeof basePath === \"function\" &&\n typeof props.path !== \"function\"\n ) {\n return basePath();\n } else if (\n typeof basePath === \"function\" &&\n typeof props.path === \"function\"\n ) {\n return `${basePath()}.${props.path()}`;\n }\n return \"\";\n }) as Accessor<Path<RootData>>;\n }\n\n type PathValueOptions<P extends Path<RootData>> = {\n path: Accessor<P>;\n data: Accessor<PathValue<RootData, P>>;\n };\n\n function usePathValue<P extends Path<RootData>>(\n options: PathValueOptions<P>,\n ): Accessor<PathValue<RootData, P>> {\n return createMemo(() => {\n const data = options.data();\n if (typeof options.path !== \"function\") return data;\n const path = options.path();\n if (!path) return data;\n const v = getValueFromPath(data, path as any);\n if (v === undefined || v === null) return null;\n return v;\n }) as Accessor<PathValue<RootData, P>>;\n }\n\n type FormmatedValueOptions<P extends Path<RootData>> = {\n path: Accessor<P>;\n format?: Format;\n data: Accessor<PathValue<RootData, P>>;\n };\n\n function useFormattedValue<P extends Path<RootData>>(\n options: FormmatedValueOptions<P>,\n ): Accessor<PathValue<RootData, P>> {\n const value = usePathValue({ path: options.path, data: options.data });\n\n const formattedValue = createMemo(() => {\n const v = value();\n if (v === null) return null;\n if (\n typeof v === \"string\" ||\n typeof v === \"number\" ||\n typeof v === \"boolean\"\n ) {\n return formatValue(options.format || \"\", v);\n }\n console.warn(\n `useFormattedValue: Unsupported value type. Expected string, number, or boolean. Received: ${typeof v}.`,\n v,\n );\n return null;\n });\n\n return formattedValue as Accessor<PathValue<RootData, P>>;\n }\n\n return {\n provide,\n usePath,\n usePathValue,\n useFormattedValue,\n };\n};\n"]}
1
+ {"version":3,"file":"makePathContextHooks.js","names":[],"sources":["../../../src/hooks/makePathContextHooks.ts"],"sourcesContent":["import {\n\tconsume as _consume,\n\tprovide as _provide,\n\tcreateContext,\n\ttype ICustomElement,\n} from \"component-register\";\nimport { type Accessor, createMemo } from \"solid-js\";\nimport { type Format, formatValue } from \"../utils/index.js\";\nimport type { Path, PathValue } from \"./internal\";\nimport { getValueFromPath } from \"./internal/index.js\";\n\ntype WalkableNode = Parameters<typeof _provide>[2];\n\nexport type { Path, PathValue };\n\nexport const makeFullPropertyPathContext = <RootData = any>() => {\n\ttype FullPropertyPathContextType = ReturnType<\n\t\ttypeof createFullPathPropertyContext\n\t>;\n\n\ttype Options = {\n\t\tpath: Accessor<Path<RootData>>;\n\t\telement: HTMLElement & ICustomElement;\n\t};\n\tfunction createFullPathPropertyContext(\n\t\toptions: Options,\n\t): Accessor<Path<RootData>> {\n\t\treturn options.path;\n\t}\n\n\tconst Context = createContext(createFullPathPropertyContext);\n\n\tfunction provide({\n\t\telement,\n\t\tpath,\n\t}: {\n\t\telement: WalkableNode;\n\t\tpath: Accessor<Path<RootData>>;\n\t}): FullPropertyPathContextType {\n\t\treturn _provide(Context, { path }, element);\n\t}\n\n\tfunction useFullPropertyPathContext(context: FullPropertyPathContextType) {\n\t\treturn context;\n\t}\n\n\tfunction usePath(props: {\n\t\telement: HTMLElement & ICustomElement;\n\t\tpath?: Accessor<Path<RootData>>;\n\t}): Accessor<Path<RootData>> {\n\t\tconst context = _consume(Context, props.element);\n\t\tconst basePath = useFullPropertyPathContext(context);\n\t\treturn createMemo(() => {\n\t\t\tif (typeof basePath !== \"function\" && typeof props.path === \"function\") {\n\t\t\t\treturn props.path();\n\t\t\t} else if (\n\t\t\t\ttypeof basePath === \"function\" &&\n\t\t\t\ttypeof props.path !== \"function\"\n\t\t\t) {\n\t\t\t\treturn basePath();\n\t\t\t} else if (\n\t\t\t\ttypeof basePath === \"function\" &&\n\t\t\t\ttypeof props.path === \"function\"\n\t\t\t) {\n\t\t\t\treturn `${basePath()}.${props.path()}`;\n\t\t\t}\n\t\t\treturn \"\";\n\t\t\t// The memo can yield \"\" for a missing path, which is not a\n\t\t\t// `Path<RootData>`; this cast predates v2 and is preserved as-is. v2\n\t\t\t// needs the `unknown` hop because `createMemo` now returns\n\t\t\t// `SourceAccessor`, so the two types no longer overlap directly.\n\t\t}) as unknown as Accessor<Path<RootData>>;\n\t}\n\n\ttype PathValueOptions<P extends Path<RootData>> = {\n\t\tpath: Accessor<P>;\n\t\tdata: Accessor<PathValue<RootData, P>>;\n\t};\n\n\tfunction usePathValue<P extends Path<RootData>>(\n\t\toptions: PathValueOptions<P>,\n\t): Accessor<PathValue<RootData, P>> {\n\t\treturn createMemo(() => {\n\t\t\tconst data = options.data();\n\t\t\tif (typeof options.path !== \"function\") return data;\n\t\t\tconst path = options.path();\n\t\t\tif (!path) return data;\n\t\t\tconst v = getValueFromPath(data, path as any);\n\t\t\tif (v === undefined || v === null) return null;\n\t\t\treturn v;\n\t\t}) as Accessor<PathValue<RootData, P>>;\n\t}\n\n\ttype FormmatedValueOptions<P extends Path<RootData>> = {\n\t\tpath: Accessor<P>;\n\t\tformat?: Format;\n\t\tdata: Accessor<PathValue<RootData, P>>;\n\t};\n\n\tfunction useFormattedValue<P extends Path<RootData>>(\n\t\toptions: FormmatedValueOptions<P>,\n\t): Accessor<PathValue<RootData, P>> {\n\t\tconst value = usePathValue({ path: options.path, data: options.data });\n\n\t\tconst formattedValue = createMemo(() => {\n\t\t\tconst v = value();\n\t\t\tif (v === null) return null;\n\t\t\tif (\n\t\t\t\ttypeof v === \"string\" ||\n\t\t\t\ttypeof v === \"number\" ||\n\t\t\t\ttypeof v === \"boolean\"\n\t\t\t) {\n\t\t\t\treturn formatValue(options.format || \"\", v);\n\t\t\t}\n\t\t\tconsole.warn(\n\t\t\t\t`useFormattedValue: Unsupported value type. Expected string, number, or boolean. Received: ${typeof v}.`,\n\t\t\t\tv,\n\t\t\t);\n\t\t\treturn null;\n\t\t});\n\n\t\treturn formattedValue as Accessor<PathValue<RootData, P>>;\n\t}\n\n\treturn {\n\t\tprovide,\n\t\tusePath,\n\t\tusePathValue,\n\t\tuseFormattedValue,\n\t};\n};\n"],"mappings":";;;;;;AAeA,IAAa,oCAAoD;CAShE,SAAS,8BACR,SAC2B;EAC3B,OAAO,QAAQ;CAChB;CAEA,MAAM,UAAU,cAAc,6BAA6B;CAE3D,SAAS,UAAQ,EAChB,SACA,QAI+B;EAC/B,OAAO,QAAS,SAAS,EAAE,KAAK,GAAG,OAAO;CAC3C;CAEA,SAAS,2BAA2B,SAAsC;EACzE,OAAO;CACR;CAEA,SAAS,QAAQ,OAGY;EAE5B,MAAM,WAAW,2BADD,QAAS,SAAS,MAAM,OACI,CAAO;EACnD,OAAO,iBAAiB;GACvB,IAAI,OAAO,aAAa,cAAc,OAAO,MAAM,SAAS,YAC3D,OAAO,MAAM,KAAK;QACZ,IACN,OAAO,aAAa,cACpB,OAAO,MAAM,SAAS,YAEtB,OAAO,SAAS;QACV,IACN,OAAO,aAAa,cACpB,OAAO,MAAM,SAAS,YAEtB,OAAO,GAAG,SAAS,EAAE,GAAG,MAAM,KAAK;GAEpC,OAAO;EAKR,CAAC;CACF;CAOA,SAAS,aACR,SACmC;EACnC,OAAO,iBAAiB;GACvB,MAAM,OAAO,QAAQ,KAAK;GAC1B,IAAI,OAAO,QAAQ,SAAS,YAAY,OAAO;GAC/C,MAAM,OAAO,QAAQ,KAAK;GAC1B,IAAI,CAAC,MAAM,OAAO;GAClB,MAAM,IAAI,iBAAiB,MAAM,IAAW;GAC5C,IAAI,MAAM,KAAA,KAAa,MAAM,MAAM,OAAO;GAC1C,OAAO;EACR,CAAC;CACF;CAQA,SAAS,kBACR,SACmC;EACnC,MAAM,QAAQ,aAAa;GAAE,MAAM,QAAQ;GAAM,MAAM,QAAQ;EAAK,CAAC;EAmBrE,OAjBuB,iBAAiB;GACvC,MAAM,IAAI,MAAM;GAChB,IAAI,MAAM,MAAM,OAAO;GACvB,IACC,OAAO,MAAM,YACb,OAAO,MAAM,YACb,OAAO,MAAM,WAEb,OAAO,YAAY,QAAQ,UAAU,IAAI,CAAC;GAE3C,QAAQ,KACP,6FAA6F,OAAO,EAAE,IACtG,CACD;GACA,OAAO;EACR,CAEO;CACR;CAEA,OAAO;EACN,SAAA;EACA;EACA;EACA;CACD;AACD"}
@@ -1,70 +1,64 @@
1
- import './makePathContextHooks';
2
- import html from 'solid-js/html';
3
- import { createMemo, Show, For } from 'solid-js';
4
- import { getTemplateContent } from '../utils/index.js';
5
-
6
- const makePathDataArrayComponent = ({
7
- useRootData,
8
- hooks,
9
- name,
10
- arrayItemName
11
- }) => {
12
- const { usePath, provide, usePathValue } = hooks;
13
- return (props, { element }) => {
14
- const itemTemplate = getTemplateContent(element, "item");
15
- if (!itemTemplate)
16
- return console.warn(
17
- `${name}: No template found with a property of 'item'.`,
18
- element
19
- );
20
- if (!props.arrayPath)
21
- return console.warn(`${name}: No array path provided.`, element);
22
- const data = useRootData(element);
23
- const fullPath = usePath({
24
- element,
25
- path: () => props.arrayPath
26
- });
27
- provide({
28
- element,
29
- path: fullPath
30
- });
31
- const value = usePathValue({
32
- path: fullPath,
33
- data
34
- });
35
- const arrayValue = createMemo(() => {
36
- const v = value();
37
- if (!v) {
38
- console.warn(
39
- `${name}: value is null or undefined at path ${fullPath()}`,
40
- element
41
- );
42
- return null;
43
- }
44
- if (!Array.isArray(v)) {
45
- console.warn(
46
- `${name}: value is not an array at path ${fullPath()}`,
47
- element
48
- );
49
- return null;
50
- }
51
- return v;
52
- });
53
- element.replaceChildren(...[]);
54
- return html`
55
- <${Show} when=${() => arrayValue() && arrayValue().length > 0}>
56
- <${For} each=${arrayValue}>
57
- ${(_, idx) => html`
58
- <${arrayItemName} item-index=${() => `${idx()}`}>
59
- ${() => Array.from(itemTemplate.cloneNode(true).childNodes)}
60
- </${arrayItemName}>
61
- `}
62
- <//>
63
- <//>
64
- `;
65
- };
1
+ import { getTemplateContent } from "../utils/getTemplateContent.js";
2
+ import "../utils/index.js";
3
+ import { createMemo, untrack } from "solid-js";
4
+ import { Dynamic, For, Show, createComponent } from "@solidjs/web";
5
+ //#region src/hooks/makePathDataArrayComponent.tsx
6
+ var makePathDataArrayComponent = ({ useRootData, hooks, name, arrayItemName }) => {
7
+ const { usePath, provide, usePathValue } = hooks;
8
+ return (props, { element }) => {
9
+ const itemTemplate = getTemplateContent(element, "item");
10
+ if (!itemTemplate) return console.warn(`${name}: No template found with a property of 'item'.`, element);
11
+ if (untrack(() => !props.arrayPath)) return console.warn(`${name}: No array path provided.`, element);
12
+ const data = useRootData(element);
13
+ const fullPath = usePath({
14
+ element,
15
+ path: () => props.arrayPath
16
+ });
17
+ provide({
18
+ element,
19
+ path: fullPath
20
+ });
21
+ const value = usePathValue({
22
+ path: fullPath,
23
+ data
24
+ });
25
+ const arrayValue = createMemo(() => {
26
+ const v = value();
27
+ if (!v) {
28
+ console.warn(`${name}: value is null or undefined at path ${fullPath()}`, element);
29
+ return null;
30
+ }
31
+ if (!Array.isArray(v)) {
32
+ console.warn(`${name}: value is not an array at path ${fullPath()}`, element);
33
+ return null;
34
+ }
35
+ return v;
36
+ });
37
+ element.replaceChildren(...[]);
38
+ return createComponent(Show, {
39
+ get when() {
40
+ return (arrayValue()?.length ?? 0) > 0;
41
+ },
42
+ get children() {
43
+ return createComponent(For, {
44
+ get each() {
45
+ return arrayValue() ?? [];
46
+ },
47
+ children: (_, idx) => createComponent(Dynamic, {
48
+ component: arrayItemName,
49
+ get "item-index"() {
50
+ return `${idx()}`;
51
+ },
52
+ get children() {
53
+ return Array.from(itemTemplate.cloneNode(true).childNodes);
54
+ }
55
+ })
56
+ });
57
+ }
58
+ });
59
+ };
66
60
  };
67
-
61
+ //#endregion
68
62
  export { makePathDataArrayComponent };
69
- //# sourceMappingURL=makePathDataArrayComponent.js.map
63
+
70
64
  //# sourceMappingURL=makePathDataArrayComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/makePathDataArrayComponent.ts"],"names":[],"mappings":";;;;;AAQO,MAAM,6BAA6B,CAA8B;AAAA,EACtE,WAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAKK,KAAA;AACH,EAAA,MAAM,EAAE,OAAA,EAAS,OAAS,EAAA,YAAA,EAAiB,GAAA,KAAA;AAC3C,EAAA,OAAO,CAAC,KAAA,EAAO,EAAE,OAAA,EAAc,KAAA;AAC7B,IAAM,MAAA,YAAA,GAAe,kBAAmB,CAAA,OAAA,EAAS,MAAM,CAAA;AACvD,IAAA,IAAI,CAAC,YAAA;AACH,MAAA,OAAO,OAAQ,CAAA,IAAA;AAAA,QACb,GAAG,IAAI,CAAA,8CAAA,CAAA;AAAA,QACP;AAAA,OACF;AACF,IAAA,IAAI,CAAC,KAAM,CAAA,SAAA;AACT,MAAA,OAAO,OAAQ,CAAA,IAAA,CAAK,CAAG,EAAA,IAAI,6BAA6B,OAAO,CAAA;AAEjE,IAAM,MAAA,IAAA,GAAO,YAAY,OAAO,CAAA;AAEhC,IAAA,MAAM,WAAW,OAAQ,CAAA;AAAA,MACvB,OAAA;AAAA,MACA,IAAA,EAAM,MAAM,KAAM,CAAA;AAAA,KACnB,CAAA;AAED,IAAQ,OAAA,CAAA;AAAA,MACN,OAAA;AAAA,MACA,IAAM,EAAA;AAAA,KACP,CAAA;AAED,IAAA,MAAM,QAAQ,YAAa,CAAA;AAAA,MACzB,IAAM,EAAA,QAAA;AAAA,MACN;AAAA,KACD,CAAA;AAED,IAAM,MAAA,UAAA,GAAa,WAAW,MAAM;AAClC,MAAA,MAAM,IAAI,KAAM,EAAA;AAEhB,MAAA,IAAI,CAAC,CAAG,EAAA;AACN,QAAQ,OAAA,CAAA,IAAA;AAAA,UACN,CAAG,EAAA,IAAI,CAAwC,qCAAA,EAAA,QAAA,EAAU,CAAA,CAAA;AAAA,UACzD;AAAA,SACF;AACA,QAAO,OAAA,IAAA;AAAA;AAGT,MAAA,IAAI,CAAC,KAAA,CAAM,OAAQ,CAAA,CAAC,CAAG,EAAA;AACrB,QAAQ,OAAA,CAAA,IAAA;AAAA,UACN,CAAG,EAAA,IAAI,CAAmC,gCAAA,EAAA,QAAA,EAAU,CAAA,CAAA;AAAA,UACpD;AAAA,SACF;AACA,QAAO,OAAA,IAAA;AAAA;AAGT,MAAO,OAAA,CAAA;AAAA,KACR,CAAA;AACD,IAAQ,OAAA,CAAA,eAAA,CAAgB,GAAG,EAAE,CAAA;AAE7B,IAAO,OAAA,IAAA;AAAA,OACF,EAAA,IAAI,SAAS,MAAM,UAAA,MAAgB,UAAW,EAAA,CAAG,SAAS,CAAC,CAAA;AAAA,SACzD,EAAA,GAAG,SAAS,UAAU,CAAA;AAAA,UACrB,EAAA,CAAC,GAAQ,GAA0B,KAAA,IAAA;AAAA,aAAA,EAChC,aAAa,CAAe,YAAA,EAAA,MAAM,CAAG,EAAA,GAAA,EAAK,CAAE,CAAA,CAAA;AAAA,cAC3C,EAAA,MAAM,MAAM,IAAK,CAAA,YAAA,CAAa,UAAU,IAAI,CAAA,CAAE,UAAU,CAAC;AAAA,cAAA,EACzD,aAAa,CAAA;AAAA,UAClB,CAAA;AAAA;AAAA;AAAA,IAAA,CAAA;AAAA,GAIT;AACF","file":"makePathDataArrayComponent.js","sourcesContent":["import type { CorrectComponentType, Format } from \"../utils/index\";\nimport { type Path } from \"./makePathContextHooks\";\nimport type { BaseOptions } from \"./internal/types\";\n\nimport html from \"solid-js/html\";\nimport { Show, For, createMemo, type Accessor } from \"solid-js\";\nimport { getTemplateContent } from \"../utils/index.js\";\n\nexport const makePathDataArrayComponent = <RootData = any, Props = any>({\n useRootData,\n hooks,\n name,\n arrayItemName,\n}: BaseOptions<RootData> & { arrayItemName: string }): CorrectComponentType<\n {\n arrayPath: Path<RootData>;\n format?: Format;\n } & Props\n> => {\n const { usePath, provide, usePathValue } = hooks;\n return (props, { element }) => {\n const itemTemplate = getTemplateContent(element, \"item\");\n if (!itemTemplate)\n return console.warn(\n `${name}: No template found with a property of 'item'.`,\n element,\n );\n if (!props.arrayPath)\n return console.warn(`${name}: No array path provided.`, element);\n\n const data = useRootData(element);\n\n const fullPath = usePath({\n element,\n path: () => props.arrayPath,\n });\n\n provide({\n element,\n path: fullPath,\n });\n\n const value = usePathValue({\n path: fullPath,\n data: data as any,\n });\n\n const arrayValue = createMemo(() => {\n const v = value();\n\n if (!v) {\n console.warn(\n `${name}: value is null or undefined at path ${fullPath()}`,\n element,\n );\n return null;\n }\n\n if (!Array.isArray(v)) {\n console.warn(\n `${name}: value is not an array at path ${fullPath()}`,\n element,\n );\n return null;\n }\n\n return v;\n });\n element.replaceChildren(...[]);\n\n return html`\n <${Show} when=${() => arrayValue() && arrayValue()!.length > 0}>\n <${For} each=${arrayValue}>\n ${(_: any, idx: Accessor<number>) => html`\n <${arrayItemName} item-index=${() => `${idx()}`}>\n ${() => Array.from(itemTemplate.cloneNode(true).childNodes)}\n </${arrayItemName}>\n `}\n <//>\n <//>\n `;\n };\n};\n"]}
1
+ {"version":3,"file":"makePathDataArrayComponent.js","names":["<Show when={(arrayValue()?.length ?? 0) > 0}>\n\t\t\t\t<For each={arrayValue() ?? []}>\n\t\t\t\t\t{(_, idx) => (\n\t\t\t\t\t\t<Dynamic component={arrayItemName} item-index={`${idx()}`}>\n\t\t\t\t\t\t\t{Array.from(itemTemplate.cloneNode(true).childNodes)}\n\t\t\t\t\t\t</Dynamic>\n\t\t\t\t\t)}\n\t\t\t\t</For>\n\t\t\t</Show>","<For each={arrayValue() ?? []}>\n\t\t\t\t\t{(_, idx) => (\n\t\t\t\t\t\t<Dynamic component={arrayItemName} item-index={`${idx()}`}>\n\t\t\t\t\t\t\t{Array.from(itemTemplate.cloneNode(true).childNodes)}\n\t\t\t\t\t\t</Dynamic>\n\t\t\t\t\t)}\n\t\t\t\t</For>","<Dynamic component={arrayItemName} item-index={`${idx()}`}>\n\t\t\t\t\t\t\t{Array.from(itemTemplate.cloneNode(true).childNodes)}\n\t\t\t\t\t\t</Dynamic>","component={arrayItemName}"],"sources":["../../../src/hooks/makePathDataArrayComponent.tsx"],"sourcesContent":["import { Dynamic, For, Show } from \"@solidjs/web\";\nimport { createMemo, untrack } from \"solid-js\";\nimport type { CorrectComponentType, Format } from \"../utils/index\";\nimport { getTemplateContent } from \"../utils/index.js\";\nimport type { BaseOptions } from \"./internal/types\";\nimport type { Path } from \"./makePathContextHooks\";\n\nexport const makePathDataArrayComponent = <RootData = any, Props = any>({\n\tuseRootData,\n\thooks,\n\tname,\n\tarrayItemName,\n}: BaseOptions<RootData> & { arrayItemName: string }): CorrectComponentType<\n\t{\n\t\tarrayPath: Path<RootData>;\n\t\tformat?: Format;\n\t} & Props\n> => {\n\tconst { usePath, provide, usePathValue } = hooks;\n\treturn (props, { element }) => {\n\t\tconst itemTemplate = getTemplateContent(element, \"item\");\n\t\tif (!itemTemplate)\n\t\t\treturn console.warn(\n\t\t\t\t`${name}: No template found with a property of 'item'.`,\n\t\t\t\telement,\n\t\t\t);\n\t\tif (untrack(() => !props.arrayPath))\n\t\t\treturn console.warn(`${name}: No array path provided.`, element);\n\n\t\tconst data = useRootData(element);\n\n\t\tconst fullPath = usePath({\n\t\t\telement,\n\t\t\tpath: () => props.arrayPath,\n\t\t});\n\n\t\tprovide({\n\t\t\telement,\n\t\t\tpath: fullPath,\n\t\t});\n\n\t\tconst value = usePathValue({\n\t\t\tpath: fullPath,\n\t\t\tdata: data as any,\n\t\t});\n\n\t\tconst arrayValue = createMemo(() => {\n\t\t\tconst v = value();\n\n\t\t\tif (!v) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${name}: value is null or undefined at path ${fullPath()}`,\n\t\t\t\t\telement,\n\t\t\t\t);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif (!Array.isArray(v)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${name}: value is not an array at path ${fullPath()}`,\n\t\t\t\t\telement,\n\t\t\t\t);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn v;\n\t\t});\n\t\telement.replaceChildren(...[]);\n\n\t\t// The item tag is data, not a literal, so it goes through `Dynamic`.\n\t\treturn (\n\t\t\t<Show when={(arrayValue()?.length ?? 0) > 0}>\n\t\t\t\t<For each={arrayValue() ?? []}>\n\t\t\t\t\t{(_, idx) => (\n\t\t\t\t\t\t<Dynamic component={arrayItemName} item-index={`${idx()}`}>\n\t\t\t\t\t\t\t{Array.from(itemTemplate.cloneNode(true).childNodes)}\n\t\t\t\t\t\t</Dynamic>\n\t\t\t\t\t)}\n\t\t\t\t</For>\n\t\t\t</Show>\n\t\t);\n\t};\n};\n"],"mappings":";;;;;AAOA,IAAa,8BAA2D,EACvE,aACA,OACA,MACA,oBAMI;CACJ,MAAM,EAAE,SAAS,SAAS,iBAAiB;CAC3C,QAAQ,OAAO,EAAE,cAAc;EAC9B,MAAM,eAAe,mBAAmB,SAAS,MAAM;EACvD,IAAI,CAAC,cACJ,OAAO,QAAQ,KACd,GAAG,KAAK,iDACR,OACD;EACD,IAAI,cAAc,CAAC,MAAM,SAAS,GACjC,OAAO,QAAQ,KAAK,GAAG,KAAK,4BAA4B,OAAO;EAEhE,MAAM,OAAO,YAAY,OAAO;EAEhC,MAAM,WAAW,QAAQ;GACxB;GACA,YAAY,MAAM;EACnB,CAAC;EAED,QAAQ;GACP;GACA,MAAM;EACP,CAAC;EAED,MAAM,QAAQ,aAAa;GAC1B,MAAM;GACA;EACP,CAAC;EAED,MAAM,aAAa,iBAAiB;GACnC,MAAM,IAAI,MAAM;GAEhB,IAAI,CAAC,GAAG;IACP,QAAQ,KACP,GAAG,KAAK,uCAAuC,SAAS,KACxD,OACD;IACA,OAAO;GACR;GAEA,IAAI,CAAC,MAAM,QAAQ,CAAC,GAAG;IACtB,QAAQ,KACP,GAAG,KAAK,kCAAkC,SAAS,KACnD,OACD;IACA,OAAO;GACR;GAEA,OAAO;EACR,CAAC;EACD,QAAQ,gBAAgB,GAAG,CAAC,CAAC;EAG7B,OACCA,gBAAAA,MAAAA;GAAM,IAAA,OAAA;IAAO,QAAA,WAAW,CAAC,EAAE,UAAU,KAAK;GAAC;GAA3C,IAAA,WAAA;IACCC,OAAAA,gBAAAA,KAAAA;KAAK,IAAA,OAAA;MAAM,OAAA,WAAW,KAAK,CAAC;KAAC;KAA7BA,WACG,GAAG,QACJC,gBAAAA,SAAAA;MAASC,WAAW;MAAe,IAAA,eAAA;OAAY,OAAA,GAAG,IAAI;MAAG;MAAzD,IAAA,WAAA;OACE,OAAA,MAAM,KAAK,aAAa,UAAU,IAAI,CAAC,CAAC,UAAU;MAC3C;;IAEN,CAAA;GACA;;CAER;AACD"}
@@ -1,24 +1,20 @@
1
- import './makePathContextHooks';
2
-
3
- const makePathDataArrayItemComponent = ({
4
- hooks,
5
- name
6
- }) => {
7
- const { usePath, provide } = hooks;
8
- return (props, { element }) => {
9
- if (!props.itemIndex)
10
- return console.warn(`${name}: No path attribute provided.`);
11
- const fullPath = usePath({
12
- path: () => props.itemIndex,
13
- element
14
- });
15
- provide({
16
- element,
17
- path: fullPath
18
- });
19
- };
1
+ import { untrack } from "solid-js";
2
+ //#region src/hooks/makePathDataArrayItemComponent.ts
3
+ var makePathDataArrayItemComponent = ({ hooks, name }) => {
4
+ const { usePath, provide } = hooks;
5
+ return (props, { element }) => {
6
+ if (untrack(() => !props.itemIndex)) return console.warn(`${name}: No path attribute provided.`);
7
+ const fullPath = usePath({
8
+ path: () => props.itemIndex,
9
+ element
10
+ });
11
+ provide({
12
+ element,
13
+ path: fullPath
14
+ });
15
+ };
20
16
  };
21
-
17
+ //#endregion
22
18
  export { makePathDataArrayItemComponent };
23
- //# sourceMappingURL=makePathDataArrayItemComponent.js.map
19
+
24
20
  //# sourceMappingURL=makePathDataArrayItemComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/makePathDataArrayItemComponent.ts"],"names":[],"mappings":";;AAIO,MAAM,iCAAiC,CAG5C;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAiE,KAAA;AAC/D,EAAM,MAAA,EAAE,OAAS,EAAA,OAAA,EAAY,GAAA,KAAA;AAC7B,EAAA,OAAO,CAAC,KAAA,EAAO,EAAE,OAAA,EAAc,KAAA;AAC7B,IAAA,IAAI,CAAC,KAAM,CAAA,SAAA;AACT,MAAA,OAAO,OAAQ,CAAA,IAAA,CAAK,CAAG,EAAA,IAAI,CAA+B,6BAAA,CAAA,CAAA;AAE5D,IAAA,MAAM,WAAW,OAAQ,CAAA;AAAA,MACvB,IAAA,EAAM,MAAM,KAAM,CAAA,SAAA;AAAA,MAClB;AAAA,KACD,CAAA;AAED,IAAQ,OAAA,CAAA;AAAA,MACN,OAAA;AAAA,MACA,IAAM,EAAA;AAAA,KACP,CAAA;AAAA,GACH;AACF","file":"makePathDataArrayItemComponent.js","sourcesContent":["import type { CorrectComponentType } from \"../utils/index\";\nimport { type Path } from \"./makePathContextHooks\";\nimport type { BaseOptions } from \"./internal/types\";\n\nexport const makePathDataArrayItemComponent = <\n RootData = any,\n Props extends { itemIndex: Path<RootData> } = any,\n>({\n hooks,\n name,\n}: BaseOptions<RootData, Props>): CorrectComponentType<Props> => {\n const { usePath, provide } = hooks;\n return (props, { element }) => {\n if (!props.itemIndex)\n return console.warn(`${name}: No path attribute provided.`);\n\n const fullPath = usePath({\n path: () => props.itemIndex,\n element,\n });\n\n provide({\n element,\n path: fullPath,\n });\n };\n};\n"]}
1
+ {"version":3,"file":"makePathDataArrayItemComponent.js","names":[],"sources":["../../../src/hooks/makePathDataArrayItemComponent.ts"],"sourcesContent":["import { untrack } from \"solid-js\";\nimport type { CorrectComponentType } from \"../utils/index\";\nimport type { BaseOptions } from \"./internal/types\";\nimport type { Path } from \"./makePathContextHooks\";\n\nexport const makePathDataArrayItemComponent = <\n\tRootData = any,\n\tProps extends { itemIndex: Path<RootData> } = any,\n>({\n\thooks,\n\tname,\n}: BaseOptions<RootData, Props>): CorrectComponentType<Props> => {\n\tconst { usePath, provide } = hooks;\n\treturn (props, { element }) => {\n\t\tif (untrack(() => !props.itemIndex))\n\t\t\treturn console.warn(`${name}: No path attribute provided.`);\n\n\t\tconst fullPath = usePath({\n\t\t\tpath: () => props.itemIndex,\n\t\t\telement,\n\t\t});\n\n\t\tprovide({\n\t\t\telement,\n\t\t\tpath: fullPath,\n\t\t});\n\t};\n};\n"],"mappings":";;AAKA,IAAa,kCAGX,EACD,OACA,WACgE;CAChE,MAAM,EAAE,SAAS,YAAY;CAC7B,QAAQ,OAAO,EAAE,cAAc;EAC9B,IAAI,cAAc,CAAC,MAAM,SAAS,GACjC,OAAO,QAAQ,KAAK,GAAG,KAAK,8BAA8B;EAE3D,MAAM,WAAW,QAAQ;GACxB,YAAY,MAAM;GAClB;EACD,CAAC;EAED,QAAQ;GACP;GACA,MAAM;EACP,CAAC;CACF;AACD"}
@@ -1,36 +1,34 @@
1
- import html from 'solid-js/html';
2
- import { Show } from 'solid-js';
3
-
4
- const makePathDataComponent = ({
5
- useRootData,
6
- hooks,
7
- name
8
- }) => {
9
- const { usePath, useFormattedValue } = hooks;
10
- return (props, { element }) => {
11
- if (!props.propertyName)
12
- return console.warn(
13
- `${name}: No property-name attribute provided.`,
14
- element
15
- );
16
- const data = useRootData(element);
17
- const fullPath = usePath({
18
- element,
19
- path: () => props.propertyName
20
- });
21
- const formattedValue = useFormattedValue({
22
- get format() {
23
- return props.format;
24
- },
25
- path: fullPath,
26
- data
27
- });
28
- return html`
29
- <${Show} when=${() => formattedValue() !== null}> ${formattedValue} <//>
30
- `;
31
- };
1
+ import { untrack } from "solid-js";
2
+ import { Show, createComponent } from "@solidjs/web";
3
+ //#region src/hooks/makePathDataComponent.tsx
4
+ var makePathDataComponent = ({ useRootData, hooks, name }) => {
5
+ const { usePath, useFormattedValue } = hooks;
6
+ return (props, { element }) => {
7
+ if (untrack(() => !props.propertyName)) return console.warn(`${name}: No property-name attribute provided.`, element);
8
+ const data = useRootData(element);
9
+ const fullPath = usePath({
10
+ element,
11
+ path: () => props.propertyName
12
+ });
13
+ const formattedValue = useFormattedValue({
14
+ get format() {
15
+ return props.format;
16
+ },
17
+ path: fullPath,
18
+ data
19
+ });
20
+ const text = () => formattedValue();
21
+ return createComponent(Show, {
22
+ get when() {
23
+ return text() !== null;
24
+ },
25
+ get children() {
26
+ return text();
27
+ }
28
+ });
29
+ };
32
30
  };
33
-
31
+ //#endregion
34
32
  export { makePathDataComponent };
35
- //# sourceMappingURL=makePathDataComponent.js.map
33
+
36
34
  //# sourceMappingURL=makePathDataComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/makePathDataComponent.ts"],"names":[],"mappings":";;;AAOO,MAAM,wBAAwB,CAA8B;AAAA,EACjE,WAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAEK,KAAA;AACH,EAAM,MAAA,EAAE,OAAS,EAAA,iBAAA,EAAsB,GAAA,KAAA;AACvC,EAAA,OAAO,CAAC,KAAA,EAAO,EAAE,OAAA,EAAc,KAAA;AAC7B,IAAA,IAAI,CAAC,KAAM,CAAA,YAAA;AACT,MAAA,OAAO,OAAQ,CAAA,IAAA;AAAA,QACb,GAAG,IAAI,CAAA,sCAAA,CAAA;AAAA,QACP;AAAA,OACF;AACF,IAAM,MAAA,IAAA,GAAO,YAAY,OAAO,CAAA;AAChC,IAAA,MAAM,WAAW,OAAQ,CAAA;AAAA,MACvB,OAAA;AAAA,MACA,IAAA,EAAM,MAAM,KAAM,CAAA;AAAA,KACnB,CAAA;AACD,IAAA,MAAM,iBAAiB,iBAAkB,CAAA;AAAA,MACvC,IAAI,MAAS,GAAA;AACX,QAAA,OAAO,KAAM,CAAA,MAAA;AAAA,OACf;AAAA,MACA,IAAM,EAAA,QAAA;AAAA,MACN;AAAA,KACD,CAAA;AACD,IAAO,OAAA,IAAA;AAAA,OAAA,EACF,IAAI,CAAS,MAAA,EAAA,MAAM,gBAAqB,KAAA,IAAI,KAAK,cAAc,CAAA;AAAA,IAAA,CAAA;AAAA,GAEtE;AACF","file":"makePathDataComponent.js","sourcesContent":["import type { BaseOptions } from \"./internal/types\";\nimport type { CorrectComponentType, Format } from \"../utils/index\";\nimport type { Path } from \"./internal\";\n\nimport html from \"solid-js/html\";\nimport { Show } from \"solid-js\";\n\nexport const makePathDataComponent = <RootData = any, Props = any>({\n useRootData,\n hooks,\n name,\n}: BaseOptions<RootData>): CorrectComponentType<\n { propertyName: Path<RootData>; format?: Format } & Props\n> => {\n const { usePath, useFormattedValue } = hooks;\n return (props, { element }) => {\n if (!props.propertyName)\n return console.warn(\n `${name}: No property-name attribute provided.`,\n element,\n );\n const data = useRootData(element);\n const fullPath = usePath({\n element,\n path: () => props.propertyName,\n });\n const formattedValue = useFormattedValue({\n get format() {\n return props.format;\n },\n path: fullPath,\n data: data as any,\n });\n return html`\n <${Show} when=${() => formattedValue() !== null}> ${formattedValue} <//>\n `;\n };\n};\n"]}
1
+ {"version":3,"file":"makePathDataComponent.js","names":["<Show when={text() !== null}>{text()}</Show>"],"sources":["../../../src/hooks/makePathDataComponent.tsx"],"sourcesContent":["import { Show } from \"@solidjs/web\";\nimport { untrack } from \"solid-js\";\nimport type { CorrectComponentType, Format } from \"../utils/index\";\nimport type { Path } from \"./internal\";\nimport type { BaseOptions } from \"./internal/types\";\n\nexport const makePathDataComponent = <RootData = any, Props = any>({\n\tuseRootData,\n\thooks,\n\tname,\n}: BaseOptions<RootData>): CorrectComponentType<\n\t{ propertyName: Path<RootData>; format?: Format } & Props\n> => {\n\tconst { usePath, useFormattedValue } = hooks;\n\treturn (props, { element }) => {\n\t\tif (untrack(() => !props.propertyName))\n\t\t\treturn console.warn(\n\t\t\t\t`${name}: No property-name attribute provided.`,\n\t\t\t\telement,\n\t\t\t);\n\t\tconst data = useRootData(element);\n\t\tconst fullPath = usePath({\n\t\t\telement,\n\t\t\tpath: () => props.propertyName,\n\t\t});\n\t\tconst formattedValue = useFormattedValue({\n\t\t\tget format() {\n\t\t\t\treturn props.format;\n\t\t\t},\n\t\t\tpath: fullPath,\n\t\t\tdata: data as any,\n\t\t});\n\t\t// `useFormattedValue` is declared as `Accessor<PathValue<...>>`, but it\n\t\t// only ever returns `formatValue`'s string or null. The declared generic\n\t\t// may be callable, which makes `<Show>`'s overloads ambiguous and would\n\t\t// let Solid *invoke* the child rather than render it.\n\t\tconst text = () => formattedValue() as string | null;\n\n\t\t// Control flow moved to `@solidjs/web` in v2, and this is JSX rather than\n\t\t// `solid-js/html` now that the build compiles it.\n\t\treturn <Show when={text() !== null}>{text()}</Show>;\n\t};\n};\n"],"mappings":";;;AAMA,IAAa,yBAAsD,EAClE,aACA,OACA,WAGI;CACJ,MAAM,EAAE,SAAS,sBAAsB;CACvC,QAAQ,OAAO,EAAE,cAAc;EAC9B,IAAI,cAAc,CAAC,MAAM,YAAY,GACpC,OAAO,QAAQ,KACd,GAAG,KAAK,yCACR,OACD;EACD,MAAM,OAAO,YAAY,OAAO;EAChC,MAAM,WAAW,QAAQ;GACxB;GACA,YAAY,MAAM;EACnB,CAAC;EACD,MAAM,iBAAiB,kBAAkB;GACxC,IAAI,SAAS;IACZ,OAAO,MAAM;GACd;GACA,MAAM;GACA;EACP,CAAC;EAKD,MAAM,aAAa,eAAe;EAIlC,OAAOA,gBAAAA,MAAAA;GAAM,IAAA,OAAA;IAAM,OAAA,KAAK,MAAM;GAAI;GAA3B,IAAA,WAAA;IAA8B,OAAA,KAAK;GAAQ;;CACnD;AACD"}