@daikin-oss/design-system-web-components 1.2.0 → 1.3.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 (245) hide show
  1. package/CHANGELOG.md +150 -0
  2. package/dist/cjs/base/dds-element.cjs +1 -1
  3. package/dist/cjs/components/accordion-item/daikin-accordion-item.cjs +1 -0
  4. package/dist/cjs/components/avatar/daikin-avatar.cjs +1 -0
  5. package/dist/cjs/components/calendar/daikin-calendar.cjs +2 -0
  6. package/dist/cjs/components/card-header/daikin-card-header.cjs +1 -1
  7. package/dist/cjs/components/carousel/daikin-carousel.cjs +7 -3
  8. package/dist/cjs/components/carousel-item/daikin-carousel-item.cjs +2 -2
  9. package/dist/cjs/components/chip/daikin-chip.cjs +106 -0
  10. package/dist/cjs/components/chip/daikin-chip.d.cts +36 -0
  11. package/dist/cjs/components/chip/index.cjs +7 -0
  12. package/dist/cjs/components/chip/index.d.cts +1 -0
  13. package/dist/cjs/components/combobox/daikin-combobox.cjs +604 -0
  14. package/dist/cjs/components/combobox/daikin-combobox.d.cts +134 -0
  15. package/dist/cjs/components/combobox/index.cjs +8 -0
  16. package/dist/cjs/components/combobox/index.d.cts +1 -0
  17. package/dist/cjs/components/date-picker/daikin-date-picker.cjs +31 -16
  18. package/dist/cjs/components/date-picker/daikin-date-picker.d.cts +2 -1
  19. package/dist/cjs/components/dropdown/daikin-dropdown.cjs +52 -37
  20. package/dist/cjs/components/dropdown/daikin-dropdown.d.cts +4 -3
  21. package/dist/cjs/components/icon/daikin-icon.cjs +117 -12
  22. package/dist/cjs/components/icon/daikin-icon.d.cts +141 -9
  23. package/dist/cjs/components/icon/icons.json.cjs +5 -1
  24. package/dist/cjs/components/icon-button/daikin-icon-button.cjs +12 -2
  25. package/dist/cjs/components/icon-button/daikin-icon-button.d.cts +8 -0
  26. package/dist/cjs/components/index.cjs +36 -0
  27. package/dist/cjs/components/index.d.cts +5 -0
  28. package/dist/cjs/components/input-group/daikin-input-group.cjs +1 -1
  29. package/dist/cjs/components/input-group/daikin-input-group.d.cts +40 -13
  30. package/dist/cjs/components/list-item/daikin-list-item.cjs +2 -2
  31. package/dist/cjs/components/modal-header/daikin-modal-header.cjs +1 -1
  32. package/dist/cjs/components/progress-bar/daikin-progress-bar.cjs +3 -3
  33. package/dist/cjs/components/select/daikin-select.cjs +6 -1
  34. package/dist/cjs/components/tab/daikin-tab.cjs +1 -0
  35. package/dist/cjs/components/table/daikin-table.cjs +33 -12
  36. package/dist/cjs/components/table/daikin-table.d.cts +67 -34
  37. package/dist/cjs/components/table-header-cell/daikin-table-header-cell.cjs +31 -6
  38. package/dist/cjs/components/table-header-cell/daikin-table-header-cell.d.cts +7 -0
  39. package/dist/cjs/components/text-field/daikin-text-field.cjs +191 -56
  40. package/dist/cjs/components/text-field/daikin-text-field.d.cts +32 -3
  41. package/dist/cjs/components/text-field/number-utils.cjs +61 -0
  42. package/dist/cjs/components/text-field/number-utils.d.cts +26 -0
  43. package/dist/cjs/components/text-masked-field/daikin-text-masked-field.cjs +312 -0
  44. package/dist/cjs/components/text-masked-field/daikin-text-masked-field.d.cts +136 -0
  45. package/dist/cjs/components/text-masked-field/index.cjs +7 -0
  46. package/dist/cjs/components/text-masked-field/index.d.cts +1 -0
  47. package/dist/cjs/components/time-picker/daikin-time-picker.cjs +577 -0
  48. package/dist/cjs/components/time-picker/daikin-time-picker.d.cts +165 -0
  49. package/dist/cjs/components/time-picker/index.cjs +17 -0
  50. package/dist/cjs/components/time-picker/index.d.cts +1 -0
  51. package/dist/cjs/components/toast-notification-manager/daikin-toast-notification-manager.d.cts +1 -1
  52. package/dist/cjs/components/tooltip/daikin-tooltip.cjs +12 -2
  53. package/dist/cjs/components/tooltip/daikin-tooltip.d.cts +8 -1
  54. package/dist/cjs/controllers/floating-ui-auto-update.cjs +22 -4
  55. package/dist/cjs/controllers/floating-ui-auto-update.d.cts +12 -0
  56. package/dist/cjs/icon-registry.cjs +170 -0
  57. package/dist/cjs/icon-registry.d.cts +120 -0
  58. package/dist/cjs/index.cjs +39 -0
  59. package/dist/cjs/index.d.cts +1 -0
  60. package/dist/cjs/tailwind.css.cjs +1 -1
  61. package/dist/cjs/utils/notification-common.d.cts +1 -1
  62. package/dist/cjs-dev/base/dds-element.cjs +1 -1
  63. package/dist/cjs-dev/components/accordion-item/daikin-accordion-item.cjs +1 -0
  64. package/dist/cjs-dev/components/avatar/daikin-avatar.cjs +1 -0
  65. package/dist/cjs-dev/components/calendar/daikin-calendar.cjs +2 -0
  66. package/dist/cjs-dev/components/card-header/daikin-card-header.cjs +1 -1
  67. package/dist/cjs-dev/components/carousel/daikin-carousel.cjs +7 -3
  68. package/dist/cjs-dev/components/carousel-item/daikin-carousel-item.cjs +2 -2
  69. package/dist/cjs-dev/components/chip/daikin-chip.cjs +106 -0
  70. package/dist/cjs-dev/components/chip/daikin-chip.d.cts +36 -0
  71. package/dist/cjs-dev/components/chip/index.cjs +7 -0
  72. package/dist/cjs-dev/components/chip/index.d.cts +1 -0
  73. package/dist/cjs-dev/components/combobox/daikin-combobox.cjs +604 -0
  74. package/dist/cjs-dev/components/combobox/daikin-combobox.d.cts +134 -0
  75. package/dist/cjs-dev/components/combobox/index.cjs +8 -0
  76. package/dist/cjs-dev/components/combobox/index.d.cts +1 -0
  77. package/dist/cjs-dev/components/date-picker/daikin-date-picker.cjs +31 -16
  78. package/dist/cjs-dev/components/date-picker/daikin-date-picker.d.cts +2 -1
  79. package/dist/cjs-dev/components/dropdown/daikin-dropdown.cjs +52 -37
  80. package/dist/cjs-dev/components/dropdown/daikin-dropdown.d.cts +4 -3
  81. package/dist/cjs-dev/components/icon/daikin-icon.cjs +141 -16
  82. package/dist/cjs-dev/components/icon/daikin-icon.d.cts +141 -9
  83. package/dist/cjs-dev/components/icon/icons.json.cjs +5 -1
  84. package/dist/cjs-dev/components/icon-button/daikin-icon-button.cjs +12 -2
  85. package/dist/cjs-dev/components/icon-button/daikin-icon-button.d.cts +8 -0
  86. package/dist/cjs-dev/components/index.cjs +36 -0
  87. package/dist/cjs-dev/components/index.d.cts +5 -0
  88. package/dist/cjs-dev/components/input-group/daikin-input-group.cjs +1 -1
  89. package/dist/cjs-dev/components/input-group/daikin-input-group.d.cts +40 -13
  90. package/dist/cjs-dev/components/list-item/daikin-list-item.cjs +2 -2
  91. package/dist/cjs-dev/components/modal-header/daikin-modal-header.cjs +1 -1
  92. package/dist/cjs-dev/components/progress-bar/daikin-progress-bar.cjs +3 -3
  93. package/dist/cjs-dev/components/select/daikin-select.cjs +6 -1
  94. package/dist/cjs-dev/components/tab/daikin-tab.cjs +1 -0
  95. package/dist/cjs-dev/components/table/daikin-table.cjs +36 -15
  96. package/dist/cjs-dev/components/table/daikin-table.d.cts +67 -34
  97. package/dist/cjs-dev/components/table-header-cell/daikin-table-header-cell.cjs +31 -6
  98. package/dist/cjs-dev/components/table-header-cell/daikin-table-header-cell.d.cts +7 -0
  99. package/dist/cjs-dev/components/text-field/daikin-text-field.cjs +191 -56
  100. package/dist/cjs-dev/components/text-field/daikin-text-field.d.cts +32 -3
  101. package/dist/cjs-dev/components/text-field/number-utils.cjs +64 -0
  102. package/dist/cjs-dev/components/text-field/number-utils.d.cts +26 -0
  103. package/dist/cjs-dev/components/text-masked-field/daikin-text-masked-field.cjs +312 -0
  104. package/dist/cjs-dev/components/text-masked-field/daikin-text-masked-field.d.cts +136 -0
  105. package/dist/cjs-dev/components/text-masked-field/index.cjs +7 -0
  106. package/dist/cjs-dev/components/text-masked-field/index.d.cts +1 -0
  107. package/dist/cjs-dev/components/time-picker/daikin-time-picker.cjs +589 -0
  108. package/dist/cjs-dev/components/time-picker/daikin-time-picker.d.cts +165 -0
  109. package/dist/cjs-dev/components/time-picker/index.cjs +17 -0
  110. package/dist/cjs-dev/components/time-picker/index.d.cts +1 -0
  111. package/dist/cjs-dev/components/toast-notification-manager/daikin-toast-notification-manager.d.cts +1 -1
  112. package/dist/cjs-dev/components/tooltip/daikin-tooltip.cjs +12 -2
  113. package/dist/cjs-dev/components/tooltip/daikin-tooltip.d.cts +8 -1
  114. package/dist/cjs-dev/controllers/floating-ui-auto-update.cjs +22 -4
  115. package/dist/cjs-dev/controllers/floating-ui-auto-update.d.cts +12 -0
  116. package/dist/cjs-dev/icon-registry.cjs +170 -0
  117. package/dist/cjs-dev/icon-registry.d.cts +120 -0
  118. package/dist/cjs-dev/index.cjs +39 -0
  119. package/dist/cjs-dev/index.d.cts +1 -0
  120. package/dist/cjs-dev/tailwind.css.cjs +1 -1
  121. package/dist/cjs-dev/utils/notification-common.d.cts +1 -1
  122. package/dist/es/base/dds-element.js +1 -1
  123. package/dist/es/components/accordion-item/daikin-accordion-item.js +1 -0
  124. package/dist/es/components/avatar/daikin-avatar.js +1 -0
  125. package/dist/es/components/calendar/daikin-calendar.js +2 -0
  126. package/dist/es/components/card-header/daikin-card-header.js +1 -1
  127. package/dist/es/components/carousel/daikin-carousel.js +7 -3
  128. package/dist/es/components/carousel-item/daikin-carousel-item.js +2 -2
  129. package/dist/es/components/chip/daikin-chip.d.ts +36 -0
  130. package/dist/es/components/chip/daikin-chip.js +107 -0
  131. package/dist/es/components/chip/index.d.ts +1 -0
  132. package/dist/es/components/chip/index.js +4 -0
  133. package/dist/es/components/combobox/daikin-combobox.d.ts +134 -0
  134. package/dist/es/components/combobox/daikin-combobox.js +605 -0
  135. package/dist/es/components/combobox/index.d.ts +1 -0
  136. package/dist/es/components/combobox/index.js +5 -0
  137. package/dist/es/components/date-picker/daikin-date-picker.d.ts +2 -1
  138. package/dist/es/components/date-picker/daikin-date-picker.js +32 -17
  139. package/dist/es/components/dropdown/daikin-dropdown.d.ts +4 -3
  140. package/dist/es/components/dropdown/daikin-dropdown.js +52 -37
  141. package/dist/es/components/icon/daikin-icon.d.ts +141 -9
  142. package/dist/es/components/icon/daikin-icon.js +118 -13
  143. package/dist/es/components/icon/icons.json.js +4 -0
  144. package/dist/es/components/icon-button/daikin-icon-button.d.ts +8 -0
  145. package/dist/es/components/icon-button/daikin-icon-button.js +12 -2
  146. package/dist/es/components/index.d.ts +5 -0
  147. package/dist/es/components/index.js +22 -1
  148. package/dist/es/components/input-group/daikin-input-group.d.ts +40 -13
  149. package/dist/es/components/input-group/daikin-input-group.js +1 -1
  150. package/dist/es/components/list-item/daikin-list-item.js +2 -2
  151. package/dist/es/components/modal-header/daikin-modal-header.js +1 -1
  152. package/dist/es/components/progress-bar/daikin-progress-bar.js +3 -3
  153. package/dist/es/components/select/daikin-select.js +6 -1
  154. package/dist/es/components/tab/daikin-tab.js +1 -0
  155. package/dist/es/components/table/daikin-table.d.ts +67 -34
  156. package/dist/es/components/table/daikin-table.js +33 -12
  157. package/dist/es/components/table-header-cell/daikin-table-header-cell.d.ts +7 -0
  158. package/dist/es/components/table-header-cell/daikin-table-header-cell.js +31 -6
  159. package/dist/es/components/text-field/daikin-text-field.d.ts +32 -3
  160. package/dist/es/components/text-field/daikin-text-field.js +191 -56
  161. package/dist/es/components/text-field/number-utils.d.ts +26 -0
  162. package/dist/es/components/text-field/number-utils.js +61 -0
  163. package/dist/es/components/text-masked-field/daikin-text-masked-field.d.ts +136 -0
  164. package/dist/es/components/text-masked-field/daikin-text-masked-field.js +313 -0
  165. package/dist/es/components/text-masked-field/index.d.ts +1 -0
  166. package/dist/es/components/text-masked-field/index.js +4 -0
  167. package/dist/es/components/time-picker/daikin-time-picker.d.ts +165 -0
  168. package/dist/es/components/time-picker/daikin-time-picker.js +578 -0
  169. package/dist/es/components/time-picker/index.d.ts +1 -0
  170. package/dist/es/components/time-picker/index.js +14 -0
  171. package/dist/es/components/toast-notification-manager/daikin-toast-notification-manager.d.ts +1 -1
  172. package/dist/es/components/tooltip/daikin-tooltip.d.ts +8 -1
  173. package/dist/es/components/tooltip/daikin-tooltip.js +12 -2
  174. package/dist/es/controllers/floating-ui-auto-update.d.ts +12 -0
  175. package/dist/es/controllers/floating-ui-auto-update.js +22 -4
  176. package/dist/es/icon-registry.d.ts +120 -0
  177. package/dist/es/icon-registry.js +170 -0
  178. package/dist/es/index.d.ts +1 -0
  179. package/dist/es/index.js +25 -1
  180. package/dist/es/tailwind.css.js +1 -1
  181. package/dist/es/utils/notification-common.d.ts +1 -1
  182. package/dist/es-dev/base/dds-element.js +1 -1
  183. package/dist/es-dev/components/accordion-item/daikin-accordion-item.js +1 -0
  184. package/dist/es-dev/components/avatar/daikin-avatar.js +1 -0
  185. package/dist/es-dev/components/calendar/daikin-calendar.js +2 -0
  186. package/dist/es-dev/components/card-header/daikin-card-header.js +1 -1
  187. package/dist/es-dev/components/carousel/daikin-carousel.js +7 -3
  188. package/dist/es-dev/components/carousel-item/daikin-carousel-item.js +2 -2
  189. package/dist/es-dev/components/chip/daikin-chip.d.ts +36 -0
  190. package/dist/es-dev/components/chip/daikin-chip.js +107 -0
  191. package/dist/es-dev/components/chip/index.d.ts +1 -0
  192. package/dist/es-dev/components/chip/index.js +4 -0
  193. package/dist/es-dev/components/combobox/daikin-combobox.d.ts +134 -0
  194. package/dist/es-dev/components/combobox/daikin-combobox.js +605 -0
  195. package/dist/es-dev/components/combobox/index.d.ts +1 -0
  196. package/dist/es-dev/components/combobox/index.js +5 -0
  197. package/dist/es-dev/components/date-picker/daikin-date-picker.d.ts +2 -1
  198. package/dist/es-dev/components/date-picker/daikin-date-picker.js +32 -17
  199. package/dist/es-dev/components/dropdown/daikin-dropdown.d.ts +4 -3
  200. package/dist/es-dev/components/dropdown/daikin-dropdown.js +52 -37
  201. package/dist/es-dev/components/icon/daikin-icon.d.ts +141 -9
  202. package/dist/es-dev/components/icon/daikin-icon.js +142 -17
  203. package/dist/es-dev/components/icon/icons.json.js +4 -0
  204. package/dist/es-dev/components/icon-button/daikin-icon-button.d.ts +8 -0
  205. package/dist/es-dev/components/icon-button/daikin-icon-button.js +12 -2
  206. package/dist/es-dev/components/index.d.ts +5 -0
  207. package/dist/es-dev/components/index.js +22 -1
  208. package/dist/es-dev/components/input-group/daikin-input-group.d.ts +40 -13
  209. package/dist/es-dev/components/input-group/daikin-input-group.js +1 -1
  210. package/dist/es-dev/components/list-item/daikin-list-item.js +2 -2
  211. package/dist/es-dev/components/modal-header/daikin-modal-header.js +1 -1
  212. package/dist/es-dev/components/progress-bar/daikin-progress-bar.js +3 -3
  213. package/dist/es-dev/components/select/daikin-select.js +6 -1
  214. package/dist/es-dev/components/tab/daikin-tab.js +1 -0
  215. package/dist/es-dev/components/table/daikin-table.d.ts +67 -34
  216. package/dist/es-dev/components/table/daikin-table.js +36 -15
  217. package/dist/es-dev/components/table-header-cell/daikin-table-header-cell.d.ts +7 -0
  218. package/dist/es-dev/components/table-header-cell/daikin-table-header-cell.js +31 -6
  219. package/dist/es-dev/components/text-field/daikin-text-field.d.ts +32 -3
  220. package/dist/es-dev/components/text-field/daikin-text-field.js +191 -56
  221. package/dist/es-dev/components/text-field/number-utils.d.ts +26 -0
  222. package/dist/es-dev/components/text-field/number-utils.js +64 -0
  223. package/dist/es-dev/components/text-masked-field/daikin-text-masked-field.d.ts +136 -0
  224. package/dist/es-dev/components/text-masked-field/daikin-text-masked-field.js +313 -0
  225. package/dist/es-dev/components/text-masked-field/index.d.ts +1 -0
  226. package/dist/es-dev/components/text-masked-field/index.js +4 -0
  227. package/dist/es-dev/components/time-picker/daikin-time-picker.d.ts +165 -0
  228. package/dist/es-dev/components/time-picker/daikin-time-picker.js +590 -0
  229. package/dist/es-dev/components/time-picker/index.d.ts +1 -0
  230. package/dist/es-dev/components/time-picker/index.js +14 -0
  231. package/dist/es-dev/components/toast-notification-manager/daikin-toast-notification-manager.d.ts +1 -1
  232. package/dist/es-dev/components/tooltip/daikin-tooltip.d.ts +8 -1
  233. package/dist/es-dev/components/tooltip/daikin-tooltip.js +12 -2
  234. package/dist/es-dev/controllers/floating-ui-auto-update.d.ts +12 -0
  235. package/dist/es-dev/controllers/floating-ui-auto-update.js +22 -4
  236. package/dist/es-dev/icon-registry.d.ts +120 -0
  237. package/dist/es-dev/icon-registry.js +170 -0
  238. package/dist/es-dev/index.d.ts +1 -0
  239. package/dist/es-dev/index.js +25 -1
  240. package/dist/es-dev/tailwind.css.js +1 -1
  241. package/dist/es-dev/utils/notification-common.d.ts +1 -1
  242. package/icons/number-minus.svg +5 -0
  243. package/icons/number-plus.svg +5 -0
  244. package/package.json +14 -4
  245. package/icons/dropdown-chevron-down.svg +0 -3
@@ -1,7 +1,8 @@
1
- import { offset } from "@floating-ui/dom";
1
+ import { offset, flip, shift } from "@floating-ui/dom";
2
2
  import { cva } from "class-variance-authority";
3
3
  import { unsafeCSS, css, html } from "lit";
4
4
  import { property, state, customElement } from "lit/decorators.js";
5
+ import { guard } from "lit/directives/guard.js";
5
6
  import { ifDefined } from "lit/directives/if-defined.js";
6
7
  import { createRef, ref } from "lit/directives/ref.js";
7
8
  import { DDSFormElement } from "../../base/dds-form-element.js";
@@ -259,12 +260,6 @@ let DaikinDatePicker = class extends DDSFormElement {
259
260
  get _open() {
260
261
  return this.open && !this.disabled && !this.readonly;
261
262
  }
262
- _openCalendar() {
263
- if (this.disabled || this.readonly) {
264
- return;
265
- }
266
- this.open = true;
267
- }
268
263
  _emitSelect() {
269
264
  this.dispatchEvent(
270
265
  new Event("select", {
@@ -408,6 +403,22 @@ let DaikinDatePicker = class extends DDSFormElement {
408
403
  }
409
404
  this._emitSelect();
410
405
  }
406
+ _handlePointerUp() {
407
+ if (this.disabled || this.readonly) {
408
+ return;
409
+ }
410
+ this.open = !this.open;
411
+ }
412
+ _handleCalendarKeyDown(event) {
413
+ if (event.key === "Enter" || event.key === " ") {
414
+ event.preventDefault();
415
+ event.stopPropagation();
416
+ if (this.disabled || this.readonly) {
417
+ return;
418
+ }
419
+ this.open = !this.open;
420
+ }
421
+ }
411
422
  _handleToggle(event) {
412
423
  if (reDispatch(this, event, new ToggleEvent("toggle", event))) {
413
424
  this.open = event.newState === "open";
@@ -496,7 +507,8 @@ let DaikinDatePicker = class extends DDSFormElement {
496
507
  variant="ghost"
497
508
  button-aria-label="Open the date picker"
498
509
  ?disabled=${this.disabled}
499
- @click=${this._openCalendar}
510
+ @pointerup=${this._handlePointerUp}
511
+ @keydown=${this._handleCalendarKeyDown}
500
512
  >
501
513
  <span class=${cvaIconButton({ intent: "calender" })}></span>
502
514
  </daikin-icon-button>
@@ -510,7 +522,7 @@ let DaikinDatePicker = class extends DDSFormElement {
510
522
  default-value=${ifDefined(
511
523
  this._defaultValue ? formatDateForProperty(this._defaultValue) : void 0
512
524
  )}
513
- popover
525
+ popover="auto"
514
526
  class="absolute left-[--floating-x,0] top-[--floating-y,0]"
515
527
  @toggle=${this._handleToggle}
516
528
  @select=${this._handleSelect}
@@ -518,14 +530,17 @@ let DaikinDatePicker = class extends DDSFormElement {
518
530
  ${this._autoUpdateController.refFloating()}
519
531
  >
520
532
  </daikin-calendar>
521
- ${// Activate auto update only when the calendar is open.
522
- // TODO: refactor here with CSS Anchor Positioning instead of using floating-ui
523
- this._autoUpdateController.directive(
524
- {
525
- placement: "bottom-start",
526
- middleware: [offset({ mainAxis: 0 })]
527
- },
528
- this._open
533
+ ${// Activate auto update only when the tooltip is open.
534
+ // TODO(DDS-1226): refactor here with CSS Anchor Positioning instead of using floating-ui
535
+ guard(
536
+ [this.open],
537
+ () => this._autoUpdateController.directive(
538
+ {
539
+ placement: "bottom-start",
540
+ middleware: [offset({ mainAxis: 0 }), flip(), shift()]
541
+ },
542
+ this.open
543
+ )
529
544
  )}`;
530
545
  }
531
546
  willUpdate(changedProperties) {
@@ -75,14 +75,13 @@ export declare class DaikinDropdown extends DDSFormElement {
75
75
  private get _selectionLabels();
76
76
  private _initialUpdateCompleted;
77
77
  private _autoUpdateController;
78
- private _clickOutsideController;
78
+ private _willBeFocusedByPress;
79
79
  /**
80
80
  * Last focused dropdown item.
81
81
  * The next time the dropdown opens, the focus will be moved to this element.
82
82
  */
83
83
  private _lastFocusedItem;
84
84
  private _dropdownRef;
85
- private _onClickOutside;
86
85
  private _searchItem;
87
86
  private _moveFocus;
88
87
  private _updateFormValue;
@@ -105,13 +104,15 @@ export declare class DaikinDropdown extends DDSFormElement {
105
104
  * If multiple selection is disabled, directly empty the selected options.
106
105
  */
107
106
  private _removeLastSelection;
108
- private _handleClick;
109
107
  private _handleKeyDown;
110
108
  private _handleKeyDownEscape;
111
109
  /**
112
110
  * Handle `focusin` event to remember last focused item.
113
111
  */
114
112
  private _handleFocusIn;
113
+ private _handlePointerDown;
114
+ private _handlePointerUp;
115
+ private _handleButtonKeyDown;
115
116
  /**
116
117
  * Handle `floating-ready` event dispatched by `FloatingUIAutoUpdateController`.
117
118
  * The dropdown menu opens after the Floating UI has finished calculating its position, so there is a slight time lag between the change to `this.open` and the actual display.
@@ -8,7 +8,6 @@ import "../../base/dds-element.js";
8
8
  import { ddsElement } from "../../base/decorators.js";
9
9
  import "../../base/define.js";
10
10
  import { DDSFormElement } from "../../base/dds-form-element.js";
11
- import { ClickOutsideController } from "../../controllers/click-outside.js";
12
11
  import { FloatingUIAutoUpdateController } from "../../controllers/floating-ui-auto-update.js";
13
12
  import tailwindStyles from "../../tailwind.css.js";
14
13
  import { isSimpleKeyEvent } from "../../utils/is-simple-key.js";
@@ -51,7 +50,7 @@ const cvaButton = cva(
51
50
  "enabled:outline-[--color-base]",
52
51
  "disabled:text-ddt-color-common-disabled",
53
52
  "disabled:outline-ddt-color-common-disabled",
54
- "after:i-daikin-dropdown-chevron-down",
53
+ "after:i-daikin-chevron-down",
55
54
  "after:size-6",
56
55
  "after:flex-none",
57
56
  "after:ml-auto",
@@ -115,10 +114,7 @@ let DaikinDropdown = class extends DDSFormElement {
115
114
  this._label = null;
116
115
  this._initialUpdateCompleted = false;
117
116
  this._autoUpdateController = new FloatingUIAutoUpdateController(this);
118
- this._clickOutsideController = new ClickOutsideController(
119
- this,
120
- this._onClickOutside
121
- );
117
+ this._willBeFocusedByPress = false;
122
118
  this._lastFocusedItem = null;
123
119
  this._dropdownRef = createRef();
124
120
  }
@@ -131,9 +127,6 @@ let DaikinDropdown = class extends DDSFormElement {
131
127
  }
132
128
  );
133
129
  }
134
- _onClickOutside() {
135
- this.open = false;
136
- }
137
130
  _searchItem(prefix) {
138
131
  const items = this._items.filter(
139
132
  (item) => {
@@ -161,8 +154,9 @@ let DaikinDropdown = class extends DDSFormElement {
161
154
  return;
162
155
  }
163
156
  const items = this._items.filter(({ disabled }) => !disabled);
164
- const activeElement = document.activeElement;
165
- const focusedItemIndex = activeElement ? items.findIndex((item2) => item2.contains(activeElement)) : -1;
157
+ const focusedItemIndex = items.findIndex(
158
+ (item2) => item2.matches(":focus-within")
159
+ );
166
160
  if (focusedItemIndex === -1) {
167
161
  moveOffset = 1;
168
162
  }
@@ -193,9 +187,10 @@ let DaikinDropdown = class extends DDSFormElement {
193
187
  _handleSelectOption(value) {
194
188
  this.value = value;
195
189
  this.selectedOptions = this.multiple ? this.selectedOptions.includes(value) ? this.selectedOptions.filter((option) => option != value) : [...this.selectedOptions, value] : [value];
190
+ this.dispatchEvent(new Event("change"));
196
191
  }
197
192
  _handleFocusOut(event) {
198
- if (!event.relatedTarget) {
193
+ if (!event.relatedTarget && !this._willBeFocusedByPress) {
199
194
  if (!this.multiple && this._lastFocusedItem) {
200
195
  this._handleSelectOption(this._lastFocusedItem.value);
201
196
  }
@@ -217,12 +212,6 @@ let DaikinDropdown = class extends DDSFormElement {
217
212
  this.value = "";
218
213
  }
219
214
  }
220
- _handleClick() {
221
- if (this.disabled) {
222
- return;
223
- }
224
- this.open = !this.open;
225
- }
226
215
  _handleKeyDown(event) {
227
216
  if (event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
228
217
  if (event.key === "ArrowDown") {
@@ -284,6 +273,28 @@ let DaikinDropdown = class extends DDSFormElement {
284
273
  }
285
274
  this._lastFocusedItem = target;
286
275
  }
276
+ _handlePointerDown() {
277
+ if (this.open) {
278
+ this._willBeFocusedByPress = true;
279
+ }
280
+ }
281
+ _handlePointerUp() {
282
+ if (this.disabled) {
283
+ return;
284
+ }
285
+ this._willBeFocusedByPress = false;
286
+ this.open = !this.open;
287
+ }
288
+ _handleButtonKeyDown(event) {
289
+ if (event.key === "Enter" || event.key === " ") {
290
+ event.preventDefault();
291
+ event.stopPropagation();
292
+ if (this.disabled) {
293
+ return;
294
+ }
295
+ this.open = !this.open;
296
+ }
297
+ }
287
298
  /**
288
299
  * Handle `floating-ready` event dispatched by `FloatingUIAutoUpdateController`.
289
300
  * The dropdown menu opens after the Floating UI has finished calculating its position, so there is a slight time lag between the change to `this.open` and the actual display.
@@ -292,7 +303,9 @@ let DaikinDropdown = class extends DDSFormElement {
292
303
  _handleFloatingReady() {
293
304
  const items = this._items;
294
305
  const item = items.find((item2) => item2 === this._lastFocusedItem) ?? items.find((item2) => item2.value === this.value) ?? items.at(0);
295
- item == null ? void 0 : item.focus();
306
+ setTimeout(() => {
307
+ item == null ? void 0 : item.focus();
308
+ }, 100);
296
309
  }
297
310
  /**
298
311
  * Handle `select` event from `daikin-dropdown-item`.
@@ -302,13 +315,13 @@ let DaikinDropdown = class extends DDSFormElement {
302
315
  if (!this.multiple) {
303
316
  this.open = false;
304
317
  }
305
- this.dispatchEvent(new Event("change"));
306
318
  }
307
319
  _handleSlotChange() {
308
320
  this._updateItemsSelectable();
309
321
  }
310
322
  render() {
311
- return html`<div class="w-full relative" @keydown=${this._handleKeyDown}>
323
+ const fallbackLabel = this.open && !this.disabled ? "Close dropdown" : this.selectedOptions.length ? `Selected: ${this._selectionLabels.join(", ")}` : "Open dropdown";
324
+ return html`<div class="w-full" @keydown=${this._handleKeyDown}>
312
325
  <button
313
326
  ${ref(this._dropdownRef)}
314
327
  type="button"
@@ -318,15 +331,15 @@ let DaikinDropdown = class extends DDSFormElement {
318
331
  placeholder: !this.selectedOptions.length
319
332
  })}
320
333
  ?disabled=${this.disabled}
321
- role="combobox"
322
- aria-label=${ifDefined(this._label ?? void 0)}
334
+ aria-label=${this._label ?? fallbackLabel}
323
335
  aria-expanded=${this.open && !this.disabled}
324
336
  aria-disabled=${this.disabled}
325
337
  aria-controls="dropdown-items"
326
- aria-autocomplete="list"
327
338
  aria-required=${this.required}
328
339
  aria-haspopup="listbox"
329
- @click=${this._handleClick}
340
+ @pointerup=${this._handlePointerUp}
341
+ @pointerdown=${this._handlePointerDown}
342
+ @keydown=${this._handleButtonKeyDown}
330
343
  ${this._autoUpdateController.refReference()}
331
344
  >
332
345
  <span class="truncate">
@@ -335,19 +348,23 @@ let DaikinDropdown = class extends DDSFormElement {
335
348
  </button>
336
349
  <div
337
350
  id="dropdown-items"
338
- popover
339
- class="floating-unready:hidden absolute left-[--floating-x,0] top-[--floating-y,0] min-w-[--floating-width] max-h-[12.5rem] border border-ddt-color-divider overflow-y-auto opacity-1 transition-[opacity] rounded max-w-min break-all"
340
- aria-label=${ifDefined(this._label ?? void 0)}
341
- role="listbox"
351
+ popover="manual"
352
+ class="flex flex-col overflow-hidden floating-unready:hidden absolute left-[--floating-x,0] top-[--floating-y,0] min-w-[--floating-width] max-h-[12.5rem] border border-ddt-color-divider opacity-1 transition-[opacity] rounded max-w-min"
342
353
  @floating-ready=${this._handleFloatingReady}
343
354
  ${this._autoUpdateController.refFloating()}
344
355
  >
345
- <slot
346
- @slotchange=${this._handleSlotChange}
347
- @select=${this._handleSelect}
348
- @focusin=${this._handleFocusIn}
349
- @focusout=${this._handleFocusOut}
350
- ></slot>
356
+ <div
357
+ class="flex-1 overflow-y-auto break-all"
358
+ aria-label=${ifDefined(this._label ?? void 0)}
359
+ role="listbox"
360
+ >
361
+ <slot
362
+ @slotchange=${this._handleSlotChange}
363
+ @select=${this._handleSelect}
364
+ @focusin=${this._handleFocusIn}
365
+ @focusout=${this._handleFocusOut}
366
+ ></slot>
367
+ </div>
351
368
  </div>
352
369
  ${// Activate auto update only when the dropdown is open.
353
370
  // TODO(DDS-1226): refactor here with CSS Anchor Positioning instead of using floating-ui
@@ -355,8 +372,6 @@ let DaikinDropdown = class extends DDSFormElement {
355
372
  floatingPositionOptions,
356
373
  this.open && !this.disabled
357
374
  )}
358
- ${// Listen to click outside only when the dropdown is open.
359
- this._clickOutsideController.directive(this.open && !this.disabled)}
360
375
  </div>`;
361
376
  }
362
377
  /**
@@ -1,23 +1,115 @@
1
1
  import { DDSElement } from "../../base/index.js";
2
+ import { IconRegistry } from "../../icon-registry.js";
2
3
  import { MergeVariantProps } from "../../type-utils.js";
3
- import { icons } from "./icons.json.js";
4
+ declare const icons: {
5
+ "logo-positive": {
6
+ class: string;
7
+ color: null;
8
+ };
9
+ "logo-negative": {
10
+ class: string;
11
+ color: null;
12
+ };
13
+ alarm: {
14
+ class: string;
15
+ color: null;
16
+ };
17
+ close: {
18
+ class: string;
19
+ color: string;
20
+ };
21
+ information: {
22
+ class: string;
23
+ color: null;
24
+ };
25
+ error: {
26
+ class: string;
27
+ color: null;
28
+ };
29
+ success: {
30
+ class: string;
31
+ color: null;
32
+ };
33
+ warning: {
34
+ class: string;
35
+ color: null;
36
+ };
37
+ "pagination-chevron-left": {
38
+ class: string;
39
+ color: string;
40
+ };
41
+ "pagination-chevron-right": {
42
+ class: string;
43
+ color: string;
44
+ };
45
+ profile: {
46
+ class: string;
47
+ color: null;
48
+ };
49
+ "chevron-up": {
50
+ class: string;
51
+ color: null;
52
+ };
53
+ "chevron-down": {
54
+ class: string;
55
+ color: null;
56
+ };
57
+ "chevron-left": {
58
+ class: string;
59
+ color: null;
60
+ };
61
+ "chevron-right": {
62
+ class: string;
63
+ color: null;
64
+ };
65
+ sort: {
66
+ class: string;
67
+ color: null;
68
+ };
69
+ negative: {
70
+ class: string;
71
+ color: null;
72
+ };
73
+ positive: {
74
+ class: string;
75
+ color: null;
76
+ };
77
+ cross: {
78
+ class: string;
79
+ color: null;
80
+ };
81
+ };
4
82
  export declare const iconList: string[];
5
83
  export type IconType = keyof typeof icons;
6
84
  declare const cvaIcon: (props?: ({
7
- icon?: string | number | null | undefined;
8
85
  color?: "current" | "default" | "black" | "white" | null | undefined;
86
+ mode?: "mask" | "background" | "inline" | "static" | null | undefined;
9
87
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
10
88
  export type IconVariantProps = MergeVariantProps<typeof cvaIcon>;
11
89
  /**
12
90
  * The icon component is a versatile UI element used to display small graphical symbols or images that represent actions, objects, or concepts within an application.
13
- * The icon set is provided by DDS.
91
+ * The icon set is provided by DDS, and it also supports custom icons via the icon registry.
14
92
  *
15
- * To use an arbitrary color, specify `"current"` for the `color` property and set the `color` CSS property to the color you want to use.
93
+ * For static DDS icons, the component uses the predefined icon set.
94
+ * For custom icons, it can dynamically load icons from various sources using the icon registry.
16
95
  *
17
- * If you try to use an icon that does not exist, a blank space will be displayed.
18
- * In the development build, warnings will be displayed in the console, so please check there if you encounter any unexpected behavior.
96
+ * This component supports multiple rendering modes for enhanced security when using custom icons:
19
97
  *
20
- * @cssprop [--ddc-icon-size] - Icon size. If a value other than "current" is set for the `size` property, it will be overwritten automatically. This may be set by the parent component such as `daikin-icon-button`.
98
+ * - **mask** (default for custom icons): Uses CSS mask-image for secure rendering with color customization
99
+ * - **background**: Uses CSS background-image for secure rendering without color customization
100
+ * - **inline**: Traditional SVG rendering using innerHTML (use with caution)
101
+ * - **static** (for DDS icons): Uses predefined CSS classes from the DDS icon set
102
+ *
103
+ * **Security Note**: When using custom icons, especially with `inline` mode, ensure that the SVG content comes from trusted sources only.
104
+ * Untrusted input may lead to XSS vulnerabilities. Consider using `mask` or `background` modes for better security.
105
+ *
106
+ * To use a custom color, set the `color` property to `"current"` and apply the desired color using the CSS `color` property.
107
+ * This works out-of-the-box for mask and static modes, and can be achieved for inline mode with additional effort. The background mode does not support custom colors.
108
+ *
109
+ * If an icon cannot be loaded, a blank space will be displayed.
110
+ * In development builds, warnings will be shown in the console for debugging.
111
+ *
112
+ * @cssprop [--ddc-icon-size] - Icon size. If a value other than "current" is set for the `size` property, it will be automatically overwritten. This may also be set by a parent component such as `daikin-icon-button`.
21
113
  *
22
114
  * @example
23
115
  *
@@ -26,15 +118,51 @@ export type IconVariantProps = MergeVariantProps<typeof cvaIcon>;
26
118
  * ```
27
119
  *
28
120
  * ```html
121
+ * <!-- Using a DDS static icon -->
29
122
  * <daikin-icon icon="information" color="black" size="m"></daikin-icon>
123
+ *
124
+ * <!-- Using a custom icon -->
125
+ * <daikin-icon icon="my-custom-icon" color="black" size="m"></daikin-icon>
126
+ *
127
+ * <script>
128
+ * import { iconRegistry } from "@daikin-oss/design-system-web-components/icon-registry.js";
129
+ *
130
+ * // Register with mask mode for secure rendering
131
+ * iconRegistry.register({
132
+ * name: "my-custom-icon",
133
+ * svg: {
134
+ * svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">...</svg>',
135
+ * mode: "mask",
136
+ * defaultColor: "#0066cc"
137
+ * },
138
+ * });
139
+ *
140
+ * // Register dynamic custom icons
141
+ * iconRegistry.register({
142
+ * match: /^custom-/,
143
+ * async fetch: (name) => {
144
+ * const response = await fetch(`/path/to/custom/icons/${name}.svg`);
145
+ * if (!response.ok) {
146
+ * throw new Error(`Failed to load custom icon "${name}"`);
147
+ * }
148
+ * return response.text();
149
+ * },
150
+ * });
151
+ * </script>
30
152
  * ```
31
153
  */
32
154
  export declare class DaikinIcon extends DDSElement {
33
155
  static readonly styles: import('lit').CSSResult;
34
156
  /**
35
- * Specify the name of the icon
157
+ * Specify icon registry instance.
158
+ * Default is the global icon registry.
159
+ */
160
+ registry: IconRegistry;
161
+ /**
162
+ * Specify the name of the icon.
163
+ * Can be a static DDS icon name or a custom icon name registered in the icon registry.
36
164
  */
37
- icon: IconType | null;
165
+ icon: string | null;
38
166
  /**
39
167
  * Specify icon color
40
168
  */
@@ -44,6 +172,10 @@ export declare class DaikinIcon extends DDSElement {
44
172
  * If "current" is set, `--ddc-icon-size` CSS variable will be used. `--ddc-icon-size` may be set by the parent component such as `daikin-icon-button`.
45
173
  */
46
174
  size: "s" | "m" | "l" | "xl" | "current";
175
+ private _iconData;
176
+ connectedCallback(): void;
177
+ updated(changedProperties: Map<string, unknown>): void;
178
+ private loadIcon;
47
179
  render(): import('lit-html').TemplateResult<1>;
48
180
  }
49
181
  declare global {
@@ -1,11 +1,13 @@
1
1
  import { cva } from "class-variance-authority";
2
2
  import { unsafeCSS, css, html } from "lit";
3
- import { property } from "lit/decorators.js";
3
+ import { property, state } from "lit/decorators.js";
4
+ import { unsafeHTML } from "lit/directives/unsafe-html.js";
4
5
  import { DDSElement } from "../../base/dds-element.js";
5
6
  import { ddsElement } from "../../base/decorators.js";
6
7
  import "../../base/define.js";
8
+ import { iconRegistry } from "../../icon-registry.js";
7
9
  import tailwindStyles from "../../tailwind.css.js";
8
- import { icons } from "./icons.json.js";
10
+ import iconsJson from "./icons.json.js";
9
11
  var __defProp = Object.defineProperty;
10
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
13
  var __decorateClass = (decorators, target, key, kind) => {
@@ -16,38 +18,135 @@ var __decorateClass = (decorators, target, key, kind) => {
16
18
  if (kind && result) __defProp(target, key, result);
17
19
  return result;
18
20
  };
19
- const iconList = Object.keys(icons);
20
- const iconClassMap = Object.fromEntries(
21
- Object.entries(icons).map(([name, object]) => [name, object.class])
21
+ const { icons } = iconsJson;
22
+ const iconList = Object.keys(icons).filter(
23
+ (key) => key !== "logo-positive" && key !== "logo-negative"
22
24
  );
23
- const cvaIcon = cva(["block"], {
25
+ function svgToDataUrl(svg) {
26
+ const encoded = encodeURIComponent(svg).replaceAll("'", "%27");
27
+ return `url("data:image/svg+xml,${encoded}")`;
28
+ }
29
+ const cvaIcon = cva(["inline-flex size-full"], {
24
30
  variants: {
25
- icon: iconClassMap,
26
31
  color: {
27
32
  black: ["text-ddt-color-common-background-overlay"],
28
33
  white: ["text-ddt-color-common-text-inverse"],
29
34
  default: ["text-[--default-color]"],
30
35
  current: []
31
36
  // uses `currentColor`
37
+ },
38
+ mode: {
39
+ inline: [],
40
+ mask: [
41
+ "bg-current",
42
+ "[mask-size:100%_100%]",
43
+ "[-webkit-mask-size:100%_100%]",
44
+ "[mask-repeat:no-repeat]",
45
+ "[-webkit-mask-repeat:no-repeat]",
46
+ "[mask-image:var(--svg)]",
47
+ "[-webkit-mask-image:var(--svg)]"
48
+ ],
49
+ background: [
50
+ "bg-no-repeat",
51
+ "bg-[length:100%_100%]",
52
+ "bg-[image:var(--svg)]"
53
+ ],
54
+ static: []
55
+ // for static icons from icons.json
32
56
  }
33
57
  }
34
58
  });
35
59
  let DaikinIcon = class extends DDSElement {
36
60
  constructor() {
37
61
  super(...arguments);
62
+ this.registry = iconRegistry;
38
63
  this.icon = null;
39
64
  this.color = "default";
40
65
  this.size = "current";
66
+ this._iconData = null;
67
+ }
68
+ connectedCallback() {
69
+ super.connectedCallback();
70
+ this.loadIcon().catch((error) => {
71
+ });
72
+ }
73
+ updated(changedProperties) {
74
+ if (changedProperties.has("icon")) {
75
+ this.loadIcon().catch((error) => {
76
+ });
77
+ }
78
+ }
79
+ async loadIcon() {
80
+ if (!this.icon) {
81
+ this._iconData = null;
82
+ return;
83
+ }
84
+ const staticIcon = icons[this.icon];
85
+ if (staticIcon) {
86
+ this._iconData = {
87
+ mode: "static",
88
+ defaultColor: staticIcon.color,
89
+ class: staticIcon.class
90
+ };
91
+ return;
92
+ }
93
+ try {
94
+ const iconData = await this.registry.getIcon(this.icon);
95
+ if (false) ;
96
+ this._iconData = iconData;
97
+ } catch (error) {
98
+ this._iconData = null;
99
+ }
41
100
  }
42
101
  render() {
43
- var _a;
44
- const defaultColor = (_a = icons[this.icon ?? ""]) == null ? void 0 : _a.color;
102
+ if (!this.icon) {
103
+ return html`<span
104
+ class=${cvaIcon({
105
+ color: this.color,
106
+ mode: "static"
107
+ })}
108
+ title="Unknown icon"
109
+ ></span>`;
110
+ }
111
+ if (!this._iconData) {
112
+ return html`<span
113
+ class=${cvaIcon({
114
+ color: this.color,
115
+ mode: "inline"
116
+ })}
117
+ title=${this.icon || "Unknown icon"}
118
+ ></span>`;
119
+ }
120
+ const defaultColor = this._iconData.defaultColor;
121
+ if (this._iconData.mode === "static") {
122
+ return html`<span
123
+ class="${cvaIcon({
124
+ color: this.color,
125
+ mode: "static"
126
+ })} ${this._iconData.class}"
127
+ style=${`--default-color:${defaultColor ?? "#000000"}`}
128
+ role="presentation"
129
+ ></span>`;
130
+ }
131
+ const mode = this._iconData.mode ?? "mask";
132
+ if (mode === "inline") {
133
+ return html`<span
134
+ class=${cvaIcon({
135
+ color: this.color,
136
+ mode
137
+ })}
138
+ style=${`--default-color:${defaultColor ?? "#000000"}`}
139
+ role="presentation"
140
+ >${unsafeHTML(this._iconData.svg)}</span
141
+ >`;
142
+ }
143
+ const svgDataUrl = svgToDataUrl(this._iconData.svg);
45
144
  return html`<span
46
145
  class=${cvaIcon({
47
- icon: this.icon,
48
- color: this.color
146
+ color: this.color,
147
+ mode
49
148
  })}
50
- style=${`--default-color:${defaultColor ?? "#000000"}`}
149
+ style=${`--default-color:${defaultColor ?? "#000000"};--svg:${svgDataUrl}`}
51
150
  role="presentation"
52
151
  ></span>`;
53
152
  }
@@ -56,7 +155,7 @@ DaikinIcon.styles = css`
56
155
  ${unsafeCSS(tailwindStyles)}
57
156
 
58
157
  :host {
59
- display: inline-block;
158
+ display: inline-flex;
60
159
  width: var(--ddc-icon-size, 100%);
61
160
  height: var(--ddc-icon-size, 100%);
62
161
  }
@@ -77,6 +176,9 @@ DaikinIcon.styles = css`
77
176
  --ddc-icon-size: 24px;
78
177
  }
79
178
  `;
179
+ __decorateClass([
180
+ property({ attribute: false })
181
+ ], DaikinIcon.prototype, "registry", 2);
80
182
  __decorateClass([
81
183
  property({ type: String, reflect: true })
82
184
  ], DaikinIcon.prototype, "icon", 2);
@@ -86,6 +188,9 @@ __decorateClass([
86
188
  __decorateClass([
87
189
  property({ type: String, reflect: true })
88
190
  ], DaikinIcon.prototype, "size", 2);
191
+ __decorateClass([
192
+ state()
193
+ ], DaikinIcon.prototype, "_iconData", 2);
89
194
  DaikinIcon = __decorateClass([
90
195
  ddsElement("daikin-icon")
91
196
  ], DaikinIcon);