@usecapsule/core-components 3.3.0-dev.0 → 3.3.0-dev.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. package/css/capsule-core.css +10 -25
  2. package/css/capsule-core.css.map +1 -1
  3. package/dist/capsule/capsule.esm.js +1 -1
  4. package/dist/capsule/capsule.esm.js.map +1 -1
  5. package/dist/capsule/index.esm.js +1 -1
  6. package/dist/capsule/index.esm.js.map +1 -1
  7. package/dist/capsule/p-0462f723.js +2 -0
  8. package/dist/capsule/p-0462f723.js.map +1 -0
  9. package/dist/capsule/p-05cb769b.entry.js +10 -0
  10. package/dist/capsule/{p-0e558c7f.entry.js.map → p-05cb769b.entry.js.map} +1 -1
  11. package/dist/capsule/p-0eea90f8.entry.js +2 -0
  12. package/dist/capsule/p-4203888d.entry.js +29 -0
  13. package/dist/capsule/p-4203888d.entry.js.map +1 -0
  14. package/dist/capsule/{p-1bd11889.entry.js → p-69c3c53b.entry.js} +2 -2
  15. package/dist/capsule/{p-1bd11889.entry.js.map → p-69c3c53b.entry.js.map} +1 -1
  16. package/dist/capsule/{p-5d62e610.entry.js → p-742bda0b.entry.js} +2 -2
  17. package/dist/capsule/p-c1aa1ffb.entry.js +2 -0
  18. package/dist/capsule/{p-5965b15e.entry.js.map → p-c1aa1ffb.entry.js.map} +1 -1
  19. package/dist/capsule/p-d351f076.entry.js +2 -0
  20. package/dist/capsule/p-d351f076.entry.js.map +1 -0
  21. package/dist/cjs/_commonjsHelpers-b3309d7b.js +12 -0
  22. package/dist/cjs/_commonjsHelpers-b3309d7b.js.map +1 -0
  23. package/dist/cjs/capsule.cjs.js +1 -1
  24. package/dist/cjs/{cpsl-alert_34.cjs.entry.js → cpsl-alert_33.cjs.entry.js} +13368 -16935
  25. package/dist/cjs/cpsl-alert_33.cjs.entry.js.map +1 -0
  26. package/dist/cjs/cpsl-animation.cjs.entry.js +2 -3
  27. package/dist/cjs/cpsl-animation.cjs.entry.js.map +1 -1
  28. package/dist/cjs/cpsl-hero.cjs.entry.js +6 -9
  29. package/dist/cjs/cpsl-hero.cjs.entry.js.map +1 -1
  30. package/dist/cjs/cpsl-identicon.cjs.entry.js +1 -1
  31. package/dist/cjs/cpsl-info-box.cjs.entry.js +2 -2
  32. package/dist/cjs/cpsl-info-box.cjs.entry.js.map +1 -1
  33. package/dist/cjs/cpsl-modal-v2.cjs.entry.js +1 -1
  34. package/dist/cjs/cpsl-modal-v2.cjs.entry.js.map +1 -1
  35. package/dist/cjs/cpsl-row.cjs.entry.js +1 -1
  36. package/dist/cjs/index-65f57499.js +2 -2
  37. package/dist/cjs/index.cjs.js +12 -35
  38. package/dist/cjs/index.cjs.js.map +1 -1
  39. package/dist/cjs/loader.cjs.js +1 -1
  40. package/dist/collection/assets/icons/index.js +1 -21
  41. package/dist/collection/assets/icons/index.js.map +1 -1
  42. package/dist/collection/assets/icons/refresh.svg +3 -3
  43. package/dist/collection/collection-manifest.json +1 -2
  44. package/dist/collection/components/cpsl-alert/cpsl-alert.js +2 -2
  45. package/dist/collection/components/cpsl-alert/cpsl-alert.js.map +1 -1
  46. package/dist/collection/components/cpsl-button/cpsl-button.css +2 -89
  47. package/dist/collection/components/cpsl-button/cpsl-button.js +5 -6
  48. package/dist/collection/components/cpsl-button/cpsl-button.js.map +1 -1
  49. package/dist/collection/components/cpsl-button/cpsl-button.stories.js.map +1 -1
  50. package/dist/collection/components/cpsl-card/cpsl-card.css +2 -5
  51. package/dist/collection/components/cpsl-code-input/cpsl-code-input.css +0 -3
  52. package/dist/collection/components/cpsl-code-input/cpsl-code-input.js +7 -11
  53. package/dist/collection/components/cpsl-code-input/cpsl-code-input.js.map +1 -1
  54. package/dist/collection/components/cpsl-divider/cpsl-divider.css +1 -2
  55. package/dist/collection/components/cpsl-drawer/cpsl-drawer.js +1 -1
  56. package/dist/collection/components/cpsl-drawer/cpsl-drawer.js.map +1 -1
  57. package/dist/collection/components/cpsl-dropdown/cpsl-dropdown.js +2 -2
  58. package/dist/collection/components/cpsl-dropdown/cpsl-dropdown.js.map +1 -1
  59. package/dist/collection/components/cpsl-file-upload/cpsl-file-upload.js +6 -1
  60. package/dist/collection/components/cpsl-file-upload/cpsl-file-upload.js.map +1 -1
  61. package/dist/collection/components/cpsl-hero/cpsl-hero.css +71 -136
  62. package/dist/collection/components/cpsl-hero/cpsl-hero.js +9 -63
  63. package/dist/collection/components/cpsl-hero/cpsl-hero.js.map +1 -1
  64. package/dist/collection/components/cpsl-icon/cpsl-icon.css +0 -8
  65. package/dist/collection/components/cpsl-icon/cpsl-icon.js +2 -2
  66. package/dist/collection/components/cpsl-identicon/cpsl-identicon.js +1 -1
  67. package/dist/collection/components/cpsl-info-box/cpsl-info-box.css +2 -1
  68. package/dist/collection/components/cpsl-info-box/cpsl-info-box.js +1 -1
  69. package/dist/collection/components/cpsl-input/cpsl-input.css +2 -21
  70. package/dist/collection/components/cpsl-input/cpsl-input.js +28 -100
  71. package/dist/collection/components/cpsl-input/cpsl-input.js.map +1 -1
  72. package/dist/collection/components/{cpsl-auth-modal/cpsl-auth-modal.css → cpsl-modal/cpsl-modal.css} +58 -33
  73. package/dist/collection/components/{cpsl-auth-modal/cpsl-auth-modal.js → cpsl-modal/cpsl-modal.js} +129 -11
  74. package/dist/collection/components/cpsl-modal/cpsl-modal.js.map +1 -0
  75. package/dist/collection/components/cpsl-modal-v2/cpsl-modal-v2.js +1 -1
  76. package/dist/collection/components/cpsl-modal-v2/cpsl-modal-v2.js.map +1 -1
  77. package/dist/collection/components/cpsl-nav-button-group/cpsl-nav-button-group.js +1 -1
  78. package/dist/collection/components/cpsl-overlay/cpsl-overlay.js +1 -1
  79. package/dist/collection/components/cpsl-pagination/cpsl-pagination.js +1 -1
  80. package/dist/collection/components/cpsl-pill/cpsl-pill.js +1 -1
  81. package/dist/collection/components/cpsl-popover/cpsl-popover.css +0 -2
  82. package/dist/collection/components/cpsl-popover/cpsl-popover.js +11 -9
  83. package/dist/collection/components/cpsl-popover/cpsl-popover.js.map +1 -1
  84. package/dist/collection/components/cpsl-qr-code/cpsl-qr-code.css +3 -12
  85. package/dist/collection/components/cpsl-qr-code/cpsl-qr-code.js +23 -28
  86. package/dist/collection/components/cpsl-qr-code/cpsl-qr-code.js.map +1 -1
  87. package/dist/collection/components/cpsl-radio/cpsl-radio.js +1 -1
  88. package/dist/collection/components/cpsl-row/cpsl-row.js +1 -1
  89. package/dist/collection/components/cpsl-select/cpsl-select.css +0 -17
  90. package/dist/collection/components/cpsl-select/cpsl-select.js +5 -95
  91. package/dist/collection/components/cpsl-select/cpsl-select.js.map +1 -1
  92. package/dist/collection/components/cpsl-select-item/cpsl-select-item.js +1 -1
  93. package/dist/collection/components/cpsl-select-item/cpsl-select-item.js.map +1 -1
  94. package/dist/collection/components/cpsl-slide-button/cpsl-slide-button.js +3 -3
  95. package/dist/collection/components/cpsl-slide-button/cpsl-slide-button.js.map +1 -1
  96. package/dist/collection/components/cpsl-spinner/cpsl-spinner.css +8 -30
  97. package/dist/collection/components/cpsl-spinner/cpsl-spinner.js +7 -5
  98. package/dist/collection/components/cpsl-spinner/cpsl-spinner.js.map +1 -1
  99. package/dist/collection/components/cpsl-switch/cpsl-switch.js +1 -1
  100. package/dist/collection/components/cpsl-tab/cpsl-tab.css +1 -24
  101. package/dist/collection/components/cpsl-tab/cpsl-tab.js +1 -1
  102. package/dist/collection/components/cpsl-tab/cpsl-tab.js.map +1 -1
  103. package/dist/collection/components/cpsl-table/cpsl-table.js +9 -1
  104. package/dist/collection/components/cpsl-table/cpsl-table.js.map +1 -1
  105. package/dist/collection/components/cpsl-tabs/cpsl-tabs.css +4 -1
  106. package/dist/collection/components/cpsl-tabs/cpsl-tabs.js +4 -1
  107. package/dist/collection/components/cpsl-tabs/cpsl-tabs.js.map +1 -1
  108. package/dist/collection/components/cpsl-text/cpsl-text.css +0 -19
  109. package/dist/collection/components/cpsl-text/cpsl-text.js +4 -5
  110. package/dist/collection/components/cpsl-text/cpsl-text.js.map +1 -1
  111. package/dist/collection/components/cpsl-tile-button/cpsl-tile-button.css +1 -3
  112. package/dist/collection/components/cpsl-tile-button/cpsl-tile-button.js +2 -2
  113. package/dist/collection/interface.js.map +1 -1
  114. package/dist/collection/utils/theme/generateBorderRadii.js +3 -4
  115. package/dist/collection/utils/theme/generateBorderRadii.js.map +1 -1
  116. package/dist/collection/utils/theme/generatePalette.js +6 -22
  117. package/dist/collection/utils/theme/generatePalette.js.map +1 -1
  118. package/dist/collection/utils/theme/generateTheme.js +3 -9
  119. package/dist/collection/utils/theme/generateTheme.js.map +1 -1
  120. package/dist/collection/utils/theme/utils.js.map +1 -1
  121. package/dist/esm/_commonjsHelpers-1789f0cf.js +9 -0
  122. package/dist/esm/_commonjsHelpers-1789f0cf.js.map +1 -0
  123. package/dist/esm/capsule.js +1 -1
  124. package/dist/esm/{cpsl-alert_34.entry.js → cpsl-alert_33.entry.js} +13370 -16936
  125. package/dist/esm/cpsl-alert_33.entry.js.map +1 -0
  126. package/dist/esm/cpsl-animation.entry.js +1 -2
  127. package/dist/esm/cpsl-animation.entry.js.map +1 -1
  128. package/dist/esm/cpsl-hero.entry.js +7 -10
  129. package/dist/esm/cpsl-hero.entry.js.map +1 -1
  130. package/dist/esm/cpsl-identicon.entry.js +1 -1
  131. package/dist/esm/cpsl-info-box.entry.js +2 -2
  132. package/dist/esm/cpsl-info-box.entry.js.map +1 -1
  133. package/dist/esm/cpsl-modal-v2.entry.js +1 -1
  134. package/dist/esm/cpsl-modal-v2.entry.js.map +1 -1
  135. package/dist/esm/cpsl-row.entry.js +1 -1
  136. package/dist/esm/index-91db3414.js +2 -2
  137. package/dist/esm/index.js +12 -35
  138. package/dist/esm/index.js.map +1 -1
  139. package/dist/esm/loader.js +1 -1
  140. package/dist/types/assets/icons/index.d.ts +0 -20
  141. package/dist/types/components/cpsl-button/cpsl-button.d.ts +2 -2
  142. package/dist/types/components/cpsl-hero/cpsl-hero.d.ts +3 -18
  143. package/dist/types/components/cpsl-input/cpsl-input.d.ts +3 -13
  144. package/dist/types/components/{cpsl-auth-modal/cpsl-auth-modal.d.ts → cpsl-modal/cpsl-modal.d.ts} +23 -3
  145. package/dist/types/components/cpsl-popover/cpsl-popover.d.ts +2 -2
  146. package/dist/types/components/cpsl-qr-code/cpsl-qr-code.d.ts +0 -1
  147. package/dist/types/components/cpsl-select/cpsl-select.d.ts +1 -22
  148. package/dist/types/components/cpsl-text/cpsl-text.d.ts +1 -1
  149. package/dist/types/components.d.ts +146 -222
  150. package/dist/types/interface.d.ts +0 -13
  151. package/dist/types/utils/theme/generateBorderRadii.d.ts +1 -1
  152. package/dist/types/utils/theme/generatePalette.d.ts +2 -4
  153. package/dist/types/utils/theme/generateTheme.d.ts +1 -1
  154. package/package.json +2 -3
  155. package/dist/capsule/p-0e558c7f.entry.js +0 -10
  156. package/dist/capsule/p-32cdf894.entry.js +0 -2
  157. package/dist/capsule/p-32cdf894.entry.js.map +0 -1
  158. package/dist/capsule/p-3b042fd1.entry.js +0 -2
  159. package/dist/capsule/p-5965b15e.entry.js +0 -2
  160. package/dist/capsule/p-60508b1e.entry.js +0 -20
  161. package/dist/capsule/p-60508b1e.entry.js.map +0 -1
  162. package/dist/cjs/cpsl-alert_34.cjs.entry.js.map +0 -1
  163. package/dist/collection/assets/icons/arrow-circle-broken-down-left.svg +0 -3
  164. package/dist/collection/assets/icons/bank.svg +0 -3
  165. package/dist/collection/assets/icons/credit-card.svg +0 -3
  166. package/dist/collection/assets/icons/dot.svg +0 -3
  167. package/dist/collection/assets/icons/download.svg +0 -3
  168. package/dist/collection/assets/icons/globe.svg +0 -3
  169. package/dist/collection/assets/icons/hero-alert-circle.svg +0 -3
  170. package/dist/collection/assets/icons/hero-checkmark-capsule.svg +0 -11
  171. package/dist/collection/assets/icons/hero-checkmark.svg +0 -3
  172. package/dist/collection/assets/icons/hero-external-connection.svg +0 -71
  173. package/dist/collection/assets/icons/link-external.svg +0 -3
  174. package/dist/collection/assets/icons/log-out.svg +0 -3
  175. package/dist/collection/assets/icons/moonpay-brand.svg +0 -10
  176. package/dist/collection/assets/icons/puzzle-piece.svg +0 -3
  177. package/dist/collection/assets/icons/qr-code-02.svg +0 -3
  178. package/dist/collection/assets/icons/qr-code.svg +0 -3
  179. package/dist/collection/assets/icons/search.svg +0 -3
  180. package/dist/collection/assets/icons/send.svg +0 -3
  181. package/dist/collection/assets/icons/shield.svg +0 -3
  182. package/dist/collection/assets/icons/stripe-brand.svg +0 -3
  183. package/dist/collection/components/cpsl-auth-modal/cpsl-auth-modal.js.map +0 -1
  184. package/dist/collection/components/cpsl-icon-group/cpsl-icon-group.css +0 -97
  185. package/dist/collection/components/cpsl-icon-group/cpsl-icon-group.js +0 -121
  186. package/dist/collection/components/cpsl-icon-group/cpsl-icon-group.js.map +0 -1
  187. package/dist/esm/cpsl-alert_34.entry.js.map +0 -1
  188. package/dist/types/components/cpsl-icon-group/cpsl-icon-group.d.ts +0 -20
  189. /package/dist/capsule/{p-3b042fd1.entry.js.map → p-0eea90f8.entry.js.map} +0 -0
  190. /package/dist/capsule/{p-5d62e610.entry.js.map → p-742bda0b.entry.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"cpsl-button.stories.js","sourceRoot":"","sources":["../../../../src/components/cpsl-button/cpsl-button.stories.ts"],"names":[],"mappings":"AAGA,MAAM,IAAI,GAA4C;IACpD,KAAK,EAAE,uBAAuB;IAC9B,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE;IAC7D,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;aACf;YACD,OAAO,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,CAAC;SAC1D;QACD,IAAI,EAAE;YACJ,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;aACf;YACD,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;SAC7B;KACF;CACF,CAAC;AAEF,eAAe,IAAI,CAAC;AA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BAAmB;CAC7B,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/html';\nimport { type CpslButton } from './cpsl-button';\n\nconst meta: Meta<CpslButton & { content?: string }> = {\n title: 'Components/CpslButton',\n args: { variant: 'primary', size: 'medium', content: 'Test' },\n argTypes: {\n variant: {\n control: {\n type: 'select',\n },\n options: ['primary', 'secondary', 'ghost', 'destructive'],\n },\n size: {\n control: {\n type: 'select',\n },\n options: ['small', 'medium'],\n },\n },\n};\n\nexport default meta;\n\ntype Story = StoryFn<CpslButton & { content?: string }>;\n\nconst Template: Story = args => `<cpsl-button variant=\"${args.variant}\" size=\"${args.size}\">${args.content}</cpsl-button>`;\nconst TemplateWithIcon: Story = args => `<cpsl-button variant=\"${args.variant}\" size=\"${args.size}\"><cpsl-icon icon=\"home\" slot=\"start\"></cpsl-icon>${args.content}</cpsl-button>`;\n\nexport const Primary: Story = Template.bind({});\nPrimary.args = {\n content: 'Primary',\n};\n\nexport const Secondary: Story = Template.bind({});\nSecondary.args = {\n content: 'Secondary',\n variant: 'secondary',\n};\n\nexport const Ghost: Story = Template.bind({});\nGhost.args = {\n content: 'Ghost',\n variant: 'ghost',\n};\n\nexport const Destructive: Story = Template.bind({});\nDestructive.args = {\n content: 'Destructive',\n variant: 'destructive',\n};\n\nexport const Icon: Story = TemplateWithIcon.bind({});\nIcon.args = {\n content: '',\n variant: 'ghost',\n};\n\nexport const PrimaryWithIcon: Story = TemplateWithIcon.bind({});\nPrimaryWithIcon.args = {\n content: 'Primary With Icon',\n};\n"]}
1
+ {"version":3,"file":"cpsl-button.stories.js","sourceRoot":"","sources":["../../../../src/components/cpsl-button/cpsl-button.stories.ts"],"names":[],"mappings":"AAGA,MAAM,IAAI,GAA4C;IACpD,KAAK,EAAE,uBAAuB;IAC9B,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE;IAC7D,QAAQ,EAAE;QACR,OAAO,EAAE;Y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CAAC,MAAM,IAAI,GAAU,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACrD,IAAI,CAAC,IAAI,GAAG;IACV,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,OAAO;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAU,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAChE,eAAe,CAAC,IAAI,GAAG;IACrB,OAAO,EAAE,mBAAmB;CAC7B,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/html';\nimport { type CpslButton } from './cpsl-button';\n\nconst meta: Meta<CpslButton & { content?: string }> = {\n title: 'Components/CpslButton',\n args: { variant: 'primary', size: 'medium', content: 'Test' },\n argTypes: {\n variant: {\n control: {\n type: 'select',\n },\n options: ['primary', 'secondary', 'ghost', 'destructive'],\n },\n size: {\n control: {\n type: 'select',\n },\n options: ['small', 'medium'],\n },\n },\n};\n\nexport default meta;\n\ntype Story = StoryFn<CpslButton & { content?: string }>;\n\nconst Template: Story = args => `<cpsl-button variant=\"${args.variant}\" size=\"${args.size}\">${args.content}</cpsl-button>`;\nconst TemplateWithIcon: Story = args =>\n `<cpsl-button variant=\"${args.variant}\" size=\"${args.size}\"><cpsl-icon icon=\"home\" slot=\"start\"></cpsl-icon>${args.content}</cpsl-button>`;\n\nexport const Primary: Story = Template.bind({});\nPrimary.args = {\n content: 'Primary',\n};\n\nexport const Secondary: Story = Template.bind({});\nSecondary.args = {\n content: 'Secondary',\n variant: 'secondary',\n};\n\nexport const Ghost: Story = Template.bind({});\nGhost.args = {\n content: 'Ghost',\n variant: 'ghost',\n};\n\nexport const Destructive: Story = Template.bind({});\nDestructive.args = {\n content: 'Destructive',\n variant: 'destructive',\n};\n\nexport const Icon: Story = TemplateWithIcon.bind({});\nIcon.args = {\n content: '',\n variant: 'ghost',\n};\n\nexport const PrimaryWithIcon: Story = TemplateWithIcon.bind({});\nPrimaryWithIcon.args = {\n content: 'Primary With Icon',\n};\n"]}
@@ -60,10 +60,7 @@
60
60
  --card-padding-start: 24px;
61
61
  --card-border-width: 1px;
62
62
  --card-border-color: var(--cpsl-color-card-border);
63
- --card-border-radius-tl: var(--cpsl-border-radius-card);
64
- --card-border-radius-tr: var(--cpsl-border-radius-card);
65
- --card-border-radius-bl: var(--cpsl-border-radius-card);
66
- --card-border-radius-br: var(--cpsl-border-radius-card);
63
+ --card-border-radius: var(--cpsl-border-radius-card);
67
64
  --card-background-color: var(--cpsl-color-card-surface);
68
65
  display: block;
69
66
  }
@@ -79,6 +76,6 @@
79
76
  box-sizing: border-box;
80
77
  overflow: hidden;
81
78
  border: var(--card-border-width) solid var(--card-border-color);
82
- border-radius: var(--card-border-radius-tl) var(--card-border-radius-tr) var(--card-border-radius-br) var(--card-border-radius-bl);
79
+ border-radius: var(--card-border-radius);
83
80
  background: var(--card-background-color);
84
81
  }
@@ -95,9 +95,6 @@
95
95
  text-align: center;
96
96
  outline: none;
97
97
  }
98
- .code-input.has-value {
99
- --input-border-color: var(--cpsl-color-accent-32);
100
- }
101
98
  .code-input:focus {
102
99
  --input-border-color: var(--cpsl-color-input-border-active);
103
100
  }
@@ -4,18 +4,13 @@ export class CpslCodeInput {
4
4
  this.handleInput = (ind, ev) => {
5
5
  var _a;
6
6
  const inputElements = this.inputs;
7
- // If getting an insertFromPaste remove the last element value since the value setting is handled in the paste event
8
- if (ev.inputType === 'insertFromPaste') {
9
- inputElements[Math.min(this.length - 1, ind)].value = '';
10
- return;
11
- }
12
7
  if (ev.inputType === 'insertText') {
13
8
  if (this.type === 'number' && isNaN(parseInt(ev.data))) {
14
9
  inputElements[ind].value = '';
15
10
  return;
16
11
  }
12
+ inputElements[Math.min(this.length - 1, ind + 1)].focus();
17
13
  const newCode = `${(_a = this.code) !== null && _a !== void 0 ? _a : ''}${ev.data}`;
18
- inputElements[Math.min(this.length - 1, newCode.length)].focus();
19
14
  this.cpslInput.emit({ value: newCode });
20
15
  this.code = newCode;
21
16
  }
@@ -64,6 +59,7 @@ export class CpslCodeInput {
64
59
  inputElements[ind].setSelectionRange(1, 1);
65
60
  }, 0);
66
61
  };
62
+ // TODO: figure out why pasting a string populates the first input
67
63
  this.handlePaste = (e) => {
68
64
  const inputElements = this.inputs;
69
65
  const pastedCode = e.clipboardData.getData('text');
@@ -80,7 +76,7 @@ export class CpslCodeInput {
80
76
  inputElements.forEach((input, index) => {
81
77
  input.value = pastedCode.charAt(index);
82
78
  });
83
- inputElements[Math.min(this.length - 1, pastedCode.length)].focus();
79
+ inputElements[this.length - 1].focus();
84
80
  };
85
81
  this.code = undefined;
86
82
  this.errorText = undefined;
@@ -93,10 +89,10 @@ export class CpslCodeInput {
93
89
  }
94
90
  render() {
95
91
  var _a;
96
- return (h(Host, { key: 'fd588544d9cdebaaeb1961f4ecb5c5630e8e4699' }, h("div", { key: 'b795c99f0df6fbf4ba9a7118f3f737dbf22c7ee9', class: "code-container" }, new Array(this.length).fill(0).map((_, i) => {
97
- var _a, _b;
98
- return (h("input", { class: { 'code-input': true, 'error': Boolean(this.errorText), 'has-value': ((_a = this.code) === null || _a === void 0 ? void 0 : _a[i]) !== undefined }, id: `code-input-${i}`, onKeyDown: ev => this.handleKeyDown(i, ev), onInput: ev => this.handleInput(i, ev), onFocus: () => this.handleFocus(i), onPaste: this.handlePaste, min: 0, max: 9, value: (_b = this.code) === null || _b === void 0 ? void 0 : _b[i], inputMode: this.type === 'number' ? 'numeric' : 'text' }));
99
- })), (this.errorText || this.helperText) && (h("div", { key: '9cff50eb172f38af5065ad79e3c767f2e8ec33c9', class: { 'helper-text-container': true, 'error-text': Boolean(this.errorText) } }, h("cpsl-icon", { key: 'c8d7dbbd0ec7a2015e2e8099d0448b847641b845', icon: this.errorText ? 'alertCircle' : 'infoCircle' }), h("span", { key: '4ae4009a2fb4d8f6dc4c985ea8d39c136cb23780' }, (_a = this.errorText) !== null && _a !== void 0 ? _a : this.helperText)))));
92
+ return (h(Host, { key: 'a75b04b3cf649df494520712a822f450e44f106f' }, h("div", { key: 'c38ae9fab904d38cd3a3154e2aa4bcdef1e1562b', class: "code-container" }, new Array(this.length).fill(0).map((_, i) => {
93
+ var _a;
94
+ return (h("input", { class: { 'code-input': true, 'error': Boolean(this.errorText) }, id: `code-input-${i}`, maxLength: 1, onKeyDown: ev => this.handleKeyDown(i, ev), onInput: ev => this.handleInput(i, ev), onFocus: () => this.handleFocus(i), onPaste: this.handlePaste, min: 0, max: 9, value: (_a = this.code) === null || _a === void 0 ? void 0 : _a[i], inputMode: this.type === 'number' ? 'numeric' : 'text' }));
95
+ })), (this.errorText || this.helperText) && (h("div", { key: '96041359166b5a633d4e4598d22523553592ed4e', class: { 'helper-text-container': true, 'error-text': Boolean(this.errorText) } }, h("cpsl-icon", { key: 'ea92b75ad3d82c4a3473b758f98f873fc1b84b4c', icon: this.errorText ? 'alertCircle' : 'infoCircle' }), h("span", { key: '09a2ae795033faab8bc187cbe5d3073aeae4b977' }, (_a = this.errorText) !== null && _a !== void 0 ? _a : this.helperText)))));
100
96
  }
101
97
  static get is() { return "cpsl-code-input"; }
102
98
  static get encapsulation() { return "shadow"; }
@@ -1 +1 @@
1
- {"version":3,"file":"cpsl-code-input.js","sourceRoot":"","sources":["../../../../src/components/cpsl-code-input/cpsl-code-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAQvF,MAAM,OAAO,aAAa;;QAmChB,gBAAW,GAAG,CAAC,GAAW,EAAE,EAAc,EAAE,EAAE;;YACpD,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;YAClC,oHAAoH;YACpH,IAAI,EAAE,CAAC,SAAS,KAAK,iBAAiB,EAAE,CAAC;gBACvC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,C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;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, Element, Event, EventEmitter } from '@stencil/core';\nimport { CodeChangeEventDetail } from './code-change-interface';\n\n@Component({\n tag: 'cpsl-code-input',\n styleUrl: 'cpsl-code-input.scss',\n shadow: true,\n})\nexport class CpslCodeInput {\n @Element() el!: HTMLCpslCodeInputElement;\n\n /**\n * Value of the code.\n */\n\n @Prop({ mutable: true }) code: string;\n\n /**\n * Error text to show below the input. If this is provided the input will enter an error state.\n */\n @Prop() errorText?: string;\n\n /**\n * Helper text to show below the input. If `\"errorText\"` is provided that will take precedence.\n */\n @Prop() helperText?: string;\n\n /**\n * Length of the code.\n */\n @Prop() length: number;\n\n /**\n * Type of characters to accept in the code.\n * Defaults to number.\n */\n @Prop() type?: 'number' | 'string' = 'number';\n\n /**\n * The `cpslInput` event is fired each time the user modifies the input's value.\n */\n @Event() cpslInput!: EventEmitter<CodeChangeEventDetail>;\n\n private handleInput = (ind: number, ev: InputEvent) => {\n const inputElements = this.inputs;\n // If getting an insertFromPaste remove the last element value since the value setting is handled in the paste event\n if (ev.inputType === 'insertFromPaste') {\n inputElements[Math.min(this.length - 1, ind)].value = '';\n return;\n }\n if (ev.inputType === 'insertText') {\n if (this.type === 'number' && isNaN(parseInt(ev.data))) {\n inputElements[ind].value = '';\n return;\n }\n const newCode = `${this.code ?? ''}${ev.data}`;\n inputElements[Math.min(this.length - 1, newCode.length)].focus();\n this.cpslInput.emit({ value: newCode });\n this.code = newCode;\n }\n };\n\n private handleKeyDown = (ind: number, ev: KeyboardEvent) => {\n const inputElements = this.inputs;\n\n switch (ev.key) {\n case 'Backspace': {\n let newCode;\n if (!inputElements[ind].value) {\n inputElements[Math.max(0, ind - 1)].value = '';\n inputElements[Math.max(0, ind - 1)].focus();\n newCode = this.code.substring(0, ind - 1);\n } else {\n newCode = this.code.substring(0, ind);\n }\n this.cpslInput.emit({ value: newCode });\n this.code = newCode;\n break;\n }\n case 'ArrowLeft': {\n setTimeout(() => {\n this.inputs[ind].setSelectionRange(1, 1);\n }, 0);\n break;\n }\n default: {\n break;\n }\n }\n };\n\n private handleFocus = (ind: number) => {\n const inputElements = this.inputs;\n\n for (const input of inputElements) {\n if (!input.value) {\n input.focus();\n break;\n } else if (input.id === `code-input-${this.length - 1}`) {\n input.focus();\n break;\n }\n }\n\n setTimeout(() => {\n inputElements[ind].setSelectionRange(1, 1);\n }, 0);\n };\n\n private handlePaste = (e: ClipboardEvent) => {\n const inputElements = this.inputs;\n const pastedCode = e.clipboardData.getData('text');\n\n if (this.type === 'number' && isNaN(parseInt(pastedCode))) {\n // Remove illegal value from the first input. Not using a timeout here doesn't change the value properly.\n setTimeout(() => {\n inputElements[0].value = '';\n }, 0);\n return;\n }\n\n this.cpslInput.emit({\n value: pastedCode,\n });\n inputElements.forEach((input, index) => {\n input.value = pastedCode.charAt(index);\n });\n inputElements[Math.min(this.length - 1, pastedCode.length)].focus();\n };\n\n private get inputs() {\n return Array.from(this.el.shadowRoot.querySelectorAll('input'));\n }\n\n render() {\n return (\n <Host>\n <div class=\"code-container\">\n {new Array(this.length).fill(0).map((_, i) => (\n <input\n class={{ 'code-input': true, 'error': Boolean(this.errorText), 'has-value': this.code?.[i] !== undefined }}\n id={`code-input-${i}`}\n onKeyDown={ev => this.handleKeyDown(i, ev)}\n onInput={ev => this.handleInput(i, ev)}\n onFocus={() => this.handleFocus(i)}\n onPaste={this.handlePaste}\n min={0}\n max={9}\n value={this.code?.[i]}\n inputMode={this.type === 'number' ? 'numeric' : 'text'}\n />\n ))}\n </div>\n {(this.errorText || this.helperText) && (\n <div class={{ 'helper-text-container': true, 'error-text': Boolean(this.errorText) }}>\n <cpsl-icon icon={this.errorText ? 'alertCircle' : 'infoCircle'} />\n <span>{this.errorText ?? this.helperText}</span>\n </div>\n )}\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"cpsl-code-input.js","sourceRoot":"","sources":["../../../../src/components/cpsl-code-input/cpsl-code-input.ts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I,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, Element, Event, EventEmitter } from '@stencil/core';\nimport { CodeChangeEventDetail } from './code-change-interface';\n\n@Component({\n tag: 'cpsl-code-input',\n styleUrl: 'cpsl-code-input.scss',\n shadow: true,\n})\nexport class CpslCodeInput {\n @Element() el!: HTMLCpslCodeInputElement;\n\n /**\n * Value of the code.\n */\n @Prop({ mutable: true }) code: string;\n\n /**\n * Error text to show below the input. If this is provided the input will enter an error state.\n */\n @Prop() errorText?: string;\n\n /**\n * Helper text to show below the input. If `\"errorText\"` is provided that will take precedence.\n */\n @Prop() helperText?: string;\n\n /**\n * Length of the code.\n */\n @Prop() length: number;\n\n /**\n * Type of characters to accept in the code.\n * Defaults to number.\n */\n @Prop() type?: 'number' | 'string' = 'number';\n\n /**\n * The `cpslInput` event is fired each time the user modifies the input's value.\n */\n @Event() cpslInput!: EventEmitter<CodeChangeEventDetail>;\n\n private handleInput = (ind: number, ev: InputEvent) => {\n const inputElements = this.inputs;\n if (ev.inputType === 'insertText') {\n if (this.type === 'number' && isNaN(parseInt(ev.data))) {\n inputElements[ind].value = '';\n return;\n }\n inputElements[Math.min(this.length - 1, ind + 1)].focus();\n\n const newCode = `${this.code ?? ''}${ev.data}`;\n this.cpslInput.emit({ value: newCode });\n this.code = newCode;\n }\n };\n\n private handleKeyDown = (ind: number, ev: KeyboardEvent) => {\n const inputElements = this.inputs;\n\n switch (ev.key) {\n case 'Backspace': {\n let newCode;\n if (!inputElements[ind].value) {\n inputElements[Math.max(0, ind - 1)].value = '';\n inputElements[Math.max(0, ind - 1)].focus();\n newCode = this.code.substring(0, ind - 1);\n } else {\n newCode = this.code.substring(0, ind);\n }\n this.cpslInput.emit({ value: newCode });\n this.code = newCode;\n break;\n }\n case 'ArrowLeft': {\n setTimeout(() => {\n this.inputs[ind].setSelectionRange(1, 1);\n }, 0);\n break;\n }\n default: {\n break;\n }\n }\n };\n\n private handleFocus = (ind: number) => {\n const inputElements = this.inputs;\n\n for (const input of inputElements) {\n if (!input.value) {\n input.focus();\n break;\n } else if (input.id === `code-input-${this.length - 1}`) {\n input.focus();\n break;\n }\n }\n\n setTimeout(() => {\n inputElements[ind].setSelectionRange(1, 1);\n }, 0);\n };\n\n // TODO: figure out why pasting a string populates the first input\n private handlePaste = (e: ClipboardEvent) => {\n const inputElements = this.inputs;\n const pastedCode = e.clipboardData.getData('text');\n\n if (this.type === 'number' && isNaN(parseInt(pastedCode))) {\n // Remove illegal value from the first input. Not using a timeout here doesn't change the value properly.\n setTimeout(() => {\n inputElements[0].value = '';\n }, 0);\n return;\n }\n\n this.cpslInput.emit({\n value: pastedCode,\n });\n inputElements.forEach((input, index) => {\n input.value = pastedCode.charAt(index);\n });\n inputElements[this.length - 1].focus();\n };\n\n private get inputs() {\n return Array.from(this.el.shadowRoot.querySelectorAll('input'));\n }\n\n render() {\n return (\n <Host>\n <div class=\"code-container\">\n {new Array(this.length).fill(0).map((_, i) => (\n <input\n class={{ 'code-input': true, 'error': Boolean(this.errorText) }}\n id={`code-input-${i}`}\n maxLength={1}\n onKeyDown={ev => this.handleKeyDown(i, ev)}\n onInput={ev => this.handleInput(i, ev)}\n onFocus={() => this.handleFocus(i)}\n onPaste={this.handlePaste}\n min={0}\n max={9}\n value={this.code?.[i]}\n inputMode={this.type === 'number' ? 'numeric' : 'text'}\n />\n ))}\n </div>\n {(this.errorText || this.helperText) && (\n <div class={{ 'helper-text-container': true, 'error-text': Boolean(this.errorText) }}>\n <cpsl-icon icon={this.errorText ? 'alertCircle' : 'infoCircle'} />\n <span>{this.errorText ?? this.helperText}</span>\n </div>\n )}\n </Host>\n );\n }\n}\n"]}
@@ -59,11 +59,10 @@
59
59
  display: flex;
60
60
  align-items: center;
61
61
  height: 24px;
62
- width: 100%;
63
62
  color: var(--cpsl-color-text-subtle);
64
63
  font-family: var(--cpsl-font-family, inherit);
65
64
  font-size: clamp(14px, 0.875rem, 21px);
66
- font-weight: 500;
65
+ font-weight: 600;
67
66
  gap: 16px;
68
67
  }
69
68
 
@@ -38,7 +38,7 @@ export class CpslDrawer {
38
38
  bottom: this.anchor === 'bottom',
39
39
  left: this.anchor === 'left',
40
40
  right: this.anchor === 'right',
41
- } }, this.variant === 'temporary' && !this.noOverlay && h("cpsl-overlay", { key: '21fdc68cd01c652b7a9f8e1d624027f4051fdb47', open: this.open, zIndexOverride: DEFAULT_Z_INDICES.modal + 1 }), h("div", { key: '085ba3bf2b57ceeb5615c42816e7a0f8758eeeb0', id: "container", class: "container", part: "container" }, h("slot", { key: 'bd8517779864cf35bc30b33597b27a43c749ba1f' }))));
41
+ } }, this.variant === 'temporary' && !this.noOverlay && (h("cpsl-overlay", { key: '96f094c52ac1dc963494319933e3b59f798a6542', open: this.open, zIndexOverride: DEFAULT_Z_INDICES.modal + 1 })), h("div", { key: '1c201b7a8ba0a86e56b8c8aad35b2028574c9671', id: "container", class: "container", part: "container" }, h("slot", { key: 'e4e6b5b4f761a05d0e4dbe38fa12657e5c44ceca' }))));
42
42
  }
43
43
  static get is() { return "cpsl-drawer"; }
44
44
  static get encapsulation() { return "shadow"; }
@@ -1 +1 @@
1
- {"version":3,"file":"cpsl-drawer.js","sourceRoot":"","sources":["../../../../src/components/cpsl-drawer/cpsl-drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAOpD,MAAM,OAAO,UAAU;;;;;;;;;kCAmCiB,IAAI;kCAMJ,aAAa;uBAOL,WAAW;;;IAOzD,gBAAgB;QACd,IAAI,CAAC,oBAAoB,GAA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AAC,oBAAoB,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IACzD,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAEtE,KAAK,EAAE;gBACL,GAAG,EAAE,IAAI,CAAC,MAAM,KAAK,KAAK;gBAC1B,MAAM,EAAE,IAAI,CAAC,MAAM,KAAK,QAAQ;gBAChC,IAAI,EAAE,IAAI,CAAC,MAAM,KAAK,MAAM;gBAC5B,KAAK,EAAE,IAAI,CAAC,MAAM,KAAK,OAAO;aAC/B;YAEA,IAAI,CAAC,OAAO,KAAK,WAAW,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,qEAAc,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,iBAAiB,CAAC,KAAK,GAAG,CAAC,GAAI;YAClI,4DAAK,EAAE,EAAC,WAAW,EAAC,KAAK,EAAC,WAAW,EAAC,IAAI,EAAC,WAAW;gBACpD,8DAAa,CACT,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, Prop, Element, h, State } from '@stencil/core';\nimport { DEFAULT_Z_INDICES } from '../../constants';\n\n@Component({\n tag: 'cpsl-drawer',\n styleUrl: 'cpsl-drawer.scss',\n shadow: true,\n})\nexport class CpslDrawer {\n @Element() el!: HTMLCpslDrawerElement;\n\n @State() closedAnchorPosition?: string;\n @State() showTransition: boolean;\n\n /**\n * Side from which the drawer will enter from.\n */\n @Prop() anchor: 'top' | 'bottom' | 'left' | 'right';\n\n /**\n * Starting anchor position.\n */\n @Prop() anchorPosition?: number;\n\n /**\n * Hides the overlay for temporary drawers.\n */\n @Prop() noOverlay?: boolean;\n\n /**\n * Whether the drawer is open or not.\n */\n @Prop() open: boolean;\n\n /**\n * Size (height or width) of the drawer.\n */\n @Prop() size: number | 'auto';\n\n /**\n * Duration in seconds of the open/close animation.\n * Default is 0.15.\n */\n @Prop() transitionDuration?: number = 0.15;\n\n /**\n * Transition timing function to use.\n * Default is ease-in-out.\n */\n @Prop() transitionFunction?: string = 'ease-in-out';\n\n /**\n * The variant of the drawer.\n * `temporary` drawers will cover content and contain a backdrop. `permanent` drawers will sit beside content, i.e. desktop navigation.\n * Default is `temporary`.\n */\n @Prop() variant?: 'temporary' | 'permanent' = 'temporary';\n\n /**\n * Override z-index.\n */\n @Prop() zIndexOverride?: number;\n\n componentDidLoad() {\n this.closedAnchorPosition = `-${this.getContainerHeight()}px`;\n // Show transition after initial render\n setTimeout(() => {\n this.showTransition = true;\n }, 100);\n }\n\n private getContainerHeight() {\n return this.containerEl?.clientHeight;\n }\n\n private get containerEl() {\n return this.el.shadowRoot.getElementById('container');\n }\n\n render() {\n const setHeight = this.anchor === 'top' || this.anchor === 'bottom';\n const startingAnchor = `${this.anchorPosition}px` ?? '0px';\n const size = this.size === 'auto' ? 'auto' : `${this.size}px`;\n\n return (\n <Host\n style={{\n width: setHeight ? '100vw' : size,\n height: setHeight ? size : '100vh',\n transitionDuration: `${this.showTransition ? this.transitionDuration : 0}s`,\n transitionTimingFunction: `${this.transitionFunction}`,\n [this.anchor]: this.open || this.variant === 'permanent' ? startingAnchor : this.closedAnchorPosition,\n opacity: this.closedAnchorPosition === undefined ? '0' : '1',\n ...(this.zIndexOverride ? { zIndex: `${this.zIndexOverride}` } : {}),\n }}\n class={{\n top: this.anchor === 'top',\n bottom: this.anchor === 'bottom',\n left: this.anchor === 'left',\n right: this.anchor === 'right',\n }}\n >\n {this.variant === 'temporary' && !this.noOverlay && <cpsl-overlay open={this.open} zIndexOverride={DEFAULT_Z_INDICES.modal + 1} />}\n <div id=\"container\" class=\"container\" part=\"container\">\n <slot></slot>\n </div>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"cpsl-drawer.js","sourceRoot":"","sources":["../../../../src/components/cpsl-drawer/cpsl-drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAOpD,MAAM,OAAO,UAAU;;;;;;;;;kCAmCiB,IAAI;kCAMJ,aAAa;uBAOL,WAAW;;;IAOzD,gBAAgB;QACd,IAAI,CAAC,oBAAoB,GAAG,IAAI,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC;QAC9D,uCAAuC;QACvC,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC7B,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC;IAEO,kBAAkB;;QACxB,OAAO,MAAA,IAAI,CAAC,WAAW,0CAAE,YAAY,CAAC;IACxC,CAAC;IAED,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IACxD,CAAC;IAED,MAAM;;QACJ,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC;QACpE,MAAM,cAAc,GAAG,MAAA,GAAG,IAAI,CAAC,cAAc,IAAI,mCAAI,KAAK,CAAC;QAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC;QAE9D,OAAO,CACL,EAAC,IAAI,qDACH,KAAK,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, Prop, Element, h, State } from '@stencil/core';\nimport { DEFAULT_Z_INDICES } from '../../constants';\n\n@Component({\n tag: 'cpsl-drawer',\n styleUrl: 'cpsl-drawer.scss',\n shadow: true,\n})\nexport class CpslDrawer {\n @Element() el!: HTMLCpslDrawerElement;\n\n @State() closedAnchorPosition?: string;\n @State() showTransition: boolean;\n\n /**\n * Side from which the drawer will enter from.\n */\n @Prop() anchor: 'top' | 'bottom' | 'left' | 'right';\n\n /**\n * Starting anchor position.\n */\n @Prop() anchorPosition?: number;\n\n /**\n * Hides the overlay for temporary drawers.\n */\n @Prop() noOverlay?: boolean;\n\n /**\n * Whether the drawer is open or not.\n */\n @Prop() open: boolean;\n\n /**\n * Size (height or width) of the drawer.\n */\n @Prop() size: number | 'auto';\n\n /**\n * Duration in seconds of the open/close animation.\n * Default is 0.15.\n */\n @Prop() transitionDuration?: number = 0.15;\n\n /**\n * Transition timing function to use.\n * Default is ease-in-out.\n */\n @Prop() transitionFunction?: string = 'ease-in-out';\n\n /**\n * The variant of the drawer.\n * `temporary` drawers will cover content and contain a backdrop. `permanent` drawers will sit beside content, i.e. desktop navigation.\n * Default is `temporary`.\n */\n @Prop() variant?: 'temporary' | 'permanent' = 'temporary';\n\n /**\n * Override z-index.\n */\n @Prop() zIndexOverride?: number;\n\n componentDidLoad() {\n this.closedAnchorPosition = `-${this.getContainerHeight()}px`;\n // Show transition after initial render\n setTimeout(() => {\n this.showTransition = true;\n }, 100);\n }\n\n private getContainerHeight() {\n return this.containerEl?.clientHeight;\n }\n\n private get containerEl() {\n return this.el.shadowRoot.getElementById('container');\n }\n\n render() {\n const setHeight = this.anchor === 'top' || this.anchor === 'bottom';\n const startingAnchor = `${this.anchorPosition}px` ?? '0px';\n const size = this.size === 'auto' ? 'auto' : `${this.size}px`;\n\n return (\n <Host\n style={{\n width: setHeight ? '100vw' : size,\n height: setHeight ? size : '100vh',\n transitionDuration: `${this.showTransition ? this.transitionDuration : 0}s`,\n transitionTimingFunction: `${this.transitionFunction}`,\n [this.anchor]: this.open || this.variant === 'permanent' ? startingAnchor : this.closedAnchorPosition,\n opacity: this.closedAnchorPosition === undefined ? '0' : '1',\n ...(this.zIndexOverride ? { zIndex: `${this.zIndexOverride}` } : {}),\n }}\n class={{\n top: this.anchor === 'top',\n bottom: this.anchor === 'bottom',\n left: this.anchor === 'left',\n right: this.anchor === 'right',\n }}\n >\n {this.variant === 'temporary' && !this.noOverlay && (\n <cpsl-overlay open={this.open} zIndexOverride={DEFAULT_Z_INDICES.modal + 1} />\n )}\n <div id=\"container\" class=\"container\" part=\"container\">\n <slot></slot>\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { Host, h } from "@stencil/core";
1
+ import { Host, h, } from "@stencil/core";
2
2
  import { Icons } from "../../assets/icons";
3
3
  export class CpslDropdown {
4
4
  constructor() {
@@ -94,7 +94,7 @@ export class CpslDropdown {
94
94
  }
95
95
  render() {
96
96
  var _a, _b, _c;
97
- return (h(Host, { key: 'a997453b8690196f125bcf96fd94d728e645cd9e' }, h("button", { key: '0be8f5b0b6fcb3a27a5885205c0f585a68dc1bb9', class: "dropdown-button", onClick: this.toggleDropdown }, `${((_a = this.selectedItem) === null || _a === void 0 ? void 0 : _a.selectedLabel) || ((_b = this.selectedItem) === null || _b === void 0 ? void 0 : _b.label)} ${(_c = this.selectedItem) === null || _c === void 0 ? void 0 : _c.value}`, h("div", { key: 'f324edfdd97304de361a0ccd2bec793af25d3aa3', class: `chevron ${this.isOpen ? '' : 'closed'}`, innerHTML: Icons['chevronUp'] })), h("ul", { key: 'e1a3a097abb0633bd33caefabce016e2308f1ac0', class: { 'dropdown-options': true, 'open': this.isOpen }, style: { width: this.width } }, this.hasCpslSearch && (h("li", { key: '517c74f9f94df623206d8969a32d894b854f95a4', class: "search-bar" }, h("input", { key: '28ed686f30069ecb92dd0ee1852a9b9f94a98264', type: "text", placeholder: "Search...", value: this.searchQuery, onInput: this.handleSearchQueryChange }))), this.filteredItems.map(item => (h("li", { onClick: this.handleItemSelect(item) }, h("span", { innerHTML: Icons[item.icon] }), item.label, " ", h("span", { class: "dropdown-value" }, item.value)))))));
97
+ return (h(Host, { key: 'a34526653b775141129622b3b2c4f394fe2cd7a3' }, h("button", { key: '5925ed5bfddd0f956cd5f834dc18c4f7434c9cc2', class: "dropdown-button", onClick: this.toggleDropdown }, `${((_a = this.selectedItem) === null || _a === void 0 ? void 0 : _a.selectedLabel) || ((_b = this.selectedItem) === null || _b === void 0 ? void 0 : _b.label)} ${(_c = this.selectedItem) === null || _c === void 0 ? void 0 : _c.value}`, h("div", { key: '74bb9192ad7740af23db871d80492796a4158eee', class: `chevron ${this.isOpen ? '' : 'closed'}`, innerHTML: Icons['chevronUp'] })), h("ul", { key: '981160bd591ee5a41a1e94ad0d4c9ae705381468', class: { 'dropdown-options': true, 'open': this.isOpen }, style: { width: this.width } }, this.hasCpslSearch && (h("li", { key: 'a15daf3ad8ba55d81020c3b07b4c5dedc6119ca7', class: "search-bar" }, h("input", { key: 'fa9e3a1a9bb404de23474a641949c06e8cc11b50', type: "text", placeholder: "Search...", value: this.searchQuery, onInput: this.handleSearchQueryChange }))), this.filteredItems.map(item => (h("li", { onClick: this.handleItemSelect(item) }, h("span", { innerHTML: Icons[item.icon] }), item.label, " ", h("span", { class: "dropdown-value" }, item.value)))))));
98
98
  }
99
99
  static get is() { return "cpsl-dropdown"; }
100
100
  static get encapsulation() { return "shadow"; }
@@ -1 +1 @@
1
- {"version":3,"file":"cpsl-dropdown.js","sourceRoot":"","sources":["../../../../src/components/cpsl-dropdown/cpsl-dropdown.tsx"],"names":[],"mappings":"A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;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element, ComponentInterface, Watch, Listen, EventEmitter, Event } from '@stencil/core';\nimport { Icons } from '../../assets/icons';\nimport { DropdownInputEventDetail } from './dropdown-interface';\n\n@Component({\n tag: 'cpsl-dropdown',\n styleUrl: 'cpsl-dropdown.scss',\n shadow: true,\n})\nexport class CpslDropdown implements ComponentInterface {\n @Element() el: HTMLCpslDropdownElement;\n\n /**\n * Width of the dropdown\n */\n @Prop() width: string = '100%';\n\n /**\n * Whether or not to include search capability\n */\n @Prop() hasCpslSearch: boolean = false;\n\n @State() isOpen: boolean = false;\n @State() searchQuery: string = '';\n @State() filteredItems: Array<DropdownInputEventDetail> = [];\n\n /**\n * Items to be presented in the dropdown\n */\n @Prop() items: Array<DropdownInputEventDetail> = [];\n\n /**\n * The selected item in the dropdown\n */\n @Prop({ mutable: true }) selectedItem?: DropdownInputEventDetail | null = null;\n\n /**\n * Event emitted when the selected item changes\n */\n @Event() selectedItemChange!: EventEmitter<DropdownInputEventDetail>;\n\n @Watch('selectedItem')\n handleSelectedItemChange(newValue: DropdownInputEventDetail | null) {\n if (newValue !== null) {\n this.selectItem(newValue, false);\n }\n }\n\n private toggleDropdown = () => {\n this.isOpen = !this.isOpen;\n };\n\n private selectItem = (item: DropdownInputEventDetail, emitEvent: boolean = true) => {\n this.selectedItem = item;\n this.isOpen = false;\n if (emitEvent) {\n this.selectedItemChange.emit(this.selectedItem);\n }\n };\n\n private handleItemSelect = (item: DropdownInputEventDetail) => () => {\n this.selectItem(item);\n };\n\n private handleSearchQueryChange = (event: InputEvent) => {\n const target = event.target as HTMLInputElement;\n this.searchQuery = target.value;\n this.filteredItems = this.items.filter(item => item.label.toLowerCase().includes(this.searchQuery.toLowerCase()));\n };\n\n @Watch('isOpen')\n handleOpenChange() {\n if (this.isOpen) {\n this.adjustPosition();\n this.addClickOutsideListener();\n } else {\n this.removeClickOutsideListener();\n }\n }\n\n @Listen('resize', { target: 'window' })\n handleResize() {\n if (this.isOpen) {\n this.adjustPosition();\n }\n }\n\n private adjustPosition() {\n const dropdownOptions = this.el.shadowRoot.querySelector('.dropdown-options') as HTMLElement;\n const parentRect = this.el.parentElement?.getBoundingClientRect();\n const searchBar = this.el.shadowRoot.querySelector('.search-bar') as HTMLElement;\n const viewportHeight = window.innerHeight;\n\n if (parentRect) {\n this.width = `${parentRect.width}px`;\n dropdownOptions.style.left = `${parentRect.x}px`;\n if (window.innerWidth <= 480) {\n searchBar.style.maxHeight = `30px`;\n dropdownOptions.style.top = `425px`;\n dropdownOptions.style.maxHeight = '110px';\n return;\n }\n dropdownOptions.style.top = `${parentRect.y + parentRect.height}px`;\n\n const availableHeight = viewportHeight - parentRect.bottom;\n dropdownOptions.style.maxHeight = `${availableHeight - 8}px`;\n }\n }\n\n private addClickOutsideListener() {\n window.addEventListener('click', this.handleClickOutside);\n }\n\n private removeClickOutsideListener() {\n window.removeEventListener('click', this.handleClickOutside);\n }\n\n private handleClickOutside = (event: MouseEvent) => {\n if (this.isOpen && !this.el.contains(event.target as Node)) {\n this.isOpen = false;\n }\n };\n\n componentWillLoad() {\n if (this.items.length > 0) {\n this.filteredItems = [...this.items];\n if (this.selectedItem !== null) {\n this.selectItem(this.selectedItem, false);\n } else {\n this.selectedItem = this.items[0];\n }\n }\n }\n\n disconnectedCallback() {\n this.removeClickOutsideListener();\n }\n\n render() {\n return (\n <Host>\n <button class=\"dropdown-button\" onClick={this.toggleDropdown}>\n {`${this.selectedItem?.selectedLabel || this.selectedItem?.label} ${this.selectedItem?.value}`}\n <div class={`chevron ${this.isOpen ? '' : 'closed'}`} innerHTML={Icons['chevronUp']} />\n </button>\n <ul class={{ 'dropdown-options': true, 'open': this.isOpen }} style={{ width: this.width }}>\n {this.hasCpslSearch && (\n <li class=\"search-bar\">\n <input type=\"text\" placeholder=\"Search...\" value={this.searchQuery} onInput={this.handleSearchQueryChange} />\n </li>\n )}\n {this.filteredItems.map(item => (\n <li onClick={this.handleItemSelect(item)}>\n <span innerHTML={Icons[item.icon]}></span>\n {item.label} <span class=\"dropdown-value\">{item.value}</span>\n </li>\n ))}\n </ul>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"cpsl-dropdown.js","sourceRoot":"","sources":["../../../../src/components/cpsl-dropdown/cpsl-dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,IAAI,EACJ,CAAC,EACD,IAAI,EACJ,KAAK,EACL,OAAO,EAEP,KAAK,EACL,MAAM,EAEN,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAQ3C,MAAM,OAAO,YAAY;;QAuCf,mBAAc,GAAG,GAAG,EAAE;YAC5B,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;QAC7B,CAAC,CAAC;QAEM,eAAU,GAAG,CAAC,IAA8B,EAAE,YAAqB,IAAI,EAAE,EAAE;YACjF,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YACpB,IAAI,SAAS,EAAE,CAAC;gBACd,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAClD,CAAC;QACH,CAAC,CAAC;QAEM,qBAAgB,GAAG,CAAC,IAA8B,EAAE,EAAE,CAAC,GAAG,EAAE;YAClE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC;QAEM,4BAAuB,GAAG,CAAC,KAAiB,EAAE,EAAE;YACtD,MAAM,MAAM,GAAG,KAAK,CAAC,MAA0B,CAAC;YAChD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC;YAChC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,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N,CAAC,CACC,CACA,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Host,\n h,\n Prop,\n State,\n Element,\n ComponentInterface,\n Watch,\n Listen,\n EventEmitter,\n Event,\n} from '@stencil/core';\nimport { Icons } from '../../assets/icons';\nimport { DropdownInputEventDetail } from './dropdown-interface';\n\n@Component({\n tag: 'cpsl-dropdown',\n styleUrl: 'cpsl-dropdown.scss',\n shadow: true,\n})\nexport class CpslDropdown implements ComponentInterface {\n @Element() el: HTMLCpslDropdownElement;\n\n /**\n * Width of the dropdown\n */\n @Prop() width: string = '100%';\n\n /**\n * Whether or not to include search capability\n */\n @Prop() hasCpslSearch: boolean = false;\n\n @State() isOpen: boolean = false;\n @State() searchQuery: string = '';\n @State() filteredItems: Array<DropdownInputEventDetail> = [];\n\n /**\n * Items to be presented in the dropdown\n */\n @Prop() items: Array<DropdownInputEventDetail> = [];\n\n /**\n * The selected item in the dropdown\n */\n @Prop({ mutable: true }) selectedItem?: DropdownInputEventDetail | null = null;\n\n /**\n * Event emitted when the selected item changes\n */\n @Event() selectedItemChange!: EventEmitter<DropdownInputEventDetail>;\n\n @Watch('selectedItem')\n handleSelectedItemChange(newValue: DropdownInputEventDetail | null) {\n if (newValue !== null) {\n this.selectItem(newValue, false);\n }\n }\n\n private toggleDropdown = () => {\n this.isOpen = !this.isOpen;\n };\n\n private selectItem = (item: DropdownInputEventDetail, emitEvent: boolean = true) => {\n this.selectedItem = item;\n this.isOpen = false;\n if (emitEvent) {\n this.selectedItemChange.emit(this.selectedItem);\n }\n };\n\n private handleItemSelect = (item: DropdownInputEventDetail) => () => {\n this.selectItem(item);\n };\n\n private handleSearchQueryChange = (event: InputEvent) => {\n const target = event.target as HTMLInputElement;\n this.searchQuery = target.value;\n this.filteredItems = this.items.filter(item => item.label.toLowerCase().includes(this.searchQuery.toLowerCase()));\n };\n\n @Watch('isOpen')\n handleOpenChange() {\n if (this.isOpen) {\n this.adjustPosition();\n this.addClickOutsideListener();\n } else {\n this.removeClickOutsideListener();\n }\n }\n\n @Listen('resize', { target: 'window' })\n handleResize() {\n if (this.isOpen) {\n this.adjustPosition();\n }\n }\n\n private adjustPosition() {\n const dropdownOptions = this.el.shadowRoot.querySelector('.dropdown-options') as HTMLElement;\n const parentRect = this.el.parentElement?.getBoundingClientRect();\n const searchBar = this.el.shadowRoot.querySelector('.search-bar') as HTMLElement;\n const viewportHeight = window.innerHeight;\n\n if (parentRect) {\n this.width = `${parentRect.width}px`;\n dropdownOptions.style.left = `${parentRect.x}px`;\n if (window.innerWidth <= 480) {\n searchBar.style.maxHeight = `30px`;\n dropdownOptions.style.top = `425px`;\n dropdownOptions.style.maxHeight = '110px';\n return;\n }\n dropdownOptions.style.top = `${parentRect.y + parentRect.height}px`;\n\n const availableHeight = viewportHeight - parentRect.bottom;\n dropdownOptions.style.maxHeight = `${availableHeight - 8}px`;\n }\n }\n\n private addClickOutsideListener() {\n window.addEventListener('click', this.handleClickOutside);\n }\n\n private removeClickOutsideListener() {\n window.removeEventListener('click', this.handleClickOutside);\n }\n\n private handleClickOutside = (event: MouseEvent) => {\n if (this.isOpen && !this.el.contains(event.target as Node)) {\n this.isOpen = false;\n }\n };\n\n componentWillLoad() {\n if (this.items.length > 0) {\n this.filteredItems = [...this.items];\n if (this.selectedItem !== null) {\n this.selectItem(this.selectedItem, false);\n } else {\n this.selectedItem = this.items[0];\n }\n }\n }\n\n disconnectedCallback() {\n this.removeClickOutsideListener();\n }\n\n render() {\n return (\n <Host>\n <button class=\"dropdown-button\" onClick={this.toggleDropdown}>\n {`${this.selectedItem?.selectedLabel || this.selectedItem?.label} ${this.selectedItem?.value}`}\n <div class={`chevron ${this.isOpen ? '' : 'closed'}`} innerHTML={Icons['chevronUp']} />\n </button>\n <ul class={{ 'dropdown-options': true, 'open': this.isOpen }} style={{ width: this.width }}>\n {this.hasCpslSearch && (\n <li class=\"search-bar\">\n <input type=\"text\" placeholder=\"Search...\" value={this.searchQuery} onInput={this.handleSearchQueryChange} />\n </li>\n )}\n {this.filteredItems.map(item => (\n <li onClick={this.handleItemSelect(item)}>\n <span innerHTML={Icons[item.icon]}></span>\n {item.label} <span class=\"dropdown-value\">{item.value}</span>\n </li>\n ))}\n </ul>\n </Host>\n );\n }\n}\n"]}
@@ -115,7 +115,12 @@ export class CpslFileUpload {
115
115
  }
116
116
  render() {
117
117
  var _a, _b, _c;
118
- return (h(Host, { key: '7d86bbac92b88c5e0b4a7c79cde8b2669f3801c2' }, this.label && (h("label", { key: 'eb364a27a57b278c5f6a75b793369e07ced1ea2c', class: "label", htmlFor: this.inputId }, this.label, this.required ? '*' : ' ', !this.required && this.showOptionalLabel ? h("span", { class: "optional-label" }, "(optional)") : '')), h("slot", { key: 'e40411eb484d37dcc9980aaab3a1f69aaf954cc0', name: "label" }), h("div", { key: 'd6da41895c97f0b9a1bcac7c6bc8b3c645558204', class: { 'container': true, 'error': Boolean(this.errorText), 'drag': this.dragOver, 'drag-error': this.dragError } }, h("div", { key: '6eb03384b7ac287459afc20abee8a616c99981ce', class: { 'label-container': true } }, h("slot", { key: '7e4c43bddd220698c73670c8f2da7b600e404686', name: "left-content" })), h("div", { key: '66dc0aa70f8eb04e33e5bd9f7bf32bf60ef2188b', class: { 'file-container': true } }, this.FileContent), h("input", { key: '850e65539600a22b474304524f83d3b14be5d3dd', id: this.inputId, type: "file", accept: (_b = (_a = this.fileTypes) === null || _a === void 0 ? void 0 : _a.join(', ')) !== null && _b !== void 0 ? _b : '*', files: this.file ? [this.file] : undefined, onDrop: this.handleDrop, onDragEnter: this.handleDragEnter, onDragLeave: this.handleDragLeave, onChange: this.handleInputChange })), (this.errorText || this.helperText) && (h("div", { key: '23a46735f7578cf98c4940881032ace297c59584', class: { 'helper-text-container': true, 'error-text': Boolean(this.errorText) } }, h("span", { key: '135a2875a88051bccf79fd41c8424c58611fbb6a' }, (_c = this.errorText) !== null && _c !== void 0 ? _c : this.helperText)))));
118
+ return (h(Host, { key: '7d86bbac92b88c5e0b4a7c79cde8b2669f3801c2' }, this.label && (h("label", { key: 'eb364a27a57b278c5f6a75b793369e07ced1ea2c', class: "label", htmlFor: this.inputId }, this.label, this.required ? '*' : ' ', !this.required && this.showOptionalLabel ? h("span", { class: "optional-label" }, "(optional)") : '')), h("slot", { key: 'e40411eb484d37dcc9980aaab3a1f69aaf954cc0', name: "label" }), h("div", { key: '89002e60d7f77b252f0c2975ce7a06e60fc2f869', class: {
119
+ 'container': true,
120
+ 'error': Boolean(this.errorText),
121
+ 'drag': this.dragOver,
122
+ 'drag-error': this.dragError,
123
+ } }, h("div", { key: '8bafc5c869a0bce30ab2d8b5a0637a3e0107c6fa', class: { 'label-container': true } }, h("slot", { key: '45243bf17f5ea2e330146b1b87f5f2d523ac9250', name: "left-content" })), h("div", { key: '7e2da2facbb1f602b9da2f2a02f8993f629d14a8', class: { 'file-container': true } }, this.FileContent), h("input", { key: '6f16f2eeab60fb48018d98ff97de89707d1fdef2', id: this.inputId, type: "file", accept: (_b = (_a = this.fileTypes) === null || _a === void 0 ? void 0 : _a.join(', ')) !== null && _b !== void 0 ? _b : '*', files: this.file ? [this.file] : undefined, onDrop: this.handleDrop, onDragEnter: this.handleDragEnter, onDragLeave: this.handleDragLeave, onChange: this.handleInputChange })), (this.errorText || this.helperText) && (h("div", { key: '26967c087e20d68251d603257fbe0ba491807043', class: { 'helper-text-container': true, 'error-text': Boolean(this.errorText) } }, h("span", { key: 'a1c85bed3f74a2f1808fb5f472bddf4c9ea7dc7b' }, (_c = this.errorText) !== null && _c !== void 0 ? _c : this.helperText)))));
119
124
  }
120
125
  static get is() { return "cpsl-file-upload"; }
121
126
  static get encapsulation() { return "shadow"; }
@@ -1 +1 @@
1
- {"version":3,"file":"cpsl-file-upload.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,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBAClF,+DAAO,MAAA,IAAI,CAAC,SAAS,mCAAI,IAAI,CAAC,UAAU,CAAQ,CAC5C,CACP,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,QAAQ,GAAG,CAAC,CAAC","sourcesContent":["import { Component, Host, Prop, Event, h, EventEmitter, State, Fragment, Element } from '@stencil/core';\n\n@Component({\n tag: 'cpsl-file-upload',\n styleUrl: 'cpsl-file-upload.scss',\n shadow: true,\n})\nexport class CpslFileUpload {\n @Element() el!: HTMLCpslFileUploadElement;\n\n private inputId = `cpsl-file-upload-${inputIds++}`;\n\n @State() file?: File;\n @State() dragOver?: boolean;\n @State() dragError?: boolean;\n @State() isUploading?: boolean;\n @State() uploadError?: boolean;\n\n /**\n * Error text to show below the input. If this is provided the input will enter an error state.\n */\n @Prop() errorText?: string;\n\n /**\n * Filename for the external source of the selected file.\n */\n @Prop() externalFilename?: string;\n\n /**\n * External source for the selected file.\n */\n @Prop() externalSrc?: string;\n\n /**\n * Valid file types.\n */\n @Prop() fileTypes?: string[];\n\n /**\n * Helper text to show below the input. If `\"errorText\"` is provided that will take precedence.\n */\n @Prop() helperText?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label?: string;\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required = false;\n\n /**\n * If `true`, the label will display an \"optional\" tag.\n */\n @Prop() showOptionalLabel = false;\n\n /**\n * Function to trigger file upload to server.\n * Returns: boolean indicating success or failure.\n */\n @Prop() uploadFile?: (file: File) => Promise<boolean>;\n\n /**\n * Emitted when the file is dropped in the input.\n */\n @Event() cpslOnDrop!: EventEmitter<DragEvent>;\n\n /**\n * Emitted when the file drag enters the input.\n */\n @Event() cpslOnDragEnter!: EventEmitter<DragEvent>;\n\n /**\n * Emitted when the file drag leaves the input.\n */\n @Event() cpslOnDragLeave!: EventEmitter<DragEvent>;\n\n /**\n * Emitted when the file changes.\n */\n @Event() cpslFileChange!: EventEmitter<File>;\n\n /**\n * Emitted when the file is removed.\n */\n @Event() cpslFileRemoved!: EventEmitter<void>;\n\n private handleDrop = async (ev: DragEvent) => {\n ev.preventDefault();\n\n const item = Array.from(ev.dataTransfer.items)?.[0];\n\n if (item && this.isValidFile(item.type)) {\n const file = item.getAsFile();\n await this.addFile(file);\n }\n\n this.dragOver = false;\n this.dragError = false;\n\n this.cpslOnDrop.emit(ev);\n };\n\n private handleDragEnter = (ev: DragEvent) => {\n ev.preventDefault();\n\n this.dragOver = true;\n\n const item = Array.from(ev.dataTransfer.items)?.[0];\n\n if (item && this.isValidFile(item.type)) {\n this.dragError = true;\n }\n\n this.cpslOnDragEnter.emit(ev);\n };\n\n private handleDragLeave = (ev: DragEvent) => {\n ev.preventDefault();\n\n this.dragOver = false;\n this.dragError = false;\n\n this.cpslOnDragLeave.emit(ev);\n };\n\n private handleInputChange = async (ev: Event) => {\n ev.preventDefault();\n\n const input = this.inputEl;\n\n if (input.files.length) {\n const file = input.files[0];\n\n if (this.isValidFile(file.type)) {\n await this.addFile(file);\n }\n }\n };\n\n private isValidFile = (type: string) => {\n if (this.fileTypes?.length ? !this.fileTypes.includes(type) : false) {\n return false;\n }\n\n return true;\n };\n\n private addFile = async (file: File) => {\n this.file = file;\n this.cpslFileChange.emit(file);\n this.uploadError = false;\n this.isUploading = true;\n const uploadSuccess = this.uploadFile ? await this.uploadFile(file) : true;\n if (!uploadSuccess) {\n this.uploadError = true;\n const input = this.inputEl;\n input.value = '';\n }\n this.isUploading = false;\n };\n\n private removeFile = (e: MouseEvent) => {\n e.preventDefault();\n\n this.file = undefined;\n\n const input = this.inputEl;\n input.value = '';\n\n this.cpslFileRemoved.emit();\n };\n\n get inputEl() {\n return this.el.shadowRoot.getElementById(this.inputId) as HTMLInputElement;\n }\n\n get FileContent() {\n const hasFile = Boolean(this.file) || Boolean(this.externalSrc);\n const isUploading = this.isUploading;\n const error = this.uploadError;\n\n const text = !hasFile ? (\n <Fragment>\n {'Drag file here or '}\n <cpsl-text class=\"inline-text\" variant=\"bodyXS\">\n upload file\n </cpsl-text>\n </Fragment>\n ) : isUploading ? (\n `${this.file.name} is uploading`\n ) : error ? (\n 'Upload Failed'\n ) : (\n this.file?.name || this.externalFilename || ''\n );\n const TopElement = !hasFile ? (\n <cpsl-icon icon=\"image\" />\n ) : isUploading ? (\n <cpsl-spinner />\n ) : error ? (\n <cpsl-icon icon=\"close\" />\n ) : (\n <img class=\"sample-img\" src={this.file ? URL.createObjectURL(this.file) : this.externalSrc} alt=\"Sample Image\" />\n );\n\n return (\n <Fragment>\n {TopElement}\n <span class=\"sample-image-name-container\">\n <cpsl-text class=\"sample-image-name\" variant=\"bodyXS\">\n {text}\n </cpsl-text>\n {hasFile && !error && !isUploading && <cpsl-icon icon=\"close\" onClick={this.removeFile} />}\n </span>\n </Fragment>\n );\n }\n\n render() {\n return (\n <Host>\n {this.label && (\n <label class=\"label\" htmlFor={this.inputId}>\n {this.label}\n {this.required ? '*' : ' '}\n {!this.required && this.showOptionalLabel ? <span class=\"optional-label\">(optional)</span> : ''}\n </label>\n )}\n <slot name=\"label\"></slot>\n <div class={{ 'container': true, 'error': Boolean(this.errorText), 'drag': this.dragOver, 'drag-error': this.dragError }}>\n <div class={{ 'label-container': true }}>\n <slot name=\"left-content\"></slot>\n </div>\n <div class={{ 'file-container': true }}>{this.FileContent}</div>\n <input\n id={this.inputId}\n type=\"file\"\n accept={this.fileTypes?.join(', ') ?? '*'}\n files={this.file ? [this.file] : undefined}\n onDrop={this.handleDrop}\n onDragEnter={this.handleDragEnter}\n onDragLeave={this.handleDragLeave}\n onChange={this.handleInputChange}\n />\n </div>\n {(this.errorText || this.helperText) && (\n <div class={{ 'helper-text-container': true, 'error-text': Boolean(this.errorText) }}>\n <span>{this.errorText ?? this.helperText}</span>\n </div>\n )}\n </Host>\n );\n }\n}\n\nlet inputIds = 0;\n"]}
1
+ {"version":3,"file":"cpsl-file-upload.js","sourceRoot":"","sources":["../../../../src/components/cpsl-file-upload/cpsl-file-upload.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAgB,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAOxG,MAAM,OAAO,cAAc;;QAGjB,YAAO,GAAG,oBAAoB,QAAQ,EAAE,EAAE,CAAC;QA+E3C,eAAU,GAAG,CAAO,EAAa,EAAE,EAAE;;YAC3C,EAAE,CAAC,cAAc,EAAE,CAAC;YAEpB,MAAM,IAAI,GAAG,MAAA,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,0CAAG,CAAC,CAAC,CAAC;YAEpD,IAAI,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;gBAC9B,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;YAED,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YACtB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;YAEvB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC3B,CAAC,CAAA,CAAC;QAEM,oBAAe,GAAG,CAAC,EAAa,EAAE,EAAE;;YAC1C,E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,CAAC,SAAS,EAC1C,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,WAAW,EAAE,IAAI,CAAC,eAAe,EACjC,WAAW,EAAE,IAAI,CAAC,eAAe,EACjC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,GAChC,CACE;YACL,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CACtC,4DAAK,KAAK,EAAE,EAAE,uBAAuB,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBAClF,+DAAO,MAAA,IAAI,CAAC,SAAS,mCAAI,IAAI,CAAC,UAAU,CAAQ,CAC5C,CACP,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,QAAQ,GAAG,CAAC,CAAC","sourcesContent":["import { Component, Host, Prop, Event, h, EventEmitter, State, Fragment, Element } from '@stencil/core';\n\n@Component({\n tag: 'cpsl-file-upload',\n styleUrl: 'cpsl-file-upload.scss',\n shadow: true,\n})\nexport class CpslFileUpload {\n @Element() el!: HTMLCpslFileUploadElement;\n\n private inputId = `cpsl-file-upload-${inputIds++}`;\n\n @State() file?: File;\n @State() dragOver?: boolean;\n @State() dragError?: boolean;\n @State() isUploading?: boolean;\n @State() uploadError?: boolean;\n\n /**\n * Error text to show below the input. If this is provided the input will enter an error state.\n */\n @Prop() errorText?: string;\n\n /**\n * Filename for the external source of the selected file.\n */\n @Prop() externalFilename?: string;\n\n /**\n * External source for the selected file.\n */\n @Prop() externalSrc?: string;\n\n /**\n * Valid file types.\n */\n @Prop() fileTypes?: string[];\n\n /**\n * Helper text to show below the input. If `\"errorText\"` is provided that will take precedence.\n */\n @Prop() helperText?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label?: string;\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required = false;\n\n /**\n * If `true`, the label will display an \"optional\" tag.\n */\n @Prop() showOptionalLabel = false;\n\n /**\n * Function to trigger file upload to server.\n * Returns: boolean indicating success or failure.\n */\n @Prop() uploadFile?: (file: File) => Promise<boolean>;\n\n /**\n * Emitted when the file is dropped in the input.\n */\n @Event() cpslOnDrop!: EventEmitter<DragEvent>;\n\n /**\n * Emitted when the file drag enters the input.\n */\n @Event() cpslOnDragEnter!: EventEmitter<DragEvent>;\n\n /**\n * Emitted when the file drag leaves the input.\n */\n @Event() cpslOnDragLeave!: EventEmitter<DragEvent>;\n\n /**\n * Emitted when the file changes.\n */\n @Event() cpslFileChange!: EventEmitter<File>;\n\n /**\n * Emitted when the file is removed.\n */\n @Event() cpslFileRemoved!: EventEmitter<void>;\n\n private handleDrop = async (ev: DragEvent) => {\n ev.preventDefault();\n\n const item = Array.from(ev.dataTransfer.items)?.[0];\n\n if (item && this.isValidFile(item.type)) {\n const file = item.getAsFile();\n await this.addFile(file);\n }\n\n this.dragOver = false;\n this.dragError = false;\n\n this.cpslOnDrop.emit(ev);\n };\n\n private handleDragEnter = (ev: DragEvent) => {\n ev.preventDefault();\n\n this.dragOver = true;\n\n const item = Array.from(ev.dataTransfer.items)?.[0];\n\n if (item && this.isValidFile(item.type)) {\n this.dragError = true;\n }\n\n this.cpslOnDragEnter.emit(ev);\n };\n\n private handleDragLeave = (ev: DragEvent) => {\n ev.preventDefault();\n\n this.dragOver = false;\n this.dragError = false;\n\n this.cpslOnDragLeave.emit(ev);\n };\n\n private handleInputChange = async (ev: Event) => {\n ev.preventDefault();\n\n const input = this.inputEl;\n\n if (input.files.length) {\n const file = input.files[0];\n\n if (this.isValidFile(file.type)) {\n await this.addFile(file);\n }\n }\n };\n\n private isValidFile = (type: string) => {\n if (this.fileTypes?.length ? !this.fileTypes.includes(type) : false) {\n return false;\n }\n\n return true;\n };\n\n private addFile = async (file: File) => {\n this.file = file;\n this.cpslFileChange.emit(file);\n this.uploadError = false;\n this.isUploading = true;\n const uploadSuccess = this.uploadFile ? await this.uploadFile(file) : true;\n if (!uploadSuccess) {\n this.uploadError = true;\n const input = this.inputEl;\n input.value = '';\n }\n this.isUploading = false;\n };\n\n private removeFile = (e: MouseEvent) => {\n e.preventDefault();\n\n this.file = undefined;\n\n const input = this.inputEl;\n input.value = '';\n\n this.cpslFileRemoved.emit();\n };\n\n get inputEl() {\n return this.el.shadowRoot.getElementById(this.inputId) as HTMLInputElement;\n }\n\n get FileContent() {\n const hasFile = Boolean(this.file) || Boolean(this.externalSrc);\n const isUploading = this.isUploading;\n const error = this.uploadError;\n\n const text = !hasFile ? (\n <Fragment>\n {'Drag file here or '}\n <cpsl-text class=\"inline-text\" variant=\"bodyXS\">\n upload file\n </cpsl-text>\n </Fragment>\n ) : isUploading ? (\n `${this.file.name} is uploading`\n ) : error ? (\n 'Upload Failed'\n ) : (\n this.file?.name || this.externalFilename || ''\n );\n const TopElement = !hasFile ? (\n <cpsl-icon icon=\"image\" />\n ) : isUploading ? (\n <cpsl-spinner />\n ) : error ? (\n <cpsl-icon icon=\"close\" />\n ) : (\n <img class=\"sample-img\" src={this.file ? URL.createObjectURL(this.file) : this.externalSrc} alt=\"Sample Image\" />\n );\n\n return (\n <Fragment>\n {TopElement}\n <span class=\"sample-image-name-container\">\n <cpsl-text class=\"sample-image-name\" variant=\"bodyXS\">\n {text}\n </cpsl-text>\n {hasFile && !error && !isUploading && <cpsl-icon icon=\"close\" onClick={this.removeFile} />}\n </span>\n </Fragment>\n );\n }\n\n render() {\n return (\n <Host>\n {this.label && (\n <label class=\"label\" htmlFor={this.inputId}>\n {this.label}\n {this.required ? '*' : ' '}\n {!this.required && this.showOptionalLabel ? <span class=\"optional-label\">(optional)</span> : ''}\n </label>\n )}\n <slot name=\"label\"></slot>\n <div\n class={{\n 'container': true,\n 'error': Boolean(this.errorText),\n 'drag': this.dragOver,\n 'drag-error': this.dragError,\n }}\n >\n <div class={{ 'label-container': true }}>\n <slot name=\"left-content\"></slot>\n </div>\n <div class={{ 'file-container': true }}>{this.FileContent}</div>\n <input\n id={this.inputId}\n type=\"file\"\n accept={this.fileTypes?.join(', ') ?? '*'}\n files={this.file ? [this.file] : undefined}\n onDrop={this.handleDrop}\n onDragEnter={this.handleDragEnter}\n onDragLeave={this.handleDragLeave}\n onChange={this.handleInputChange}\n />\n </div>\n {(this.errorText || this.helperText) && (\n <div class={{ 'helper-text-container': true, 'error-text': Boolean(this.errorText) }}>\n <span>{this.errorText ?? this.helperText}</span>\n </div>\n )}\n </Host>\n );\n }\n}\n\nlet inputIds = 0;\n"]}