@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,65 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Copyright IBM Corp. 2019, 2026
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ const legacyCustomElement = (tagName, clazz) => {
10
+ try {
11
+ customElements.define(tagName, clazz);
12
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
13
+ }
14
+ catch (error) {
15
+ // eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20452
16
+ console.error(`Failed to define ${tagName}:`, error);
17
+ console.warn(`Attempting to re-define ${tagName}`);
18
+ }
19
+ // Cast as any because TS doesn't recognize the return type as being a
20
+ // subtype of the decorated class when clazz is typed as
21
+ // `Constructor<HTMLElement>` for some reason.
22
+ // `Constructor<HTMLElement>` is helpful to make sure the decorator is
23
+ // applied to elements however.
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+ return clazz;
26
+ };
27
+ const standardCustomElement = (tagName, descriptor) => {
28
+ const { kind, elements } = descriptor;
29
+ return {
30
+ kind,
31
+ elements,
32
+ // This callback is called once the class is otherwise fully defined
33
+ finisher(clazz) {
34
+ try {
35
+ customElements.define(tagName, clazz);
36
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
37
+ }
38
+ catch (error) {
39
+ // eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20452
40
+ console.warn(`Attempting to re-define ${tagName}`);
41
+ }
42
+ },
43
+ };
44
+ };
45
+ /**
46
+ * Class decorator factory that defines the decorated class as a custom element.
47
+ *
48
+ * ```js
49
+ * @customElement('my-element')
50
+ * class MyElement extends LitElement {
51
+ * render() {
52
+ * return html``;
53
+ * }
54
+ * }
55
+ * ```
56
+ *
57
+ * @category Decorator
58
+ * @param tagName The tag name of the custom element to define.
59
+ */
60
+ const carbonElement = (tagName) => (classOrDescriptor) => typeof classOrDescriptor === 'function'
61
+ ? legacyCustomElement(tagName, classOrDescriptor)
62
+ : standardCustomElement(tagName, classOrDescriptor);
63
+
64
+ exports.carbonElement = carbonElement;
65
+ //# 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,66 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * Copyright IBM Corp. 2019, 2022
7
+ *
8
+ * This source code is licensed under the Apache-2.0 license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */
11
+ /**
12
+ * Puts an event listener to an internal table for `@HostListener()`.
13
+ *
14
+ * @param type
15
+ * The event type. Can be prefixed with `document:` or `window:`.
16
+ * The event listener is attached to host element's owner document or its default view in such case.
17
+ * @param options The event listener options.
18
+ * @param Clazz The target class.
19
+ * @param name The method name in the given target class that works as the event listener.
20
+ */
21
+ const setHostListener = (type, options, Clazz, name) => {
22
+ const hostListeners = Clazz._hostListeners;
23
+ if (!hostListeners) {
24
+ throw new Error('The method `@HostListener()` is defined on has to be of a class that has `HostListerMixin`.');
25
+ }
26
+ if (!hostListeners[name]) {
27
+ hostListeners[name] = {};
28
+ }
29
+ hostListeners[name][type] = { options };
30
+ };
31
+ /**
32
+ * @param type
33
+ * The event type. Can be prefixed with `document:` or `window:`.
34
+ * The event listener is attached to host element's owner document or its default view in such case.
35
+ * @param options The event listener options.
36
+ * @param descriptor The original class element descriptor of the event listener method.
37
+ * @returns The updated class element descriptor with `@HostListener()` decorator.
38
+ */
39
+ const HostListenerStandard = (type, options, descriptor) => {
40
+ const { kind, key, placement } = descriptor;
41
+ if (!((kind === 'method' && placement === 'prototype') ||
42
+ (kind === 'field' && placement === 'own'))) {
43
+ throw new Error('`@HostListener()` must be defined on instance methods, but you may have defined it on static, field, etc.');
44
+ }
45
+ return {
46
+ ...descriptor,
47
+ finisher(Clazz) {
48
+ setHostListener(type, options, Clazz, key);
49
+ },
50
+ };
51
+ };
52
+ /**
53
+ * A decorator to add event listener to the host element, or its `document`/`window`, of a custom element.
54
+ * The `target` must extend `HostListenerMixin`.
55
+ *
56
+ * @param type
57
+ * The event type. Can be prefixed with `document:` or `window:`.
58
+ * The event listener is attached to host element's owner document or its default view in such case.
59
+ * @param options The event listener options.
60
+ */
61
+ const HostListener = (type, options) => (targetOrDescriptor, name) => typeof name !== 'undefined'
62
+ ? setHostListener(type, options, targetOrDescriptor.constructor, name) // eslint-disable-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/20452
63
+ : HostListenerStandard(type, options, targetOrDescriptor); // eslint-disable-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/20452
64
+
65
+ exports.default = HostListener;
66
+ //# 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,72 @@
1
+ 'use strict';
2
+
3
+ var iconHelpers = require('@carbon/icon-helpers');
4
+ var unsafeSvg_js = require('lit/directives/unsafe-svg.js');
5
+
6
+ /**
7
+ * Copyright IBM Corp. 2019, 2024
8
+ *
9
+ * This source code is licensed under the Apache-2.0 license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ // Helper function to get the actual descriptor
13
+ function getIconDescriptor(descriptor) {
14
+ return 'default' in descriptor && descriptor.default
15
+ ? descriptor.default
16
+ : descriptor;
17
+ }
18
+ /**
19
+ * Convert an imported icon descriptor to an SVG string, e.g.
20
+ * import ChevronRight16 from '@carbon/icons/es/chevron--right/16.js';
21
+ */
22
+ function carbonIconToSVG(descriptor, attributes = {}) {
23
+ const iconDescriptor = getIconDescriptor(descriptor);
24
+ // Ensure attrs exists
25
+ if (!iconDescriptor.attrs) {
26
+ iconDescriptor.attrs = {};
27
+ }
28
+ // Merge attributes
29
+ const mergedAttrs = {
30
+ ...iconDescriptor.attrs,
31
+ ...attributes,
32
+ };
33
+ // Process attributes
34
+ const processedAttrs = iconHelpers.getAttributes(mergedAttrs);
35
+ // Ensure proper attribute formatting
36
+ const attrString = iconHelpers.formatAttributes(processedAttrs);
37
+ // Process content
38
+ const content = iconDescriptor.content || [];
39
+ const contentString = content
40
+ .map((child) => {
41
+ if (typeof child === 'string')
42
+ return child;
43
+ return elementToSVG(child);
44
+ })
45
+ .join('');
46
+ return `<svg ${attrString}>${contentString}</svg>`;
47
+ }
48
+ /**
49
+ * Convert an element to SVG string
50
+ */
51
+ function elementToSVG(element) {
52
+ if (typeof element === 'string') {
53
+ return element;
54
+ }
55
+ const { elem = 'svg', attrs = {}, content = [] } = element;
56
+ const children = content.map(elementToSVG).join('');
57
+ const attrString = iconHelpers.formatAttributes(attrs);
58
+ return `<${elem} ${attrString}>${children}</${elem}>`;
59
+ }
60
+ /**
61
+ * Create an icon function that returns a Lit template with unsafeSVG
62
+ */
63
+ function createIconTemplate(descriptor) {
64
+ return (attributes = {}) => {
65
+ const svgString = carbonIconToSVG(descriptor, attributes);
66
+ return unsafeSvg_js.unsafeSVG(svgString);
67
+ };
68
+ }
69
+
70
+ exports.carbonIconToSVG = carbonIconToSVG;
71
+ exports.createIconTemplate = createIconTemplate;
72
+ //# 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":["getAttributes","formatAttributes","unsafeSVG"],"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,GAAGA,yBAAa,CAAC,WAAW,CAAC;;AAGjD,IAAA,MAAM,UAAU,GAAGC,4BAAgB,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,GAAGA,4BAAgB,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,OAAOC,sBAAS,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,45 @@
1
+ 'use strict';
2
+
3
+ require('lit/directives/unsafe-svg.js');
4
+ var iconLoaderUtils = require('./icon-loader-utils.js');
5
+
6
+ /**
7
+ * Copyright IBM Corp. 2019, 2024
8
+ *
9
+ * This source code is licensed under the Apache-2.0 license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ /**
13
+ * Icon utility function that returns pure SVG content without any wrapper element.
14
+ * This preserves all existing CSS selectors and provides a unified way to render icons.
15
+ *
16
+ * For Carbon icons, import directly in your component:
17
+ * import ChevronRight16 from '@carbon/icons/es/chevron--right/16.js';
18
+ *
19
+ * Usage:
20
+ * Icon import: ${iconLoader(ChevronRight16)}
21
+ * With attributes: ${iconLoader(ChevronRight16, { class: 'my-class', slot: 'icon' })}
22
+ * SVG string: ${iconLoader(null, {}, '<svg>...</svg>')}
23
+ *
24
+ * @param icon - Icon descriptor from import, Lit template, or null for custom SVG
25
+ * @param attributes - Additional attributes to apply to the SVG
26
+ * @param customSvg - Custom SVG string (used when icon is null)
27
+ * @returns Lit template with pure SVG content
28
+ */
29
+ function iconLoader(icon, attributes = {}, customSvg) {
30
+ // Imported icon
31
+ if (icon) {
32
+ // If it's an imported icon descriptor such as ChevronRight16, convert to SVG
33
+ if ('default' in icon || ('attrs' in icon && 'content' in icon)) {
34
+ const iconTemplate = iconLoaderUtils.createIconTemplate(icon);
35
+ return iconTemplate(attributes);
36
+ }
37
+ // If it's a Lit template or other content
38
+ return icon;
39
+ }
40
+ // No icon provided
41
+ return null;
42
+ }
43
+
44
+ exports.iconLoader = iconLoader;
45
+ //# 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":["createIconTemplate"],"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,GAAGA,kCAAkB,CAAC,IAAkB,CAAC;AAC3D,YAAA,OAAO,YAAY,CAAC,UAAU,CAAC;QACjC;;AAEA,QAAA,OAAO,IAAsB;IAC/B;;AAGA,IAAA,OAAO,IAAI;AACb;;;;"}