@carbon-labs/wc-date-picker 0.2.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 (156) hide show
  1. package/LICENSE +201 -0
  2. package/es/__stories__/date-picker.stories.d.ts +949 -0
  3. package/es/components/date-picker/calendar-renderer.d.ts +147 -0
  4. package/es/components/date-picker/calendar-renderer.js +406 -0
  5. package/es/components/date-picker/calendar-renderer.js.map +1 -0
  6. package/es/components/date-picker/date-picker-input-skeleton.d.ts +34 -0
  7. package/es/components/date-picker/date-picker-input-skeleton.js +77 -0
  8. package/es/components/date-picker/date-picker-input-skeleton.js.map +1 -0
  9. package/es/components/date-picker/date-picker-input.d.ts +539 -0
  10. package/es/components/date-picker/date-picker-input.js +413 -0
  11. package/es/components/date-picker/date-picker-input.js.map +1 -0
  12. package/es/components/date-picker/date-picker.d.ts +977 -0
  13. package/es/components/date-picker/date-picker.js +1047 -0
  14. package/es/components/date-picker/date-picker.js.map +1 -0
  15. package/es/components/date-picker/date-picker.scss.js +6 -0
  16. package/es/components/date-picker/date-picker.scss.js.map +1 -0
  17. package/es/components/date-picker/defs.d.ts +45 -0
  18. package/es/components/date-picker/defs.js +51 -0
  19. package/es/components/date-picker/defs.js.map +1 -0
  20. package/es/index.d.ts +10 -0
  21. package/es/index.js +5 -0
  22. package/es/index.js.map +1 -0
  23. package/es/state-machine/actions.d.ts +35 -0
  24. package/es/state-machine/actions.js +860 -0
  25. package/es/state-machine/actions.js.map +1 -0
  26. package/es/state-machine/adapters/web-component-adapter.d.ts +142 -0
  27. package/es/state-machine/adapters/web-component-adapter.js +269 -0
  28. package/es/state-machine/adapters/web-component-adapter.js.map +1 -0
  29. package/es/state-machine/effects.d.ts +35 -0
  30. package/es/state-machine/effects.js +92 -0
  31. package/es/state-machine/effects.js.map +1 -0
  32. package/es/state-machine/guards.d.ts +41 -0
  33. package/es/state-machine/guards.js +143 -0
  34. package/es/state-machine/guards.js.map +1 -0
  35. package/es/state-machine/index.d.ts +12 -0
  36. package/es/state-machine/machine.d.ts +92 -0
  37. package/es/state-machine/machine.js +272 -0
  38. package/es/state-machine/machine.js.map +1 -0
  39. package/es/state-machine/states.d.ts +89 -0
  40. package/es/state-machine/states.js +105 -0
  41. package/es/state-machine/states.js.map +1 -0
  42. package/es/state-machine/temporal-utils.d.ts +203 -0
  43. package/es/state-machine/temporal-utils.js +128 -0
  44. package/es/state-machine/temporal-utils.js.map +1 -0
  45. package/es/state-machine/types.d.ts +163 -0
  46. package/es/temp-imports/.storybook/templates/with-layer.d.ts +26 -0
  47. package/es/temp-imports/globals/decorators/carbon-element.d.ts +45 -0
  48. package/es/temp-imports/globals/decorators/carbon-element.js +63 -0
  49. package/es/temp-imports/globals/decorators/carbon-element.js.map +1 -0
  50. package/es/temp-imports/globals/decorators/host-listener.d.ts +17 -0
  51. package/es/temp-imports/globals/decorators/host-listener.js +62 -0
  52. package/es/temp-imports/globals/decorators/host-listener.js.map +1 -0
  53. package/es/temp-imports/globals/internal/collection-helpers.d.ts +41 -0
  54. package/es/temp-imports/globals/internal/handle.d.ts +16 -0
  55. package/es/temp-imports/globals/internal/icon-loader-utils.d.ts +31 -0
  56. package/es/temp-imports/globals/internal/icon-loader-utils.js +69 -0
  57. package/es/temp-imports/globals/internal/icon-loader-utils.js.map +1 -0
  58. package/es/temp-imports/globals/internal/icon-loader.d.ts +28 -0
  59. package/es/temp-imports/globals/internal/icon-loader.js +43 -0
  60. package/es/temp-imports/globals/internal/icon-loader.js.map +1 -0
  61. package/es/temp-imports/globals/mixins/focus.d.ts +369 -0
  62. package/es/temp-imports/globals/mixins/focus.js +38 -0
  63. package/es/temp-imports/globals/mixins/focus.js.map +1 -0
  64. package/es/temp-imports/globals/mixins/form.d.ts +379 -0
  65. package/es/temp-imports/globals/mixins/form.js +49 -0
  66. package/es/temp-imports/globals/mixins/form.js.map +1 -0
  67. package/es/temp-imports/globals/mixins/host-listener.d.ts +387 -0
  68. package/es/temp-imports/globals/mixins/host-listener.js +76 -0
  69. package/es/temp-imports/globals/mixins/host-listener.js.map +1 -0
  70. package/es/temp-imports/globals/mixins/on.d.ts +9 -0
  71. package/es/temp-imports/globals/mixins/on.js +19 -0
  72. package/es/temp-imports/globals/mixins/on.js.map +1 -0
  73. package/es/temp-imports/globals/settings.d.ts +13 -0
  74. package/es/temp-imports/globals/settings.js +76 -0
  75. package/es/temp-imports/globals/settings.js.map +1 -0
  76. package/es/temp-imports/globals/shared-enums.d.ts +19 -0
  77. package/es/temp-imports/globals/shared-enums.js +23 -0
  78. package/es/temp-imports/globals/shared-enums.js.map +1 -0
  79. package/lib/__stories__/date-picker.stories.d.ts +949 -0
  80. package/lib/components/date-picker/calendar-renderer.d.ts +147 -0
  81. package/lib/components/date-picker/calendar-renderer.js +408 -0
  82. package/lib/components/date-picker/calendar-renderer.js.map +1 -0
  83. package/lib/components/date-picker/date-picker-input-skeleton.d.ts +34 -0
  84. package/lib/components/date-picker/date-picker-input-skeleton.js +79 -0
  85. package/lib/components/date-picker/date-picker-input-skeleton.js.map +1 -0
  86. package/lib/components/date-picker/date-picker-input.d.ts +539 -0
  87. package/lib/components/date-picker/date-picker-input.js +422 -0
  88. package/lib/components/date-picker/date-picker-input.js.map +1 -0
  89. package/lib/components/date-picker/date-picker.d.ts +977 -0
  90. package/lib/components/date-picker/date-picker.js +1049 -0
  91. package/lib/components/date-picker/date-picker.js.map +1 -0
  92. package/lib/components/date-picker/date-picker.scss.js +10 -0
  93. package/lib/components/date-picker/date-picker.scss.js.map +1 -0
  94. package/lib/components/date-picker/defs.d.ts +45 -0
  95. package/lib/components/date-picker/defs.js +56 -0
  96. package/lib/components/date-picker/defs.js.map +1 -0
  97. package/lib/index.d.ts +10 -0
  98. package/lib/index.js +8 -0
  99. package/lib/index.js.map +1 -0
  100. package/lib/state-machine/actions.d.ts +35 -0
  101. package/lib/state-machine/actions.js +864 -0
  102. package/lib/state-machine/actions.js.map +1 -0
  103. package/lib/state-machine/adapters/web-component-adapter.d.ts +142 -0
  104. package/lib/state-machine/adapters/web-component-adapter.js +271 -0
  105. package/lib/state-machine/adapters/web-component-adapter.js.map +1 -0
  106. package/lib/state-machine/effects.d.ts +35 -0
  107. package/lib/state-machine/effects.js +96 -0
  108. package/lib/state-machine/effects.js.map +1 -0
  109. package/lib/state-machine/guards.d.ts +41 -0
  110. package/lib/state-machine/guards.js +147 -0
  111. package/lib/state-machine/guards.js.map +1 -0
  112. package/lib/state-machine/index.d.ts +12 -0
  113. package/lib/state-machine/machine.d.ts +92 -0
  114. package/lib/state-machine/machine.js +274 -0
  115. package/lib/state-machine/machine.js.map +1 -0
  116. package/lib/state-machine/states.d.ts +89 -0
  117. package/lib/state-machine/states.js +105 -0
  118. package/lib/state-machine/states.js.map +1 -0
  119. package/lib/state-machine/temporal-utils.d.ts +203 -0
  120. package/lib/state-machine/temporal-utils.js +136 -0
  121. package/lib/state-machine/temporal-utils.js.map +1 -0
  122. package/lib/state-machine/types.d.ts +163 -0
  123. package/lib/temp-imports/.storybook/templates/with-layer.d.ts +26 -0
  124. package/lib/temp-imports/globals/decorators/carbon-element.d.ts +45 -0
  125. package/lib/temp-imports/globals/decorators/carbon-element.js +65 -0
  126. package/lib/temp-imports/globals/decorators/carbon-element.js.map +1 -0
  127. package/lib/temp-imports/globals/decorators/host-listener.d.ts +17 -0
  128. package/lib/temp-imports/globals/decorators/host-listener.js +66 -0
  129. package/lib/temp-imports/globals/decorators/host-listener.js.map +1 -0
  130. package/lib/temp-imports/globals/internal/collection-helpers.d.ts +41 -0
  131. package/lib/temp-imports/globals/internal/handle.d.ts +16 -0
  132. package/lib/temp-imports/globals/internal/icon-loader-utils.d.ts +31 -0
  133. package/lib/temp-imports/globals/internal/icon-loader-utils.js +72 -0
  134. package/lib/temp-imports/globals/internal/icon-loader-utils.js.map +1 -0
  135. package/lib/temp-imports/globals/internal/icon-loader.d.ts +28 -0
  136. package/lib/temp-imports/globals/internal/icon-loader.js +45 -0
  137. package/lib/temp-imports/globals/internal/icon-loader.js.map +1 -0
  138. package/lib/temp-imports/globals/mixins/focus.d.ts +369 -0
  139. package/lib/temp-imports/globals/mixins/focus.js +42 -0
  140. package/lib/temp-imports/globals/mixins/focus.js.map +1 -0
  141. package/lib/temp-imports/globals/mixins/form.d.ts +379 -0
  142. package/lib/temp-imports/globals/mixins/form.js +53 -0
  143. package/lib/temp-imports/globals/mixins/form.js.map +1 -0
  144. package/lib/temp-imports/globals/mixins/host-listener.d.ts +387 -0
  145. package/lib/temp-imports/globals/mixins/host-listener.js +80 -0
  146. package/lib/temp-imports/globals/mixins/host-listener.js.map +1 -0
  147. package/lib/temp-imports/globals/mixins/on.d.ts +9 -0
  148. package/lib/temp-imports/globals/mixins/on.js +23 -0
  149. package/lib/temp-imports/globals/mixins/on.js.map +1 -0
  150. package/lib/temp-imports/globals/settings.d.ts +13 -0
  151. package/lib/temp-imports/globals/settings.js +79 -0
  152. package/lib/temp-imports/globals/settings.js.map +1 -0
  153. package/lib/temp-imports/globals/shared-enums.d.ts +19 -0
  154. package/lib/temp-imports/globals/shared-enums.js +23 -0
  155. package/lib/temp-imports/globals/shared-enums.js.map +1 -0
  156. package/package.json +44 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright IBM Corp. 2019, 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ const legacyCustomElement = (tagName, clazz) => {
8
+ try {
9
+ customElements.define(tagName, clazz);
10
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
11
+ }
12
+ catch (error) {
13
+ // eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20452
14
+ console.error(`Failed to define ${tagName}:`, error);
15
+ console.warn(`Attempting to re-define ${tagName}`);
16
+ }
17
+ // Cast as any because TS doesn't recognize the return type as being a
18
+ // subtype of the decorated class when clazz is typed as
19
+ // `Constructor<HTMLElement>` for some reason.
20
+ // `Constructor<HTMLElement>` is helpful to make sure the decorator is
21
+ // applied to elements however.
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ return clazz;
24
+ };
25
+ const standardCustomElement = (tagName, descriptor) => {
26
+ const { kind, elements } = descriptor;
27
+ return {
28
+ kind,
29
+ elements,
30
+ // This callback is called once the class is otherwise fully defined
31
+ finisher(clazz) {
32
+ try {
33
+ customElements.define(tagName, clazz);
34
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
35
+ }
36
+ catch (error) {
37
+ // eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20452
38
+ console.warn(`Attempting to re-define ${tagName}`);
39
+ }
40
+ },
41
+ };
42
+ };
43
+ /**
44
+ * Class decorator factory that defines the decorated class as a custom element.
45
+ *
46
+ * ```js
47
+ * @customElement('my-element')
48
+ * class MyElement extends LitElement {
49
+ * render() {
50
+ * return html``;
51
+ * }
52
+ * }
53
+ * ```
54
+ *
55
+ * @category Decorator
56
+ * @param tagName The tag name of the custom element to define.
57
+ */
58
+ const carbonElement = (tagName) => (classOrDescriptor) => typeof classOrDescriptor === 'function'
59
+ ? legacyCustomElement(tagName, classOrDescriptor)
60
+ : standardCustomElement(tagName, classOrDescriptor);
61
+
62
+ export { carbonElement };
63
+ //# sourceMappingURL=carbon-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carbon-element.js","sources":["../../../../../temp-imports/globals/decorators/carbon-element.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AAsCH,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAE,KAAyB,KAAI;AACzE,IAAA,IAAI;AACF,QAAA,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,KAAiC,CAAC;;IAEnE;IAAE,OAAO,KAAK,EAAE;;QAEd,OAAO,CAAC,KAAK,CAAC,CAAA,iBAAA,EAAoB,OAAO,CAAA,CAAA,CAAG,EAAE,KAAK,CAAC;AACpD,QAAA,OAAO,CAAC,IAAI,CAAC,2BAA2B,OAAO,CAAA,CAAE,CAAC;IACpD;;;;;;;AAOA,IAAA,OAAO,KAAY;AACrB,CAAC;AAED,MAAM,qBAAqB,GAAG,CAC5B,OAAe,EACf,UAA2B,KACzB;AACF,IAAA,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,UAAU;IACrC,OAAO;QACL,IAAI;QACJ,QAAQ;;AAER,QAAA,QAAQ,CAAC,KAA+B,EAAA;AACtC,YAAA,IAAI;AACF,gBAAA,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC;;YAEvC;YAAE,OAAO,KAAK,EAAE;;AAEd,gBAAA,OAAO,CAAC,IAAI,CAAC,2BAA2B,OAAO,CAAA,CAAE,CAAC;YACpD;QACF,CAAC;KACF;AACH,CAAC;AAED;;;;;;;;;;;;;;AAcG;AACI,MAAM,aAAa,GACxB,CAAC,OAAe,KAChB,CAAC,iBAAuD,KACtD,OAAO,iBAAiB,KAAK;AAC3B,MAAE,mBAAmB,CAAC,OAAO,EAAE,iBAAiB;AAChD,MAAE,qBAAqB,CAAC,OAAO,EAAE,iBAAoC;;;;"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright IBM Corp. 2019, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /**
8
+ * A decorator to add event listener to the host element, or its `document`/`window`, of a custom element.
9
+ * The `target` must extend `HostListenerMixin`.
10
+ *
11
+ * @param type
12
+ * The event type. Can be prefixed with `document:` or `window:`.
13
+ * The event listener is attached to host element's owner document or its default view in such case.
14
+ * @param options The event listener options.
15
+ */
16
+ declare const HostListener: (type: string, options?: boolean | AddEventListenerOptions) => (targetOrDescriptor: any, name: string) => any;
17
+ export default HostListener;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Copyright IBM Corp. 2019, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /**
8
+ * Puts an event listener to an internal table for `@HostListener()`.
9
+ *
10
+ * @param type
11
+ * The event type. Can be prefixed with `document:` or `window:`.
12
+ * The event listener is attached to host element's owner document or its default view in such case.
13
+ * @param options The event listener options.
14
+ * @param Clazz The target class.
15
+ * @param name The method name in the given target class that works as the event listener.
16
+ */
17
+ const setHostListener = (type, options, Clazz, name) => {
18
+ const hostListeners = Clazz._hostListeners;
19
+ if (!hostListeners) {
20
+ throw new Error('The method `@HostListener()` is defined on has to be of a class that has `HostListerMixin`.');
21
+ }
22
+ if (!hostListeners[name]) {
23
+ hostListeners[name] = {};
24
+ }
25
+ hostListeners[name][type] = { options };
26
+ };
27
+ /**
28
+ * @param type
29
+ * The event type. Can be prefixed with `document:` or `window:`.
30
+ * The event listener is attached to host element's owner document or its default view in such case.
31
+ * @param options The event listener options.
32
+ * @param descriptor The original class element descriptor of the event listener method.
33
+ * @returns The updated class element descriptor with `@HostListener()` decorator.
34
+ */
35
+ const HostListenerStandard = (type, options, descriptor) => {
36
+ const { kind, key, placement } = descriptor;
37
+ if (!((kind === 'method' && placement === 'prototype') ||
38
+ (kind === 'field' && placement === 'own'))) {
39
+ throw new Error('`@HostListener()` must be defined on instance methods, but you may have defined it on static, field, etc.');
40
+ }
41
+ return {
42
+ ...descriptor,
43
+ finisher(Clazz) {
44
+ setHostListener(type, options, Clazz, key);
45
+ },
46
+ };
47
+ };
48
+ /**
49
+ * A decorator to add event listener to the host element, or its `document`/`window`, of a custom element.
50
+ * The `target` must extend `HostListenerMixin`.
51
+ *
52
+ * @param type
53
+ * The event type. Can be prefixed with `document:` or `window:`.
54
+ * The event listener is attached to host element's owner document or its default view in such case.
55
+ * @param options The event listener options.
56
+ */
57
+ const HostListener = (type, options) => (targetOrDescriptor, name) => typeof name !== 'undefined'
58
+ ? setHostListener(type, options, targetOrDescriptor.constructor, name) // eslint-disable-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/20452
59
+ : HostListenerStandard(type, options, targetOrDescriptor); // eslint-disable-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/20452
60
+
61
+ export { HostListener as default };
62
+ //# sourceMappingURL=host-listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-listener.js","sources":["../../../../../temp-imports/globals/decorators/host-listener.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AAEH;;;;;;;;;AASG;AACH,MAAM,eAAe,GAAG,CACtB,IAAY,EACZ,OAA0C,EAC1C,KAAK,EACL,IAAY,KACV;AACF,IAAA,MAAM,aAAa,GAAG,KAAK,CAAC,cAAc;IAC1C,IAAI,CAAC,aAAa,EAAE;AAClB,QAAA,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F;IACH;AACA,IAAA,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;AACxB,QAAA,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE;IAC1B;IACA,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE;AACzC,CAAC;AAED;;;;;;;AAOG;AACH,MAAM,oBAAoB,GAAG,CAC3B,IAAY,EACZ,OAA0C,EAC1C,UAAU,KACR;IACF,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,UAAU;IAC3C,IACE,EACE,CAAC,IAAI,KAAK,QAAQ,IAAI,SAAS,KAAK,WAAW;SAC9C,IAAI,KAAK,OAAO,IAAI,SAAS,KAAK,KAAK,CAAC,CAC1C,EACD;AACA,QAAA,MAAM,IAAI,KAAK,CACb,2GAA2G,CAC5G;IACH;IACA,OAAO;AACL,QAAA,GAAG,UAAU;AACb,QAAA,QAAQ,CAAC,KAAK,EAAA;YACZ,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;QAC5C,CAAC;KACF;AACH,CAAC;AAED;;;;;;;;AAQG;AACH,MAAM,YAAY,GAChB,CAAC,IAAY,EAAE,OAA2C,KAC1D,CAAC,kBAAkB,EAAE,IAAY,KAC/B,OAAO,IAAI,KAAK;AACd,MAAE,eAAe,CAAC,IAAI,EAAE,OAAQ,EAAE,kBAAkB,CAAC,WAAW,EAAE,IAAI,CAAC;MACrE,oBAAoB,CAAC,IAAI,EAAE,OAAQ,EAAE,kBAAkB,EAAE;;;;"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright IBM Corp. 2019, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /**
8
+ * @param a A DOM collection.
9
+ * @param predicate The callback function.
10
+ * @param [thisObject] The context object for the given callback function.
11
+ * @returns A new array with all elements where `predicate` returns truthy.
12
+ */
13
+ export declare const filter: (a: NodeListOf<Node> | HTMLCollectionOf<Element>, predicate: (search: Node, index?: number) => boolean, thisObject?: any) => any[];
14
+ /**
15
+ * @param a A DOM collection.
16
+ * @param predicate The callback function.
17
+ * @param [thisObject] The context object for the given callback function.
18
+ * @returns The index of the first item in the given collection where `predicate` returns `true`. `-1` if no such item is found.
19
+ */
20
+ export declare const findIndex: (a: NodeListOf<Node> | HTMLCollectionOf<Element>, predicate: (search: Node, index?: number) => boolean, thisObject?: any) => number;
21
+ /**
22
+ * @param a A DOM collection.
23
+ * @param predicate The callback function.
24
+ * @param [thisObject] The context object for the given callback function.
25
+ * @returns The first item in the given collection where `predicate` returns `true`. `null` if no such item is found.
26
+ */
27
+ export declare const find: (a: NodeListOf<Node> | HTMLCollectionOf<Element>, predicate: (search: Node, index?: number) => boolean, thisObject?: any) => any;
28
+ /**
29
+ * Walks through the given DOM collection and runs the given callback.
30
+ *
31
+ * @param a A DOM collection.
32
+ * @param predicate The callback function.
33
+ * @param [thisObject] The context object for the given callback function.
34
+ */
35
+ export declare const forEach: (a: NodeListOf<Node> | HTMLCollectionOf<Element>, predicate: (search: Element, index?: number) => void, thisObject?: any) => void;
36
+ /**
37
+ * @param a A DOM collection.
38
+ * @param item An item in the DOM collection.
39
+ * @returns The index of the first occurence of the given item in the given collection. `-1` if no such item is found.
40
+ */
41
+ export declare const indexOf: (a: NodeListOf<Node> | HTMLCollectionOf<Element>, item: Node) => number;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright IBM Corp. 2019
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /**
8
+ * An object to keep track of things that can be cleaned up.
9
+ */
10
+ export default interface Handle {
11
+ /**
12
+ * Releases the thing that this object is keeping track of.
13
+ * For example, if this `Handle` is keeping track of an event listener, this `release()` method removes the event listener.
14
+ */
15
+ release(): null;
16
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright IBM Corp. 2019, 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export interface CarbonIconElement {
8
+ elem: string;
9
+ attrs: Record<string, string | number>;
10
+ content: (CarbonIconElement | string)[];
11
+ }
12
+ export interface CarbonIconDescriptor {
13
+ elem: string;
14
+ attrs: Record<string, string | number>;
15
+ content: CarbonIconElement[];
16
+ name: string;
17
+ size: number;
18
+ }
19
+ export interface CarbonIconModule {
20
+ default?: CarbonIconDescriptor;
21
+ }
22
+ export type CarbonIcon = CarbonIconDescriptor | CarbonIconModule;
23
+ /**
24
+ * Convert an imported icon descriptor to an SVG string, e.g.
25
+ * import ChevronRight16 from '@carbon/icons/es/chevron--right/16.js';
26
+ */
27
+ export declare function carbonIconToSVG(descriptor: CarbonIcon, attributes?: Record<string, string | number | undefined>): string;
28
+ /**
29
+ * Create an icon function that returns a Lit template with unsafeSVG
30
+ */
31
+ export declare function createIconTemplate(descriptor: CarbonIcon): (attributes?: Record<string, string | number | undefined>) => import("lit-html/directive").DirectiveResult<typeof import("lit-html/directives/unsafe-svg").UnsafeSVGDirective>;
@@ -0,0 +1,69 @@
1
+ import { getAttributes, formatAttributes } from '@carbon/icon-helpers';
2
+ import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
3
+
4
+ /**
5
+ * Copyright IBM Corp. 2019, 2024
6
+ *
7
+ * This source code is licensed under the Apache-2.0 license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ // Helper function to get the actual descriptor
11
+ function getIconDescriptor(descriptor) {
12
+ return 'default' in descriptor && descriptor.default
13
+ ? descriptor.default
14
+ : descriptor;
15
+ }
16
+ /**
17
+ * Convert an imported icon descriptor to an SVG string, e.g.
18
+ * import ChevronRight16 from '@carbon/icons/es/chevron--right/16.js';
19
+ */
20
+ function carbonIconToSVG(descriptor, attributes = {}) {
21
+ const iconDescriptor = getIconDescriptor(descriptor);
22
+ // Ensure attrs exists
23
+ if (!iconDescriptor.attrs) {
24
+ iconDescriptor.attrs = {};
25
+ }
26
+ // Merge attributes
27
+ const mergedAttrs = {
28
+ ...iconDescriptor.attrs,
29
+ ...attributes,
30
+ };
31
+ // Process attributes
32
+ const processedAttrs = getAttributes(mergedAttrs);
33
+ // Ensure proper attribute formatting
34
+ const attrString = formatAttributes(processedAttrs);
35
+ // Process content
36
+ const content = iconDescriptor.content || [];
37
+ const contentString = content
38
+ .map((child) => {
39
+ if (typeof child === 'string')
40
+ return child;
41
+ return elementToSVG(child);
42
+ })
43
+ .join('');
44
+ return `<svg ${attrString}>${contentString}</svg>`;
45
+ }
46
+ /**
47
+ * Convert an element to SVG string
48
+ */
49
+ function elementToSVG(element) {
50
+ if (typeof element === 'string') {
51
+ return element;
52
+ }
53
+ const { elem = 'svg', attrs = {}, content = [] } = element;
54
+ const children = content.map(elementToSVG).join('');
55
+ const attrString = formatAttributes(attrs);
56
+ return `<${elem} ${attrString}>${children}</${elem}>`;
57
+ }
58
+ /**
59
+ * Create an icon function that returns a Lit template with unsafeSVG
60
+ */
61
+ function createIconTemplate(descriptor) {
62
+ return (attributes = {}) => {
63
+ const svgString = carbonIconToSVG(descriptor, attributes);
64
+ return unsafeSVG(svgString);
65
+ };
66
+ }
67
+
68
+ export { carbonIconToSVG, createIconTemplate };
69
+ //# sourceMappingURL=icon-loader-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon-loader-utils.js","sources":["../../../../../temp-imports/globals/internal/icon-loader-utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;AAKG;AA4BH;AACA,SAAS,iBAAiB,CAAC,UAAsB,EAAA;AAC/C,IAAA,OAAO,SAAS,IAAI,UAAU,IAAI,UAAU,CAAC;UACxC,UAAU,CAAC;UACX,UAAmC;AAC1C;AAEA;;;AAGG;SACa,eAAe,CAC7B,UAAsB,EACtB,aAA0D,EAAE,EAAA;AAE5D,IAAA,MAAM,cAAc,GAAG,iBAAiB,CAAC,UAAU,CAAC;;AAGpD,IAAA,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE;AACzB,QAAA,cAAc,CAAC,KAAK,GAAG,EAAE;IAC3B;;AAGA,IAAA,MAAM,WAAW,GAAG;QAClB,GAAG,cAAc,CAAC,KAAK;AACvB,QAAA,GAAG,UAAU;KACd;;AAGD,IAAA,MAAM,cAAc,GAAG,aAAa,CAAC,WAAW,CAAC;;AAGjD,IAAA,MAAM,UAAU,GAAG,gBAAgB,CAAC,cAAc,CAAC;;AAGnD,IAAA,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,IAAI,EAAE;IAC5C,MAAM,aAAa,GAAG;AACnB,SAAA,GAAG,CAAC,CAAC,KAAiC,KAAI;QACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,YAAA,OAAO,KAAK;AAC3C,QAAA,OAAO,YAAY,CAAC,KAAK,CAAC;AAC5B,IAAA,CAAC;SACA,IAAI,CAAC,EAAE,CAAC;AAEX,IAAA,OAAO,CAAA,KAAA,EAAQ,UAAU,CAAA,CAAA,EAAI,aAAa,QAAQ;AACpD;AAEA;;AAEG;AACH,SAAS,YAAY,CAAC,OAAmC,EAAA;AACvD,IAAA,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;AAC/B,QAAA,OAAO,OAAO;IAChB;AAEA,IAAA,MAAM,EAAE,IAAI,GAAG,KAAK,EAAE,KAAK,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,OAAO;AAC1D,IAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACnD,IAAA,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAK,CAAC;IAE1C,OAAO,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA,EAAI,UAAU,IAAI,QAAQ,CAAA,EAAA,EAAK,IAAI,CAAA,CAAA,CAAG;AACvD;AAEA;;AAEG;AACG,SAAU,kBAAkB,CAAC,UAAsB,EAAA;AACvD,IAAA,OAAO,CAAC,UAAA,GAA0D,EAAE,KAAI;QACtE,MAAM,SAAS,GAAG,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC;AACzD,QAAA,OAAO,SAAS,CAAC,SAAS,CAAC;AAC7B,IAAA,CAAC;AACH;;;;"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright IBM Corp. 2019, 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
8
+ import { type CarbonIcon } from './icon-loader-utils';
9
+ import type { TemplateResult } from 'lit';
10
+ /**
11
+ * Icon utility function that returns pure SVG content without any wrapper element.
12
+ * This preserves all existing CSS selectors and provides a unified way to render icons.
13
+ *
14
+ * For Carbon icons, import directly in your component:
15
+ * import ChevronRight16 from '@carbon/icons/es/chevron--right/16.js';
16
+ *
17
+ * Usage:
18
+ * Icon import: ${iconLoader(ChevronRight16)}
19
+ * With attributes: ${iconLoader(ChevronRight16, { class: 'my-class', slot: 'icon' })}
20
+ * SVG string: ${iconLoader(null, {}, '<svg>...</svg>')}
21
+ *
22
+ * @param icon - Icon descriptor from import, Lit template, or null for custom SVG
23
+ * @param attributes - Additional attributes to apply to the SVG
24
+ * @param customSvg - Custom SVG string (used when icon is null)
25
+ * @returns Lit template with pure SVG content
26
+ */
27
+ export declare function iconLoader(icon: CarbonIcon | TemplateResult | null, attributes?: Record<string, string | number | undefined>, customSvg?: string): TemplateResult | ReturnType<typeof unsafeSVG> | null;
28
+ export default iconLoader;
@@ -0,0 +1,43 @@
1
+ import 'lit/directives/unsafe-svg.js';
2
+ import { createIconTemplate } from './icon-loader-utils.js';
3
+
4
+ /**
5
+ * Copyright IBM Corp. 2019, 2024
6
+ *
7
+ * This source code is licensed under the Apache-2.0 license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ /**
11
+ * Icon utility function that returns pure SVG content without any wrapper element.
12
+ * This preserves all existing CSS selectors and provides a unified way to render icons.
13
+ *
14
+ * For Carbon icons, import directly in your component:
15
+ * import ChevronRight16 from '@carbon/icons/es/chevron--right/16.js';
16
+ *
17
+ * Usage:
18
+ * Icon import: ${iconLoader(ChevronRight16)}
19
+ * With attributes: ${iconLoader(ChevronRight16, { class: 'my-class', slot: 'icon' })}
20
+ * SVG string: ${iconLoader(null, {}, '<svg>...</svg>')}
21
+ *
22
+ * @param icon - Icon descriptor from import, Lit template, or null for custom SVG
23
+ * @param attributes - Additional attributes to apply to the SVG
24
+ * @param customSvg - Custom SVG string (used when icon is null)
25
+ * @returns Lit template with pure SVG content
26
+ */
27
+ function iconLoader(icon, attributes = {}, customSvg) {
28
+ // Imported icon
29
+ if (icon) {
30
+ // If it's an imported icon descriptor such as ChevronRight16, convert to SVG
31
+ if ('default' in icon || ('attrs' in icon && 'content' in icon)) {
32
+ const iconTemplate = createIconTemplate(icon);
33
+ return iconTemplate(attributes);
34
+ }
35
+ // If it's a Lit template or other content
36
+ return icon;
37
+ }
38
+ // No icon provided
39
+ return null;
40
+ }
41
+
42
+ export { iconLoader };
43
+ //# sourceMappingURL=icon-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon-loader.js","sources":["../../../../../temp-imports/globals/internal/icon-loader.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAMH;;;;;;;;;;;;;;;;AAgBG;AACG,SAAU,UAAU,CACxB,IAAwC,EACxC,UAAA,GAA0D,EAAE,EAC5D,SAAkB,EAAA;;IAQlB,IAAI,IAAI,EAAE;;AAER,QAAA,IAAI,SAAS,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,CAAC,EAAE;AAC/D,YAAA,MAAM,YAAY,GAAG,kBAAkB,CAAC,IAAkB,CAAC;AAC3D,YAAA,OAAO,YAAY,CAAC,UAAU,CAAC;QACjC;;AAEA,QAAA,OAAO,IAAsB;IAC/B;;AAGA,IAAA,OAAO,IAAI;AACb;;;;"}