@ncds/ui-admin 1.8.4 → 1.8.6

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 (187) hide show
  1. package/dist/cjs/assets/scripts/featuredIcon.js +87 -0
  2. package/dist/cjs/assets/scripts/notification/FloatingNotification.js +178 -0
  3. package/dist/cjs/assets/scripts/notification/FullWidthNotification.js +133 -0
  4. package/dist/cjs/assets/scripts/notification/MessageNotification.js +159 -0
  5. package/dist/cjs/assets/scripts/notification/Notification.js +120 -0
  6. package/dist/cjs/assets/scripts/notification/const/classNames.js +50 -0
  7. package/dist/cjs/assets/scripts/notification/const/icons.js +31 -0
  8. package/dist/cjs/assets/scripts/notification/const/index.js +87 -0
  9. package/dist/cjs/assets/scripts/notification/const/sizes.js +46 -0
  10. package/dist/cjs/assets/scripts/notification/const/types.js +14 -0
  11. package/dist/cjs/assets/scripts/notification/index.js +116 -0
  12. package/dist/cjs/assets/scripts/notification/positionSync.js +180 -0
  13. package/dist/cjs/assets/scripts/notification/utils.js +122 -0
  14. package/dist/cjs/assets/scripts/shared/ButtonCloseX.js +45 -0
  15. package/dist/cjs/assets/scripts/utils/sanitize.js +39 -0
  16. package/dist/cjs/src/components/data-display/data-grid/DataGrid.js +5 -1
  17. package/dist/cjs/src/components/data-display/table/Table.js +118 -96
  18. package/dist/cjs/src/components/data-display/table/useTableScrollbars.js +187 -0
  19. package/dist/cjs/src/components/forms-and-input/combo-box/ComboBox.js +11 -10
  20. package/dist/cjs/src/components/forms-and-input/image-file-input/ImageFileInput.js +5 -2
  21. package/dist/cjs/src/components/forms-and-input/select-box/SelectBox.js +67 -29
  22. package/dist/cjs/src/components/forms-and-input/slider/Slider.js +2 -3
  23. package/dist/cjs/src/components/overlays/dropdown/Dropdown.js +47 -19
  24. package/dist/cjs/src/components/overlays/notification/CalloutNotification.js +25 -0
  25. package/dist/cjs/src/components/overlays/notification/FloatingNotification.js +86 -13
  26. package/dist/cjs/src/components/overlays/notification/Notification.js +7 -0
  27. package/dist/cjs/src/components/overlays/notification/host.js +12 -0
  28. package/dist/cjs/src/components/overlays/tooltip/Tooltip.js +57 -44
  29. package/dist/cjs/src/components/select-dropdown/SelectDropdown.js +2 -1
  30. package/dist/cjs/src/contexts/FloatingContext.js +11 -0
  31. package/dist/cjs/src/contexts/index.js +16 -0
  32. package/dist/cjs/src/hooks/index.js +11 -0
  33. package/dist/cjs/src/hooks/useFloatingPosition.js +78 -0
  34. package/dist/cjs/src/hooks/usePortalState.js +17 -0
  35. package/dist/cjs/src/types/component-meta.js +8 -1
  36. package/dist/cjs/src/utils/dropdown/maxSelection.js +35 -0
  37. package/dist/cjs/src/utils/dropdown/multiSelect.js +72 -15
  38. package/dist/esm/assets/scripts/featuredIcon.js +80 -0
  39. package/dist/esm/assets/scripts/notification/FloatingNotification.js +171 -0
  40. package/dist/esm/assets/scripts/notification/FullWidthNotification.js +126 -0
  41. package/dist/esm/assets/scripts/notification/MessageNotification.js +152 -0
  42. package/dist/esm/assets/scripts/notification/Notification.js +113 -0
  43. package/dist/esm/assets/scripts/notification/const/classNames.js +44 -0
  44. package/dist/esm/assets/scripts/notification/const/icons.js +25 -0
  45. package/dist/esm/assets/scripts/notification/const/index.js +4 -0
  46. package/dist/esm/assets/scripts/notification/const/sizes.js +40 -0
  47. package/dist/esm/assets/scripts/notification/const/types.js +8 -0
  48. package/dist/esm/assets/scripts/notification/index.js +10 -0
  49. package/dist/esm/assets/scripts/notification/positionSync.js +171 -0
  50. package/dist/esm/assets/scripts/notification/utils.js +109 -0
  51. package/dist/esm/assets/scripts/shared/ButtonCloseX.js +37 -0
  52. package/dist/esm/assets/scripts/utils/sanitize.js +31 -0
  53. package/dist/esm/src/components/data-display/data-grid/DataGrid.js +5 -1
  54. package/dist/esm/src/components/data-display/table/Table.js +118 -96
  55. package/dist/esm/src/components/data-display/table/useTableScrollbars.js +179 -0
  56. package/dist/esm/src/components/forms-and-input/combo-box/ComboBox.js +11 -10
  57. package/dist/esm/src/components/forms-and-input/image-file-input/ImageFileInput.js +5 -2
  58. package/dist/esm/src/components/forms-and-input/select-box/SelectBox.js +67 -29
  59. package/dist/esm/src/components/forms-and-input/slider/Slider.js +1 -2
  60. package/dist/esm/src/components/overlays/dropdown/Dropdown.js +47 -19
  61. package/dist/esm/src/components/overlays/notification/CalloutNotification.js +19 -0
  62. package/dist/esm/src/components/overlays/notification/FloatingNotification.js +86 -14
  63. package/dist/esm/src/components/overlays/notification/Notification.js +7 -0
  64. package/dist/esm/src/components/overlays/notification/host.js +9 -0
  65. package/dist/esm/src/components/overlays/tooltip/Tooltip.js +58 -45
  66. package/dist/esm/src/components/select-dropdown/SelectDropdown.js +2 -1
  67. package/dist/esm/src/contexts/FloatingContext.js +4 -0
  68. package/dist/esm/src/contexts/index.js +1 -0
  69. package/dist/esm/src/hooks/index.js +1 -0
  70. package/dist/esm/src/hooks/useFloatingPosition.js +71 -0
  71. package/dist/esm/src/hooks/usePortalState.js +10 -0
  72. package/dist/esm/src/types/component-meta.js +5 -1
  73. package/dist/esm/src/utils/dropdown/maxSelection.js +27 -0
  74. package/dist/esm/src/utils/dropdown/multiSelect.js +70 -14
  75. package/dist/temp/assets/scripts/featuredIcon.d.ts +22 -0
  76. package/dist/temp/assets/scripts/featuredIcon.js +79 -0
  77. package/dist/temp/assets/scripts/notification/FloatingNotification.d.ts +24 -0
  78. package/dist/temp/assets/scripts/notification/FloatingNotification.js +156 -0
  79. package/dist/temp/assets/scripts/notification/FullWidthNotification.d.ts +21 -0
  80. package/dist/temp/assets/scripts/notification/FullWidthNotification.js +111 -0
  81. package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +22 -0
  82. package/dist/temp/assets/scripts/notification/MessageNotification.js +140 -0
  83. package/dist/temp/assets/scripts/notification/Notification.d.ts +22 -0
  84. package/dist/temp/assets/scripts/notification/Notification.js +112 -0
  85. package/dist/temp/assets/scripts/notification/const/classNames.d.ts +43 -0
  86. package/dist/temp/assets/scripts/notification/const/classNames.js +44 -0
  87. package/dist/temp/assets/scripts/notification/const/icons.d.ts +25 -0
  88. package/dist/temp/assets/scripts/notification/const/icons.js +25 -0
  89. package/dist/temp/assets/scripts/notification/const/index.d.ts +5 -0
  90. package/dist/temp/assets/scripts/notification/const/index.js +4 -0
  91. package/dist/temp/assets/scripts/notification/const/sizes.d.ts +32 -0
  92. package/dist/temp/assets/scripts/notification/const/sizes.js +40 -0
  93. package/dist/temp/assets/scripts/notification/const/types.d.ts +19 -0
  94. package/dist/temp/assets/scripts/notification/const/types.js +8 -0
  95. package/dist/temp/assets/scripts/notification/index.d.ts +8 -0
  96. package/dist/temp/assets/scripts/notification/index.js +10 -0
  97. package/dist/temp/assets/scripts/notification/positionSync.d.ts +50 -0
  98. package/dist/temp/assets/scripts/notification/positionSync.js +170 -0
  99. package/dist/temp/assets/scripts/notification/utils.d.ts +8 -0
  100. package/dist/temp/assets/scripts/notification/utils.js +115 -0
  101. package/dist/temp/assets/scripts/shared/ButtonCloseX.d.ts +5 -0
  102. package/dist/temp/assets/scripts/shared/ButtonCloseX.js +33 -0
  103. package/dist/temp/assets/scripts/utils/sanitize.d.ts +22 -0
  104. package/dist/temp/assets/scripts/utils/sanitize.js +31 -0
  105. package/dist/temp/src/components/data-display/data-grid/DataGrid.js +1 -1
  106. package/dist/temp/src/components/data-display/data-grid/DataGrid.types.d.ts +7 -0
  107. package/dist/temp/src/components/data-display/table/Table.d.ts +4 -1
  108. package/dist/temp/src/components/data-display/table/Table.js +53 -68
  109. package/dist/temp/src/components/data-display/table/types.d.ts +18 -0
  110. package/dist/temp/src/components/data-display/table/useTableScrollbars.d.ts +25 -0
  111. package/dist/temp/src/components/data-display/table/useTableScrollbars.js +136 -0
  112. package/dist/temp/src/components/forms-and-input/combo-box/ComboBox.d.ts +8 -0
  113. package/dist/temp/src/components/forms-and-input/combo-box/ComboBox.js +7 -11
  114. package/dist/temp/src/components/forms-and-input/image-file-input/ImageFileInput.js +1 -1
  115. package/dist/temp/src/components/forms-and-input/select-box/SelectBox.d.ts +13 -0
  116. package/dist/temp/src/components/forms-and-input/select-box/SelectBox.js +30 -3
  117. package/dist/temp/src/components/forms-and-input/slider/Slider.d.ts +0 -1
  118. package/dist/temp/src/components/forms-and-input/slider/Slider.js +0 -1
  119. package/dist/temp/src/components/overlays/dropdown/Dropdown.d.ts +5 -0
  120. package/dist/temp/src/components/overlays/dropdown/Dropdown.js +35 -11
  121. package/dist/temp/src/components/overlays/notification/CalloutNotification.d.ts +9 -0
  122. package/dist/temp/src/components/overlays/notification/CalloutNotification.js +6 -0
  123. package/dist/temp/src/components/overlays/notification/FloatingNotification.d.ts +15 -0
  124. package/dist/temp/src/components/overlays/notification/FloatingNotification.js +81 -13
  125. package/dist/temp/src/components/overlays/notification/Notification.d.ts +18 -3
  126. package/dist/temp/src/components/overlays/notification/Notification.js +4 -0
  127. package/dist/temp/src/components/overlays/notification/host.d.ts +9 -0
  128. package/dist/temp/src/components/overlays/notification/host.js +9 -0
  129. package/dist/temp/src/components/overlays/tooltip/Tooltip.d.ts +5 -1
  130. package/dist/temp/src/components/overlays/tooltip/Tooltip.js +25 -22
  131. package/dist/temp/src/components/select-dropdown/SelectDropdown.d.ts +6 -0
  132. package/dist/temp/src/components/select-dropdown/SelectDropdown.js +2 -2
  133. package/dist/temp/src/contexts/FloatingContext.d.ts +6 -0
  134. package/dist/temp/src/contexts/FloatingContext.js +4 -0
  135. package/dist/temp/src/contexts/index.d.ts +1 -0
  136. package/dist/temp/src/contexts/index.js +1 -0
  137. package/dist/temp/src/hooks/index.d.ts +1 -0
  138. package/dist/temp/src/hooks/index.js +1 -0
  139. package/dist/temp/src/hooks/useFloatingPosition.d.ts +19 -0
  140. package/dist/temp/src/hooks/useFloatingPosition.js +55 -0
  141. package/dist/temp/src/hooks/usePortalState.d.ts +6 -0
  142. package/dist/temp/src/hooks/usePortalState.js +7 -0
  143. package/dist/temp/src/types/component-meta.d.ts +6 -2
  144. package/dist/temp/src/types/component-meta.js +14 -1
  145. package/dist/temp/src/utils/dropdown/maxSelection.d.ts +24 -0
  146. package/dist/temp/src/utils/dropdown/maxSelection.js +28 -0
  147. package/dist/temp/src/utils/dropdown/multiSelect.d.ts +42 -2
  148. package/dist/temp/src/utils/dropdown/multiSelect.js +66 -13
  149. package/dist/types/assets/scripts/featuredIcon.d.ts +22 -0
  150. package/dist/types/assets/scripts/notification/FloatingNotification.d.ts +24 -0
  151. package/dist/types/assets/scripts/notification/FullWidthNotification.d.ts +21 -0
  152. package/dist/types/assets/scripts/notification/MessageNotification.d.ts +22 -0
  153. package/dist/types/assets/scripts/notification/Notification.d.ts +22 -0
  154. package/dist/types/assets/scripts/notification/const/classNames.d.ts +43 -0
  155. package/dist/types/assets/scripts/notification/const/icons.d.ts +25 -0
  156. package/dist/types/assets/scripts/notification/const/index.d.ts +5 -0
  157. package/dist/types/assets/scripts/notification/const/sizes.d.ts +32 -0
  158. package/dist/types/assets/scripts/notification/const/types.d.ts +19 -0
  159. package/dist/types/assets/scripts/notification/index.d.ts +8 -0
  160. package/dist/types/assets/scripts/notification/positionSync.d.ts +50 -0
  161. package/dist/types/assets/scripts/notification/utils.d.ts +8 -0
  162. package/dist/types/assets/scripts/shared/ButtonCloseX.d.ts +5 -0
  163. package/dist/types/assets/scripts/utils/sanitize.d.ts +22 -0
  164. package/dist/types/src/components/data-display/data-grid/DataGrid.types.d.ts +7 -0
  165. package/dist/types/src/components/data-display/table/Table.d.ts +4 -1
  166. package/dist/types/src/components/data-display/table/types.d.ts +18 -0
  167. package/dist/types/src/components/data-display/table/useTableScrollbars.d.ts +25 -0
  168. package/dist/types/src/components/forms-and-input/combo-box/ComboBox.d.ts +8 -0
  169. package/dist/types/src/components/forms-and-input/select-box/SelectBox.d.ts +13 -0
  170. package/dist/types/src/components/forms-and-input/slider/Slider.d.ts +0 -1
  171. package/dist/types/src/components/overlays/dropdown/Dropdown.d.ts +5 -0
  172. package/dist/types/src/components/overlays/notification/CalloutNotification.d.ts +9 -0
  173. package/dist/types/src/components/overlays/notification/FloatingNotification.d.ts +15 -0
  174. package/dist/types/src/components/overlays/notification/Notification.d.ts +18 -3
  175. package/dist/types/src/components/overlays/notification/host.d.ts +9 -0
  176. package/dist/types/src/components/overlays/tooltip/Tooltip.d.ts +5 -1
  177. package/dist/types/src/components/select-dropdown/SelectDropdown.d.ts +6 -0
  178. package/dist/types/src/contexts/FloatingContext.d.ts +6 -0
  179. package/dist/types/src/contexts/index.d.ts +1 -0
  180. package/dist/types/src/hooks/index.d.ts +1 -0
  181. package/dist/types/src/hooks/useFloatingPosition.d.ts +19 -0
  182. package/dist/types/src/hooks/usePortalState.d.ts +6 -0
  183. package/dist/types/src/types/component-meta.d.ts +6 -2
  184. package/dist/types/src/utils/dropdown/maxSelection.d.ts +24 -0
  185. package/dist/types/src/utils/dropdown/multiSelect.d.ts +42 -2
  186. package/dist/ui-admin/assets/styles/style.css +312 -64
  187. package/package.json +1 -1
@@ -2,8 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { ChevronDown } from '@ncds/ui-admin-icon';
3
3
  import classNames from 'classnames';
4
4
  import { forwardRef, useCallback, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
5
+ import { createPortal } from 'react-dom';
5
6
  import { COLOR } from '../../../../constant/color';
6
7
  import { useDropdown, useScrollLock } from '../../../hooks/dropdown';
8
+ import { useFloatingPosition } from '../../../hooks/useFloatingPosition';
9
+ import { usePortalState } from '../../../hooks/usePortalState';
7
10
  import { useMultiSelect } from '../../../utils/dropdown/multiSelect';
8
11
  import { Tag } from '../../feedback-and-status/tag';
9
12
  import { SelectDropdown } from '../../select-dropdown';
@@ -54,7 +57,9 @@ function DisplayValue(_ref) {
54
57
  })]
55
58
  });
56
59
  }
57
- const SelectBox = /*#__PURE__*/forwardRef((_ref2, ref) => {
60
+ const SelectBox = /*#__PURE__*/forwardRef((_ref2, ref
61
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: 옵션/멀티/태그/포탈 등 필수 분기 통합
62
+ ) => {
58
63
  let {
59
64
  placeholder = '선택하세요',
60
65
  disabledPlaceholder = false,
@@ -68,7 +73,9 @@ const SelectBox = /*#__PURE__*/forwardRef((_ref2, ref) => {
68
73
  disabled = false,
69
74
  maxHeight = DEFAULT_MAX_HEIGHT,
70
75
  multiple = false,
76
+ maxSelection,
71
77
  align = 'left',
78
+ usePortal,
72
79
  id,
73
80
  className,
74
81
  children,
@@ -79,6 +86,10 @@ const SelectBox = /*#__PURE__*/forwardRef((_ref2, ref) => {
79
86
  } = _ref2;
80
87
  const internalRef = useRef(null);
81
88
  const dropdownRef = useRef(null);
89
+ const {
90
+ shouldPortal,
91
+ portalContainer
92
+ } = usePortalState(usePortal);
82
93
  const [selectedTags, setSelectedTags] = useState([]);
83
94
  const selectedOption = useMemo(() => {
84
95
  if (multiple) return null;
@@ -92,6 +103,13 @@ const SelectBox = /*#__PURE__*/forwardRef((_ref2, ref) => {
92
103
  }, [multiple, selectedOption, placeholder]);
93
104
  const handleOptionSelect = option => {
94
105
  if (disabled) return;
106
+ if (multiple) {
107
+ const newValue = tryToggle(option.id, Array.isArray(value) ? value : []);
108
+ if (newValue === null) return;
109
+ onChange?.(newValue);
110
+ notifyRegister(register, newValue, multiple);
111
+ return;
112
+ }
95
113
  const newValue = computeNewValue(option, value, multiple);
96
114
  onChange?.(newValue);
97
115
  notifyRegister(register, newValue, multiple);
@@ -134,8 +152,12 @@ const SelectBox = /*#__PURE__*/forwardRef((_ref2, ref) => {
134
152
  buttonText: selectAllButtonText,
135
153
  toggleSelectAll,
136
154
  getSelectedTagsData,
137
- removeTag
138
- } = useMultiSelect(currentSelectedValues, optionItems);
155
+ removeTag,
156
+ isMaxSelectionActive,
157
+ tryToggle
158
+ } = useMultiSelect(currentSelectedValues, optionItems, {
159
+ maxSelection
160
+ });
139
161
  const handleSelectAll = () => {
140
162
  if (!multiple || !onChange) return;
141
163
  const newSelectedValues = toggleSelectAll();
@@ -160,13 +182,53 @@ const SelectBox = /*#__PURE__*/forwardRef((_ref2, ref) => {
160
182
  }
161
183
  };
162
184
  useScrollLock(isOpen, dropdownRef);
185
+ // biome-ignore lint/correctness/useExhaustiveDependencies: optionItems 변경 시 너비 재계산 필요
163
186
  useLayoutEffect(() => {
164
187
  if (autoWidth && isOpen && dropdownRef.current && internalRef.current) {
165
188
  const dropdownWidth = dropdownRef.current.offsetWidth;
166
189
  internalRef.current.style.width = `${dropdownWidth}px`;
167
190
  }
168
191
  }, [autoWidth, isOpen, optionItems]);
192
+ const floatingStyle = useFloatingPosition({
193
+ enabled: shouldPortal,
194
+ isOpen,
195
+ triggerRef: internalRef,
196
+ floatingRef: dropdownRef,
197
+ direction: dropdownDirection,
198
+ align,
199
+ matchTriggerWidth: true
200
+ });
201
+ // biome-ignore lint/style/noNonNullAssertion: forwardRef 패턴에서 internalRef는 항상 존재
169
202
  useImperativeHandle(ref, () => internalRef.current, []);
203
+ const selectDropdownNode = _jsx(SelectDropdown, {
204
+ ref: dropdownRef,
205
+ isOpen: isOpen,
206
+ direction: dropdownDirection,
207
+ size: size,
208
+ options: optionItems,
209
+ value: value,
210
+ focusedIndex: focusedIndex,
211
+ maxHeight: maxHeight,
212
+ listboxId: `selectbox-options-${id || 'default'}`,
213
+ multiple: multiple,
214
+ showFooterButtons: multiple,
215
+ selectAllButtonText: selectAllButtonText,
216
+ showSelectAllAction: !isMaxSelectionActive,
217
+ componentType: "selectbox",
218
+ isKeyboardNavigation: isKeyboardNavigation,
219
+ activeDescendantId: activeDescendantId,
220
+ align: align,
221
+ className: shouldPortal ? 'ncua-select-dropdown--portal' : undefined,
222
+ style: shouldPortal && floatingStyle ? floatingStyle : undefined,
223
+ onOptionSelect: handleDropdownSelect,
224
+ onMouseMove: handleMouseMove,
225
+ onOptionHover: handleOptionHover,
226
+ onSelectAll: handleSelectAll,
227
+ onEdit: handleEdit,
228
+ onComplete: handleComplete,
229
+ children: children
230
+ });
231
+ const portaledDropdown = shouldPortal && portalContainer && isOpen ? /*#__PURE__*/createPortal(selectDropdownNode, portalContainer) : null;
170
232
  return _jsxs(_Fragment, {
171
233
  children: [_jsxs("div", {
172
234
  ref: internalRef,
@@ -205,31 +267,7 @@ const SelectBox = /*#__PURE__*/forwardRef((_ref2, ref) => {
205
267
  'ncua-selectbox__arrow--up': isOpen
206
268
  })
207
269
  })]
208
- }), _jsx(SelectDropdown, {
209
- ref: dropdownRef,
210
- isOpen: isOpen,
211
- direction: dropdownDirection,
212
- size: size,
213
- options: optionItems,
214
- value: value,
215
- focusedIndex: focusedIndex,
216
- maxHeight: maxHeight,
217
- listboxId: `selectbox-options-${id || 'default'}`,
218
- multiple: multiple,
219
- showFooterButtons: multiple,
220
- selectAllButtonText: selectAllButtonText,
221
- componentType: "selectbox",
222
- isKeyboardNavigation: isKeyboardNavigation,
223
- activeDescendantId: activeDescendantId,
224
- align: align,
225
- onOptionSelect: handleDropdownSelect,
226
- onMouseMove: handleMouseMove,
227
- onOptionHover: handleOptionHover,
228
- onSelectAll: handleSelectAll,
229
- onEdit: handleEdit,
230
- onComplete: handleComplete,
231
- children: children
232
- })]
270
+ }), !shouldPortal && selectDropdownNode]
233
271
  }), hintText && _jsx(HintText, {
234
272
  destructive: destructive,
235
273
  className: "ncua-hint-text",
@@ -247,7 +285,7 @@ const SelectBox = /*#__PURE__*/forwardRef((_ref2, ref) => {
247
285
  close: true,
248
286
  onButtonClick: () => handleRemoveTag(tag.id)
249
287
  }, tag.id))
250
- })]
288
+ }), portaledDropdown]
251
289
  });
252
290
  });
253
291
  SelectBox.displayName = 'SelectBox';
@@ -50,5 +50,4 @@ export const Slider = _ref => {
50
50
  ref: containerRef,
51
51
  className: `ncua-slider ${className || ''}`
52
52
  });
53
- };
54
- export default Slider;
53
+ };
@@ -7,6 +7,9 @@ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-sc
7
7
  import { attachClosestEdge, extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
8
8
  import { DotsGrid02, DotsVertical, Eye, EyeOff } from '@ncds/ui-admin-icon';
9
9
  import { useEffect, useLayoutEffect, useRef, useState } from 'react';
10
+ import { createPortal } from 'react-dom';
11
+ import { useFloatingPosition } from '../../../hooks/useFloatingPosition';
12
+ import { usePortalState } from '../../../hooks/usePortalState';
10
13
  import { Button } from '../../action/button';
11
14
  import { applyDraftToItems, arrayReorderByEdge, hasDraftChanged, initDraftState } from './utils';
12
15
  const DROPDOWN_ID_RADIX = 36;
@@ -143,6 +146,7 @@ const SortableConfigItem = _ref => {
143
146
  })]
144
147
  });
145
148
  };
149
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: 액션/설정 두 variant 통합 + drag-and-drop 필수 분기
146
150
  export const Dropdown = props => {
147
151
  const {
148
152
  trigger,
@@ -151,14 +155,28 @@ export const Dropdown = props => {
151
155
  groups,
152
156
  className,
153
157
  opened = false,
154
- closeOnClickOutside = true
158
+ closeOnClickOutside = true,
159
+ usePortal
155
160
  } = props;
156
161
  const variant = props.variant ?? 'action';
157
162
  const closeOnClickItem = variant === 'action' ? props.closeOnClickItem ?? true : false;
158
163
  const [isOpen, setIsOpen] = useState(opened);
159
164
  const dropdownRef = useRef(null);
160
165
  const triggerRef = useRef(null);
166
+ const menuRef = useRef(null);
161
167
  const menuItemsRef = useRef(null);
168
+ const {
169
+ shouldPortal,
170
+ portalContainer
171
+ } = usePortalState(usePortal);
172
+ const floatingStyle = useFloatingPosition({
173
+ enabled: shouldPortal,
174
+ isOpen,
175
+ triggerRef,
176
+ floatingRef: menuRef,
177
+ direction: 'down',
178
+ align
179
+ });
162
180
  const dropdownIdRef = useRef(`ncua-dropdown-${Math.random().toString(DROPDOWN_ID_RADIX).slice(DROPDOWN_ID_SLICE_START, DROPDOWN_ID_SLICE_END)}`);
163
181
  const dropdownId = dropdownIdRef.current;
164
182
  useEffect(() => {
@@ -221,7 +239,10 @@ export const Dropdown = props => {
221
239
  triggerRef.current?.focus();
222
240
  };
223
241
  const handleClickOutside = event => {
224
- if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
242
+ const target = event.target;
243
+ const insideContainer = dropdownRef.current?.contains(target) ?? false;
244
+ const insidePortaledMenu = menuRef.current?.contains(target) ?? false;
245
+ if (!insideContainer && !insidePortaledMenu) {
225
246
  setIsOpen(false);
226
247
  }
227
248
  };
@@ -233,6 +254,7 @@ export const Dropdown = props => {
233
254
  }
234
255
  }
235
256
  };
257
+ // biome-ignore lint/correctness/useExhaustiveDependencies: handleClickOutside는 안정적 참조
236
258
  useEffect(() => {
237
259
  if (closeOnClickOutside) {
238
260
  document.addEventListener('mousedown', handleClickOutside);
@@ -242,6 +264,7 @@ export const Dropdown = props => {
242
264
  }
243
265
  }, [closeOnClickOutside]);
244
266
  // ESC 키로 닫고 trigger로 포커스 복귀
267
+ // biome-ignore lint/correctness/useExhaustiveDependencies: closeAndRestoreFocus는 안정적 참조
245
268
  useEffect(() => {
246
269
  if (!isOpen) return;
247
270
  const handleEsc = event => {
@@ -422,25 +445,30 @@ export const Dropdown = props => {
422
445
  });
423
446
  };
424
447
  const dropdownClasses = ['ncua-dropdown', className, align === 'right' ? 'ncua-dropdown--right' : ''].filter(Boolean).join(' ');
448
+ const menuClasses = ['ncua-dropdown__menu', shouldPortal ? 'ncua-dropdown__menu--portal' : ''].filter(Boolean).join(' ');
449
+ const menuNode = isOpen ? _jsxs("div", {
450
+ ref: menuRef,
451
+ className: menuClasses,
452
+ role: variant === 'config' ? 'dialog' : 'menu',
453
+ "aria-label": variant === 'config' ? '설정' : undefined,
454
+ style: shouldPortal && floatingStyle ? floatingStyle : undefined,
455
+ children: [renderHeader(), _jsx("div", {
456
+ ref: menuItemsRef,
457
+ className: "ncua-dropdown__menu-items",
458
+ children: groups.map(group => {
459
+ // config variant uses draft.order to drive the rendered order
460
+ const orderedItems = variant === 'config' && draft ? draft.order.map(id => group.items.find(i => i.id === id)).filter(i => i !== undefined) : group.items;
461
+ return _jsx("div", {
462
+ className: "ncua-dropdown__group",
463
+ children: orderedItems.map(item => variant === 'config' ? renderConfigItem(item, group.sortable === true) : renderActionItem(item))
464
+ }, group.items[0]?.id);
465
+ })
466
+ }), renderFooter()]
467
+ }) : null;
468
+ const portaledMenu = shouldPortal && portalContainer && menuNode ? /*#__PURE__*/createPortal(menuNode, portalContainer) : null;
425
469
  return _jsxs("div", {
426
470
  className: dropdownClasses,
427
471
  ref: dropdownRef,
428
- children: [renderTrigger(), isOpen && _jsxs("div", {
429
- className: "ncua-dropdown__menu",
430
- role: variant === 'config' ? 'dialog' : 'menu',
431
- "aria-label": variant === 'config' ? '설정' : undefined,
432
- children: [renderHeader(), _jsx("div", {
433
- ref: menuItemsRef,
434
- className: "ncua-dropdown__menu-items",
435
- children: groups.map(group => {
436
- // config variant uses draft.order to drive the rendered order
437
- const orderedItems = variant === 'config' && draft ? draft.order.map(id => group.items.find(i => i.id === id)).filter(i => i !== undefined) : group.items;
438
- return _jsx("div", {
439
- className: "ncua-dropdown__group",
440
- children: orderedItems.map(item => variant === 'config' ? renderConfigItem(item, group.sortable === true) : renderActionItem(item))
441
- }, group.items[0]?.id);
442
- })
443
- }), renderFooter()]
444
- })]
472
+ children: [renderTrigger(), !shouldPortal && menuNode, portaledMenu]
445
473
  });
446
474
  };
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import classNames from 'classnames';
3
+ import { forwardRef } from 'react';
4
+ const CalloutNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
5
+ let {
6
+ color = 'neutral',
7
+ className,
8
+ title,
9
+ ...rest
10
+ } = _ref;
11
+ return _jsx("div", {
12
+ ref: ref,
13
+ className: classNames('ncua-callout-notification', `ncua-callout-notification--${color}`, className),
14
+ ...rest,
15
+ children: title
16
+ });
17
+ });
18
+ CalloutNotification.displayName = 'CalloutNotification';
19
+ export { CalloutNotification };
@@ -1,19 +1,64 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AlertCircle, AlertTriangle, CheckCircle, Pin02 } from '@ncds/ui-admin-icon';
3
3
  import classNames from 'classnames';
4
- import { forwardRef, useEffect, useRef, useState } from 'react';
4
+ import { forwardRef, useEffect, useId, useRef, useState } from 'react';
5
+ import { createPortal } from 'react-dom';
5
6
  import { MEDIA_QUERY } from '../../../constant/breakpoint';
6
7
  import { useMediaQuery } from '../../../hooks/useMediaQuery';
7
8
  import { Button } from '../../action/button';
8
9
  import { ButtonCloseX } from '../../action/button/ButtonCloseX';
9
10
  import { FeaturedIcon } from '../../image-and-icons/featured-icon/FeaturedIcon';
11
+ // 호스트 싱글톤은 vanilla/React 양쪽이 동일한 함수를 공유한다 — host.ts 가 가까운 진입점 역할을
12
+ // 하므로 React 컴포넌트는 deep relative path 로 vanilla internals 를 직접 import 하지 않는다.
13
+ import { mountFloatingNotificationHost } from './host';
14
+ /**
15
+ * 색상별 a11y role.
16
+ * - error/warning → role="alert" (implicit aria-live="assertive": 즉시 발화)
17
+ * - 그 외 → role="status" (implicit aria-live="polite": 현재 발화 끝난 후 발화)
18
+ * role 이 implicit live-region 을 가져오므로 호스트 컨테이너에는 aria-live 를 두지 않는다.
19
+ */
20
+ const ASSERTIVE_COLORS = {
21
+ error: true,
22
+ warning: true
23
+ };
10
24
  const iconMap = {
11
25
  neutral: Pin02,
12
26
  error: AlertTriangle,
13
27
  warning: AlertCircle,
14
28
  success: CheckCircle
15
- // info는 floating에서는 지원하지 않음
29
+ // info full-width 전용이라 floating 아이콘 매핑 없음.
30
+ };
31
+ /**
32
+ * NotificationColor → FeaturedIconColor 매핑.
33
+ * `info` 는 FeaturedIconColor 에 존재하지 않으므로 `neutral` 로 안전 fallback.
34
+ * `satisfies` 가 매핑 누락을 컴파일 타임에 강제하므로 향후 색상이 추가되면 즉시 타입 에러로 잡힌다.
35
+ */
36
+ const iconColorMap = {
37
+ neutral: 'neutral',
38
+ error: 'error',
39
+ warning: 'warning',
40
+ success: 'success',
41
+ info: 'neutral'
16
42
  };
43
+ /**
44
+ * `.ncua-floating-notification-host` 싱글톤을 보장하고 반환하는 훅.
45
+ *
46
+ * 이름의 `useMount...` 는 단순 조회가 아닌 **DOM 부수효과** 를 동반함을 신호한다 —
47
+ * 내부적으로 `mountFloatingNotificationHost()` 를 호출해 document.body 에 호스트를 append 하고
48
+ * (없으면) 글로벌 scroll/resize/MutationObserver 까지 부착한다. 호스트는 페이지 lifetime
49
+ * 싱글톤이므로 언마운트 시 제거하지 않는다.
50
+ *
51
+ * `mountFloatingNotificationHost` 는 **동기 함수** 이므로 effect 안의 호출 → setHost 가 같은 tick
52
+ * 에 끝나 cancellation race 가 없다. cancel flag 는 의미 없어 두지 않는다.
53
+ */
54
+ function useMountFloatingNotificationHost(enabled) {
55
+ const [host, setHost] = useState(null);
56
+ useEffect(() => {
57
+ if (!enabled) return;
58
+ setHost(mountFloatingNotificationHost());
59
+ }, [enabled]);
60
+ return host;
61
+ }
17
62
  const FloatingNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
18
63
  let {
19
64
  title,
@@ -23,49 +68,65 @@ const FloatingNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
23
68
  className,
24
69
  actions,
25
70
  autoClose = 0,
71
+ portal = false,
26
72
  ...rest
27
73
  } = _ref;
28
74
  const [shouldRemove, setShouldRemove] = useState(false);
29
- const iconColor = color;
30
75
  const featuredIconProps = {
31
76
  icon: iconMap[color] || Pin02,
32
77
  size: 'sm',
33
- color: iconColor,
78
+ color: iconColorMap[color],
34
79
  theme: 'dark-circle'
35
80
  };
36
81
  const isMobile = useMediaQuery(MEDIA_QUERY.mobile, {
37
82
  onMatched: onClose
38
83
  });
84
+ // onClose 는 매 렌더 새 함수 ref 일 수 있으므로 ref 로 latest 만 보관.
85
+ // → autoClose 타이머 effect 의 deps 에서 onClose 를 빼서 타이머 재시작 회피.
86
+ // render 본문에서 직접 할당 — useEffect 로 미루면 같은 commit 안에서 fire 되는 타이머가 stale onClose 를 볼 위험.
87
+ const onCloseRef = useRef(onClose);
88
+ onCloseRef.current = onClose;
39
89
  // autoClose 타이머 관리
40
90
  const timerRef = useRef(null);
91
+ // onClose 는 onCloseRef 로 latest 만 추적하므로 deps 에서 제외 (의도된 패턴).
41
92
  useEffect(() => {
42
- // autoClose가 0보다 크면 무조건 타이머 설정
93
+ // autoClose 가 0 보다 크면 타이머 설정.
43
94
  if (autoClose > 0) {
44
95
  timerRef.current = setTimeout(() => {
45
- if (onClose) {
46
- onClose();
47
- }
48
- // DOM에서 바로 제거
96
+ onCloseRef.current?.();
97
+ // DOM 에서 바로 제거
49
98
  setShouldRemove(true);
50
99
  }, autoClose);
51
100
  }
52
- // cleanup 함수: 컴포넌트 언마운트 시 타이머 정리
101
+ // cleanup: 컴포넌트 언마운트 또는 autoClose 변경 시 타이머 정리
53
102
  return () => {
54
103
  if (timerRef.current) {
55
104
  clearTimeout(timerRef.current);
56
105
  timerRef.current = null;
57
106
  }
58
107
  };
59
- }, [autoClose, onClose]);
108
+ }, [autoClose]);
109
+ // portal=true 일 때만 호스트가 필요하다.
110
+ const host = useMountFloatingNotificationHost(portal);
111
+ // a11y — 카드 root 의 role 과 제목/본문 ID. 색상에 따라 alert(error/warning) / status(나머지) 로 분기.
112
+ const reactId = useId();
113
+ const titleId = `${reactId}-title`;
114
+ const descId = `${reactId}-desc`;
115
+ const role = ASSERTIVE_COLORS[color] ? 'alert' : 'status';
60
116
  // DOM에서 완전히 제거
61
117
  if (shouldRemove) {
62
118
  return null;
63
119
  }
64
- return _jsxs("div", {
120
+ const card =
121
+ // a11y/예측가능성 — caller 가 className/id 등 일부는 덮어쓸 수 있게 {...rest} 를 먼저 펼치고,
122
+ // role/aria-labelledby/aria-describedby 같은 컴포넌트 본질 prop 은 그 뒤에 두어 우선 적용.
123
+ _jsxs("div", {
124
+ ...rest,
65
125
  ref: ref,
66
126
  className: classNames('ncua-floating-notification', `ncua-floating-notification--${color}`, className),
67
- role: "alert",
68
- ...rest,
127
+ role: role,
128
+ "aria-labelledby": titleId,
129
+ "aria-describedby": supportingText ? descId : undefined,
69
130
  children: [_jsx("div", {
70
131
  className: "ncua-floating-notification__content",
71
132
  children: _jsxs("div", {
@@ -78,10 +139,12 @@ const FloatingNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
78
139
  children: [_jsx("div", {
79
140
  className: "ncua-floating-notification__title-wrapper",
80
141
  children: _jsx("span", {
142
+ id: titleId,
81
143
  className: "ncua-floating-notification__title",
82
144
  children: title
83
145
  })
84
146
  }), supportingText && _jsx("span", {
147
+ id: descId,
85
148
  className: "ncua-floating-notification__supporting-text",
86
149
  children: supportingText
87
150
  }), actions && _jsx("div", {
@@ -102,5 +165,14 @@ const FloatingNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
102
165
  onClick: onClose
103
166
  })]
104
167
  });
168
+ // 기본은 인라인 렌더 — 부모 JSX 트리에 카드를 그대로 둔다.
169
+ if (!portal) {
170
+ return card;
171
+ }
172
+ // portal=true 인데 SSR이거나 첫 렌더(호스트 미생성)에서는 null. useEffect 후 host 설정되면 재렌더되어 portal 마운트.
173
+ if (!host) {
174
+ return null;
175
+ }
176
+ return /*#__PURE__*/createPortal(card, host);
105
177
  });
106
178
  export { FloatingNotification };
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
+ import { CalloutNotification } from './CalloutNotification';
3
4
  import { FloatingNotification } from './FloatingNotification';
4
5
  import { FullWidthNotification } from './FullWidthNotification';
5
6
  import { MessageNotification } from './MessageNotification';
@@ -30,6 +31,12 @@ const Notification = /*#__PURE__*/forwardRef((_ref, ref) => {
30
31
  ref: ref
31
32
  });
32
33
  }
34
+ if (type === 'callout') {
35
+ return _jsx(CalloutNotification, {
36
+ color: color,
37
+ ...rest
38
+ });
39
+ }
33
40
  return null;
34
41
  });
35
42
  Notification.displayName = 'Notification';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Floating Notification 호스트 관리 — React 측 진입점.
3
+ *
4
+ * 실제 구현은 vanilla/React 가 공유하는 `assets/scripts/notification/positionSync.ts` 에 있고,
5
+ * 외부 노출은 그 폴더의 public barrel(`assets/scripts/notification/index.ts`)이 담당한다.
6
+ * 이 모듈은 React 컴포넌트가 vanilla 내부 파일을 직접 참조하지 않도록 barrel 을 경유하는
7
+ * 한 단계 re-export 만 제공한다 — positionSync.ts 의 위치/이름이 바뀌어도 host.ts 만 영향.
8
+ */
9
+ export { mountFloatingNotificationHost } from '../../../../assets/scripts/notification';