@ncds/ui-admin 1.8.4 → 1.8.5

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 (177) 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/overlays/dropdown/Dropdown.js +47 -19
  23. package/dist/cjs/src/components/overlays/notification/CalloutNotification.js +25 -0
  24. package/dist/cjs/src/components/overlays/notification/FloatingNotification.js +86 -13
  25. package/dist/cjs/src/components/overlays/notification/Notification.js +7 -0
  26. package/dist/cjs/src/components/overlays/notification/host.js +12 -0
  27. package/dist/cjs/src/components/overlays/tooltip/Tooltip.js +57 -44
  28. package/dist/cjs/src/components/select-dropdown/SelectDropdown.js +2 -1
  29. package/dist/cjs/src/contexts/FloatingContext.js +11 -0
  30. package/dist/cjs/src/contexts/index.js +16 -0
  31. package/dist/cjs/src/hooks/index.js +11 -0
  32. package/dist/cjs/src/hooks/useFloatingPosition.js +78 -0
  33. package/dist/cjs/src/hooks/usePortalState.js +17 -0
  34. package/dist/cjs/src/utils/dropdown/maxSelection.js +35 -0
  35. package/dist/cjs/src/utils/dropdown/multiSelect.js +72 -15
  36. package/dist/esm/assets/scripts/featuredIcon.js +80 -0
  37. package/dist/esm/assets/scripts/notification/FloatingNotification.js +171 -0
  38. package/dist/esm/assets/scripts/notification/FullWidthNotification.js +126 -0
  39. package/dist/esm/assets/scripts/notification/MessageNotification.js +152 -0
  40. package/dist/esm/assets/scripts/notification/Notification.js +113 -0
  41. package/dist/esm/assets/scripts/notification/const/classNames.js +44 -0
  42. package/dist/esm/assets/scripts/notification/const/icons.js +25 -0
  43. package/dist/esm/assets/scripts/notification/const/index.js +4 -0
  44. package/dist/esm/assets/scripts/notification/const/sizes.js +40 -0
  45. package/dist/esm/assets/scripts/notification/const/types.js +8 -0
  46. package/dist/esm/assets/scripts/notification/index.js +10 -0
  47. package/dist/esm/assets/scripts/notification/positionSync.js +171 -0
  48. package/dist/esm/assets/scripts/notification/utils.js +109 -0
  49. package/dist/esm/assets/scripts/shared/ButtonCloseX.js +37 -0
  50. package/dist/esm/assets/scripts/utils/sanitize.js +31 -0
  51. package/dist/esm/src/components/data-display/data-grid/DataGrid.js +5 -1
  52. package/dist/esm/src/components/data-display/table/Table.js +118 -96
  53. package/dist/esm/src/components/data-display/table/useTableScrollbars.js +179 -0
  54. package/dist/esm/src/components/forms-and-input/combo-box/ComboBox.js +11 -10
  55. package/dist/esm/src/components/forms-and-input/image-file-input/ImageFileInput.js +5 -2
  56. package/dist/esm/src/components/forms-and-input/select-box/SelectBox.js +67 -29
  57. package/dist/esm/src/components/overlays/dropdown/Dropdown.js +47 -19
  58. package/dist/esm/src/components/overlays/notification/CalloutNotification.js +19 -0
  59. package/dist/esm/src/components/overlays/notification/FloatingNotification.js +86 -14
  60. package/dist/esm/src/components/overlays/notification/Notification.js +7 -0
  61. package/dist/esm/src/components/overlays/notification/host.js +9 -0
  62. package/dist/esm/src/components/overlays/tooltip/Tooltip.js +58 -45
  63. package/dist/esm/src/components/select-dropdown/SelectDropdown.js +2 -1
  64. package/dist/esm/src/contexts/FloatingContext.js +4 -0
  65. package/dist/esm/src/contexts/index.js +1 -0
  66. package/dist/esm/src/hooks/index.js +1 -0
  67. package/dist/esm/src/hooks/useFloatingPosition.js +71 -0
  68. package/dist/esm/src/hooks/usePortalState.js +10 -0
  69. package/dist/esm/src/utils/dropdown/maxSelection.js +27 -0
  70. package/dist/esm/src/utils/dropdown/multiSelect.js +70 -14
  71. package/dist/temp/assets/scripts/featuredIcon.d.ts +22 -0
  72. package/dist/temp/assets/scripts/featuredIcon.js +79 -0
  73. package/dist/temp/assets/scripts/notification/FloatingNotification.d.ts +24 -0
  74. package/dist/temp/assets/scripts/notification/FloatingNotification.js +156 -0
  75. package/dist/temp/assets/scripts/notification/FullWidthNotification.d.ts +21 -0
  76. package/dist/temp/assets/scripts/notification/FullWidthNotification.js +111 -0
  77. package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +22 -0
  78. package/dist/temp/assets/scripts/notification/MessageNotification.js +140 -0
  79. package/dist/temp/assets/scripts/notification/Notification.d.ts +22 -0
  80. package/dist/temp/assets/scripts/notification/Notification.js +112 -0
  81. package/dist/temp/assets/scripts/notification/const/classNames.d.ts +43 -0
  82. package/dist/temp/assets/scripts/notification/const/classNames.js +44 -0
  83. package/dist/temp/assets/scripts/notification/const/icons.d.ts +25 -0
  84. package/dist/temp/assets/scripts/notification/const/icons.js +25 -0
  85. package/dist/temp/assets/scripts/notification/const/index.d.ts +5 -0
  86. package/dist/temp/assets/scripts/notification/const/index.js +4 -0
  87. package/dist/temp/assets/scripts/notification/const/sizes.d.ts +32 -0
  88. package/dist/temp/assets/scripts/notification/const/sizes.js +40 -0
  89. package/dist/temp/assets/scripts/notification/const/types.d.ts +19 -0
  90. package/dist/temp/assets/scripts/notification/const/types.js +8 -0
  91. package/dist/temp/assets/scripts/notification/index.d.ts +8 -0
  92. package/dist/temp/assets/scripts/notification/index.js +10 -0
  93. package/dist/temp/assets/scripts/notification/positionSync.d.ts +50 -0
  94. package/dist/temp/assets/scripts/notification/positionSync.js +170 -0
  95. package/dist/temp/assets/scripts/notification/utils.d.ts +8 -0
  96. package/dist/temp/assets/scripts/notification/utils.js +115 -0
  97. package/dist/temp/assets/scripts/shared/ButtonCloseX.d.ts +5 -0
  98. package/dist/temp/assets/scripts/shared/ButtonCloseX.js +33 -0
  99. package/dist/temp/assets/scripts/utils/sanitize.d.ts +22 -0
  100. package/dist/temp/assets/scripts/utils/sanitize.js +31 -0
  101. package/dist/temp/src/components/data-display/data-grid/DataGrid.js +1 -1
  102. package/dist/temp/src/components/data-display/data-grid/DataGrid.types.d.ts +7 -0
  103. package/dist/temp/src/components/data-display/table/Table.d.ts +4 -1
  104. package/dist/temp/src/components/data-display/table/Table.js +53 -68
  105. package/dist/temp/src/components/data-display/table/types.d.ts +18 -0
  106. package/dist/temp/src/components/data-display/table/useTableScrollbars.d.ts +25 -0
  107. package/dist/temp/src/components/data-display/table/useTableScrollbars.js +136 -0
  108. package/dist/temp/src/components/forms-and-input/combo-box/ComboBox.d.ts +8 -0
  109. package/dist/temp/src/components/forms-and-input/combo-box/ComboBox.js +7 -11
  110. package/dist/temp/src/components/forms-and-input/image-file-input/ImageFileInput.js +1 -1
  111. package/dist/temp/src/components/forms-and-input/select-box/SelectBox.d.ts +13 -0
  112. package/dist/temp/src/components/forms-and-input/select-box/SelectBox.js +30 -3
  113. package/dist/temp/src/components/overlays/dropdown/Dropdown.d.ts +5 -0
  114. package/dist/temp/src/components/overlays/dropdown/Dropdown.js +35 -11
  115. package/dist/temp/src/components/overlays/notification/CalloutNotification.d.ts +9 -0
  116. package/dist/temp/src/components/overlays/notification/CalloutNotification.js +6 -0
  117. package/dist/temp/src/components/overlays/notification/FloatingNotification.d.ts +15 -0
  118. package/dist/temp/src/components/overlays/notification/FloatingNotification.js +81 -13
  119. package/dist/temp/src/components/overlays/notification/Notification.d.ts +18 -3
  120. package/dist/temp/src/components/overlays/notification/Notification.js +4 -0
  121. package/dist/temp/src/components/overlays/notification/host.d.ts +9 -0
  122. package/dist/temp/src/components/overlays/notification/host.js +9 -0
  123. package/dist/temp/src/components/overlays/tooltip/Tooltip.d.ts +5 -1
  124. package/dist/temp/src/components/overlays/tooltip/Tooltip.js +25 -22
  125. package/dist/temp/src/components/select-dropdown/SelectDropdown.d.ts +6 -0
  126. package/dist/temp/src/components/select-dropdown/SelectDropdown.js +2 -2
  127. package/dist/temp/src/contexts/FloatingContext.d.ts +6 -0
  128. package/dist/temp/src/contexts/FloatingContext.js +4 -0
  129. package/dist/temp/src/contexts/index.d.ts +1 -0
  130. package/dist/temp/src/contexts/index.js +1 -0
  131. package/dist/temp/src/hooks/index.d.ts +1 -0
  132. package/dist/temp/src/hooks/index.js +1 -0
  133. package/dist/temp/src/hooks/useFloatingPosition.d.ts +19 -0
  134. package/dist/temp/src/hooks/useFloatingPosition.js +55 -0
  135. package/dist/temp/src/hooks/usePortalState.d.ts +6 -0
  136. package/dist/temp/src/hooks/usePortalState.js +7 -0
  137. package/dist/temp/src/utils/dropdown/maxSelection.d.ts +24 -0
  138. package/dist/temp/src/utils/dropdown/maxSelection.js +28 -0
  139. package/dist/temp/src/utils/dropdown/multiSelect.d.ts +42 -2
  140. package/dist/temp/src/utils/dropdown/multiSelect.js +66 -13
  141. package/dist/types/assets/scripts/featuredIcon.d.ts +22 -0
  142. package/dist/types/assets/scripts/notification/FloatingNotification.d.ts +24 -0
  143. package/dist/types/assets/scripts/notification/FullWidthNotification.d.ts +21 -0
  144. package/dist/types/assets/scripts/notification/MessageNotification.d.ts +22 -0
  145. package/dist/types/assets/scripts/notification/Notification.d.ts +22 -0
  146. package/dist/types/assets/scripts/notification/const/classNames.d.ts +43 -0
  147. package/dist/types/assets/scripts/notification/const/icons.d.ts +25 -0
  148. package/dist/types/assets/scripts/notification/const/index.d.ts +5 -0
  149. package/dist/types/assets/scripts/notification/const/sizes.d.ts +32 -0
  150. package/dist/types/assets/scripts/notification/const/types.d.ts +19 -0
  151. package/dist/types/assets/scripts/notification/index.d.ts +8 -0
  152. package/dist/types/assets/scripts/notification/positionSync.d.ts +50 -0
  153. package/dist/types/assets/scripts/notification/utils.d.ts +8 -0
  154. package/dist/types/assets/scripts/shared/ButtonCloseX.d.ts +5 -0
  155. package/dist/types/assets/scripts/utils/sanitize.d.ts +22 -0
  156. package/dist/types/src/components/data-display/data-grid/DataGrid.types.d.ts +7 -0
  157. package/dist/types/src/components/data-display/table/Table.d.ts +4 -1
  158. package/dist/types/src/components/data-display/table/types.d.ts +18 -0
  159. package/dist/types/src/components/data-display/table/useTableScrollbars.d.ts +25 -0
  160. package/dist/types/src/components/forms-and-input/combo-box/ComboBox.d.ts +8 -0
  161. package/dist/types/src/components/forms-and-input/select-box/SelectBox.d.ts +13 -0
  162. package/dist/types/src/components/overlays/dropdown/Dropdown.d.ts +5 -0
  163. package/dist/types/src/components/overlays/notification/CalloutNotification.d.ts +9 -0
  164. package/dist/types/src/components/overlays/notification/FloatingNotification.d.ts +15 -0
  165. package/dist/types/src/components/overlays/notification/Notification.d.ts +18 -3
  166. package/dist/types/src/components/overlays/notification/host.d.ts +9 -0
  167. package/dist/types/src/components/overlays/tooltip/Tooltip.d.ts +5 -1
  168. package/dist/types/src/components/select-dropdown/SelectDropdown.d.ts +6 -0
  169. package/dist/types/src/contexts/FloatingContext.d.ts +6 -0
  170. package/dist/types/src/contexts/index.d.ts +1 -0
  171. package/dist/types/src/hooks/index.d.ts +1 -0
  172. package/dist/types/src/hooks/useFloatingPosition.d.ts +19 -0
  173. package/dist/types/src/hooks/usePortalState.d.ts +6 -0
  174. package/dist/types/src/utils/dropdown/maxSelection.d.ts +24 -0
  175. package/dist/types/src/utils/dropdown/multiSelect.d.ts +42 -2
  176. package/dist/ui-admin/assets/styles/style.css +304 -64
  177. package/package.json +1 -1
@@ -20,6 +20,7 @@ const SelectDropdown = /*#__PURE__*/forwardRef((_ref, ref) => {
20
20
  multiple = false,
21
21
  showFooterButtons = false,
22
22
  selectAllButtonText = '전체 선택',
23
+ showSelectAllAction = true,
23
24
  onSelectAll,
24
25
  onEdit,
25
26
  onComplete,
@@ -85,7 +86,7 @@ const SelectDropdown = /*#__PURE__*/forwardRef((_ref, ref) => {
85
86
  className: "ncua-select-dropdown__footer-buttons",
86
87
  children: [_jsx("div", {
87
88
  className: "ncua-select-dropdown__footer-left",
88
- children: multiple && _jsx(Button, {
89
+ children: multiple && showSelectAllAction && _jsx(Button, {
89
90
  label: selectAllButtonText,
90
91
  hierarchy: "text",
91
92
  size: "xs",
@@ -0,0 +1,4 @@
1
+ import { createContext, useContext } from 'react';
2
+ const FloatingContext = /*#__PURE__*/createContext(null);
3
+ export const FloatingProvider = FloatingContext.Provider;
4
+ export const useFloatingContext = () => useContext(FloatingContext);
@@ -0,0 +1 @@
1
+ export * from './FloatingContext';
@@ -2,5 +2,6 @@
2
2
  // 드롭다운 관련 hooks
3
3
  export * from './dropdown';
4
4
  export * from './useCallbackRef';
5
+ export * from './useFloatingPosition';
5
6
  export * from './useMediaQuery';
6
7
  export * from './useMergeRefs';
@@ -0,0 +1,71 @@
1
+ import { useLayoutEffect, useState } from 'react';
2
+ const FLOATING_Z_INDEX = 1500;
3
+ export const useFloatingPosition = _ref => {
4
+ let {
5
+ enabled,
6
+ isOpen,
7
+ triggerRef,
8
+ floatingRef,
9
+ direction,
10
+ offset = 4,
11
+ align = 'left',
12
+ matchTriggerWidth = false
13
+ } = _ref;
14
+ const [style, setStyle] = useState(null);
15
+ useLayoutEffect(() => {
16
+ if (!enabled || !isOpen) {
17
+ setStyle(null);
18
+ return;
19
+ }
20
+ const trigger = triggerRef.current;
21
+ if (!trigger) return;
22
+ const calculatePosition = (trigger, floatingHeight, floatingWidth) => {
23
+ const top = direction === 'up' ? trigger.top - floatingHeight - offset : trigger.bottom + offset;
24
+ const left = align === 'right' ? trigger.right - floatingWidth : trigger.left;
25
+ return {
26
+ top,
27
+ left
28
+ };
29
+ };
30
+ const update = () => {
31
+ const t = triggerRef.current;
32
+ const f = floatingRef.current;
33
+ if (!t) return;
34
+ const r = t.getBoundingClientRect();
35
+ const floatingHeight = f?.offsetHeight ?? 0;
36
+ const floatingWidth = matchTriggerWidth ? r.width : f?.offsetWidth ?? r.width;
37
+ const {
38
+ top,
39
+ left
40
+ } = calculatePosition(r, floatingHeight, floatingWidth);
41
+ // matchTriggerWidth=true: width는 max-content(콘텐츠 자연 너비), min-width만 trigger 너비로 보장.
42
+ // 옵션이 짧으면 trigger 너비, 길면 자연 확장 — 기존 absolute 모드와 동일한 UX.
43
+ setStyle({
44
+ position: 'fixed',
45
+ top,
46
+ left,
47
+ zIndex: FLOATING_Z_INDEX,
48
+ ...(matchTriggerWidth ? {
49
+ minWidth: r.width
50
+ } : {})
51
+ });
52
+ };
53
+ update();
54
+ window.addEventListener('scroll', update, true);
55
+ window.addEventListener('resize', update);
56
+ const triggerObserver = new ResizeObserver(update);
57
+ triggerObserver.observe(trigger);
58
+ let floatingObserver;
59
+ if (floatingRef.current) {
60
+ floatingObserver = new ResizeObserver(update);
61
+ floatingObserver.observe(floatingRef.current);
62
+ }
63
+ return () => {
64
+ window.removeEventListener('scroll', update, true);
65
+ window.removeEventListener('resize', update);
66
+ triggerObserver.disconnect();
67
+ floatingObserver?.disconnect();
68
+ };
69
+ }, [enabled, isOpen, direction, offset, align, matchTriggerWidth, triggerRef, floatingRef]);
70
+ return style;
71
+ };
@@ -0,0 +1,10 @@
1
+ import { useFloatingContext } from '../contexts/FloatingContext';
2
+ export const usePortalState = usePortalProp => {
3
+ const floatingContext = useFloatingContext();
4
+ const shouldPortal = usePortalProp ?? floatingContext?.preferPortal ?? false;
5
+ const portalContainer = floatingContext?.portalContainer ?? (typeof document !== 'undefined' ? document.body : null);
6
+ return {
7
+ shouldPortal,
8
+ portalContainer
9
+ };
10
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * SelectBox / ComboBox 공통 — 최대 선택 개수 제한 활성 여부 판정.
3
+ *
4
+ * React 훅(`useMultiSelect`)과 vanilla 드롭다운(`DropdownModel`)가 동일 로직을 공유하므로
5
+ * 두 곳에 정의가 갈라지지 않도록 단일 source-of-truth로 둔다.
6
+ *
7
+ * **계약**
8
+ * - `0` 이상의 정수 → 활성 (단, `0`은 모든 새 선택을 차단하는 의미)
9
+ * - 음수 / 비정수 / `undefined` / `null` → 비활성 (제한 없는 것과 동일)
10
+ *
11
+ * `0`을 활성으로 보는 이유: 호출자가 `maxSelection={0}`을 명시적으로 전달했을 때
12
+ * "선택 자체를 막겠다"는 의도로 해석하기 위함. 음수는 일반적으로 "값 없음"의 sentinel이므로 비활성.
13
+ */
14
+ export const isMaxSelectionLimitActive = maxSelection => typeof maxSelection === 'number' && Number.isInteger(maxSelection) && maxSelection >= 0;
15
+ /**
16
+ * 현재 선택 길이가 최대치에 도달했는지 단일 함수로 판정.
17
+ *
18
+ * 호출 측에서 `>=`을 직접 작성하지 않도록 의미를 노출하고, type predicate가 내부에서 적용되어
19
+ * `maxSelection`의 narrowing이 보장된다 (외부 predicate 호출로 인한 narrowing 누락 방지).
20
+ *
21
+ * - 제한 비활성(음수 / null / undefined / 비정수): 항상 `false`.
22
+ * - 활성: `currentLength >= maxSelection`.
23
+ */
24
+ export const isMaxSelectionReached = (currentLength, maxSelection) => {
25
+ if (!isMaxSelectionLimitActive(maxSelection)) return false;
26
+ return currentLength >= maxSelection;
27
+ };
@@ -1,3 +1,5 @@
1
+ import { useCallback, useMemo } from 'react';
2
+ import { isMaxSelectionLimitActive, isMaxSelectionReached } from './maxSelection';
1
3
  /**
2
4
  * 전체 선택 상태를 확인하는 유틸 함수
3
5
  */
@@ -44,25 +46,79 @@ export const removeTagFromSelected = (selectedValues, tagIdToRemove) => {
44
46
  return selectedValues.filter(id => id !== tagIdToRemove);
45
47
  };
46
48
  /**
47
- * 전체 선택 관련 로직을 번에 처리하는 커스텀 훅
49
+ * 최대 선택 개수 관련 응집을 별도 훅으로 분리.
50
+ *
51
+ * - `isMaxSelectionActive`: 제한 활성 여부.
52
+ * - `isMaxReached`: 현재 선택 길이가 최대치에 도달했는지.
53
+ * - `canAdd(currentLength)`: 새 항목 추가가 허용되는지 (도달 시 `false`).
54
+ *
55
+ * 도메인 규칙(`>=` 비교 등)을 외부로 노출하지 않고 헬퍼를 통해 의미만 반환한다.
56
+ * `useMultiSelect`가 내부에서 사용하지만, 단독으로도 필요한 호출자가 쓸 수 있게 export한다.
48
57
  */
49
- export const useMultiSelect = (selectedValues, options, selectText, deselectText) => {
58
+ export const useMaxSelection = (selectedValues, maxSelection) => {
59
+ const isMaxSelectionActive = isMaxSelectionLimitActive(maxSelection);
60
+ const isMaxReached = isMaxSelectionReached(selectedValues.length, maxSelection);
61
+ const canAdd = useCallback(currentLength => !isMaxSelectionReached(currentLength, maxSelection), [maxSelection]);
62
+ return {
63
+ isMaxSelectionActive,
64
+ isMaxReached,
65
+ canAdd
66
+ };
67
+ };
68
+ /**
69
+ * 전체 선택 관련 로직을 한 번에 처리하는 커스텀 훅.
70
+ *
71
+ * 시그니처는 호출자가 maxSelection만 지정하더라도 텍스트 라벨을 건너뛰지 않도록 옵션 객체로 받는다.
72
+ *
73
+ * **반환의 `tryToggle`**: multiple 토글 결과를 직접 돌려준다.
74
+ * - 새 배열 반환: 정상 토글 (추가 또는 해제).
75
+ * - `null` 반환: 최대 개수 도달로 추가가 차단됨 (호출자는 변경 없이 종료해야 함).
76
+ *
77
+ * 호출자가 `>= maxSelection` 같은 도메인 규칙을 직접 검사하지 않도록 결과만 노출한다.
78
+ */
79
+ export const useMultiSelect = function (selectedValues, options) {
80
+ let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
81
+ const {
82
+ selectText,
83
+ deselectText,
84
+ maxSelection
85
+ } = config;
50
86
  const isAllSelected = isAllItemsSelected(selectedValues, options);
51
87
  const buttonText = getSelectAllButtonText(selectedValues, options, selectText, deselectText);
52
- const toggleSelectAll = () => {
53
- return handleSelectAllItems(selectedValues, options);
54
- };
55
- const getSelectedTagsData = () => {
56
- return getSelectedTags(selectedValues, options);
57
- };
58
- const removeTag = tagId => {
59
- return removeTagFromSelected(selectedValues, tagId);
60
- };
61
- return {
88
+ const {
89
+ isMaxSelectionActive,
90
+ isMaxReached,
91
+ canAdd
92
+ } = useMaxSelection(selectedValues, maxSelection);
93
+ const toggleSelectAll = useCallback(() => handleSelectAllItems(selectedValues, options), [selectedValues, options]);
94
+ const getSelectedTagsData = useCallback(() => getSelectedTags(selectedValues, options), [selectedValues, options]);
95
+ const removeTag = useCallback(tagId => removeTagFromSelected(selectedValues, tagId), [selectedValues]);
96
+ /**
97
+ * multiple 선택 토글을 한 번에 처리한다.
98
+ * - 이미 포함된 항목: 해제 (배열에서 제거하여 반환).
99
+ * - 미포함 항목: 추가 시도. 최대치 도달이면 `null` 반환(차단).
100
+ *
101
+ * 호출 측은 `null` 여부만 확인하면 되며 maxSelection 도메인 규칙을 알 필요가 없다.
102
+ */
103
+ const tryToggle = useCallback((optionId, currentArray) => {
104
+ const base = Array.isArray(currentArray) ? currentArray : [];
105
+ const idx = base.indexOf(optionId);
106
+ if (idx > -1) {
107
+ const next = [...base];
108
+ next.splice(idx, 1);
109
+ return next;
110
+ }
111
+ if (!canAdd(base.length)) return null;
112
+ return [...base, optionId];
113
+ }, [canAdd]);
114
+ return useMemo(() => ({
62
115
  isAllSelected,
63
116
  buttonText,
64
117
  toggleSelectAll,
65
118
  getSelectedTagsData,
66
- removeTag
67
- };
119
+ removeTag,
120
+ isMaxSelectionActive,
121
+ isMaxReached,
122
+ tryToggle
123
+ }), [isAllSelected, buttonText, toggleSelectAll, getSelectedTagsData, removeTag, isMaxSelectionActive, isMaxReached, tryToggle]);
68
124
  };
@@ -0,0 +1,22 @@
1
+ export type FeaturedIconTheme = 'light-circle' | 'dark-circle' | 'outline-circle' | 'square-outline';
2
+ export type FeaturedIconColor = 'neutral' | 'error' | 'warning' | 'success';
3
+ export type FeaturedIconSize = 'sm' | 'md' | 'lg' | 'xl';
4
+ export interface FeaturedIconOptions {
5
+ svgString: string;
6
+ theme?: FeaturedIconTheme;
7
+ color?: FeaturedIconColor;
8
+ size?: FeaturedIconSize;
9
+ className?: string;
10
+ }
11
+ export declare class FeaturedIcon {
12
+ private element;
13
+ private options;
14
+ constructor(options: FeaturedIconOptions);
15
+ private createElement;
16
+ private addSizeToSvg;
17
+ getElement(): HTMLElement;
18
+ updateColor(color: FeaturedIconColor): void;
19
+ updateSize(size: FeaturedIconSize): void;
20
+ destroy(): void;
21
+ static create(options: FeaturedIconOptions): FeaturedIcon;
22
+ }
@@ -0,0 +1,79 @@
1
+ // React 컴포넌트와 동일하게 구성
2
+ const iconSizeMap = {
3
+ sm: 16,
4
+ md: 20,
5
+ lg: 24,
6
+ xl: 28,
7
+ };
8
+ export class FeaturedIcon {
9
+ constructor(options) {
10
+ this.options = {
11
+ theme: 'light-circle',
12
+ color: 'neutral',
13
+ size: 'sm',
14
+ className: '',
15
+ ...options,
16
+ };
17
+ this.element = this.createElement();
18
+ }
19
+ // svgString ( ICON SVG ) 을 받아서 요소를 생성
20
+ createElement() {
21
+ const { theme, color, size, className, svgString } = this.options;
22
+ // React FeaturedIcon과 동일한 클래스 구조
23
+ const classes = [
24
+ 'ncua-featured-icon',
25
+ `ncua-featured-icon--${theme}`,
26
+ `ncua-featured-icon--${color}`,
27
+ `ncua-featured-icon--${size}`,
28
+ ];
29
+ if (className) {
30
+ classes.push(className);
31
+ }
32
+ const div = document.createElement('div');
33
+ div.className = classes.join(' ');
34
+ // outline-circle 테마일 때 추가 요소들 (React 컴포넌트와 동일)
35
+ if (theme === 'outline-circle') {
36
+ const innerOutline = document.createElement('div');
37
+ innerOutline.className = 'ncua-featured-icon__outline ncua-featured-icon__outline--inner';
38
+ div.appendChild(innerOutline);
39
+ const outerOutline = document.createElement('div');
40
+ outerOutline.className = 'ncua-featured-icon__outline ncua-featured-icon__outline--outer';
41
+ div.appendChild(outerOutline);
42
+ }
43
+ // SVG 아이콘 추가
44
+ const iconSize = iconSizeMap[size];
45
+ const svgWithSize = this.addSizeToSvg(svgString, iconSize);
46
+ div.innerHTML += svgWithSize;
47
+ return div;
48
+ }
49
+ addSizeToSvg(svgString, size) {
50
+ return svgString.replace(/<svg([^>]*)>/, `<svg$1 width="${size}" height="${size}">`);
51
+ }
52
+ // Public methods
53
+ getElement() {
54
+ return this.element;
55
+ }
56
+ updateColor(color) {
57
+ this.element.className = this.element.className.replace(/ncua-featured-icon--(neutral|error|warning|success)/, `ncua-featured-icon--${color}`);
58
+ this.options.color = color;
59
+ }
60
+ updateSize(size) {
61
+ const iconSize = iconSizeMap[size];
62
+ this.element.className = this.element.className.replace(/ncua-featured-icon--(sm|md|lg|xl)/, `ncua-featured-icon--${size}`);
63
+ const svgIcon = this.element.querySelector('svg');
64
+ if (svgIcon) {
65
+ svgIcon.setAttribute('width', String(iconSize));
66
+ svgIcon.setAttribute('height', String(iconSize));
67
+ }
68
+ this.options.size = size;
69
+ }
70
+ destroy() {
71
+ if (this.element.parentNode) {
72
+ this.element.parentNode.removeChild(this.element);
73
+ }
74
+ }
75
+ // Static factory method
76
+ static create(options) {
77
+ return new FeaturedIcon(options);
78
+ }
79
+ }
@@ -0,0 +1,24 @@
1
+ import type { BaseNotificationOptions } from './const';
2
+ export interface FloatingNotificationOptions extends BaseNotificationOptions {
3
+ type?: 'floating';
4
+ }
5
+ export declare class FloatingNotification {
6
+ private element;
7
+ private options;
8
+ private autoCloseTimer?;
9
+ private featuredIcon?;
10
+ private mobileCleanup?;
11
+ constructor(options: FloatingNotificationOptions);
12
+ private createElement;
13
+ private buildTemplate;
14
+ private renderCloseButton;
15
+ private setupMobileListener;
16
+ private updateMobileStyles;
17
+ private bindEvents;
18
+ private setupAutoClose;
19
+ getElement(): HTMLElement;
20
+ appendTo(parent: HTMLElement): void;
21
+ remove(): void;
22
+ destroy(): void;
23
+ static create(options: FloatingNotificationOptions): FloatingNotification;
24
+ }
@@ -0,0 +1,156 @@
1
+ import { MEDIA_QUERY } from '../../../src/constant/breakpoint';
2
+ import { FeaturedIcon } from '../featuredIcon';
3
+ import { ButtonCloseX } from '../shared/ButtonCloseX';
4
+ import { sanitizeHtml } from '../utils/sanitize';
5
+ import { CLASS_NAMES, FLOATING_ICON_MAP, getSizes } from './const';
6
+ import { bindNotificationEvents, createWrapperElement, isMobile, renderActions, renderSupportingText, setupAutoClose, } from './utils';
7
+ export class FloatingNotification {
8
+ constructor(options) {
9
+ this.options = {
10
+ color: 'neutral',
11
+ className: '',
12
+ actions: [],
13
+ autoClose: 0,
14
+ supportingText: undefined,
15
+ ...options,
16
+ };
17
+ this.element = this.createElement();
18
+ this.bindEvents();
19
+ this.setupAutoClose();
20
+ this.setupMobileListener();
21
+ }
22
+ createElement() {
23
+ const { title, supportingText, color, className, actions, onClose } = this.options;
24
+ // 플로팅 알림에서 info 색상 사용 시 neutral로 대체
25
+ let actualColor = color;
26
+ if (color === 'info') {
27
+ actualColor = 'neutral';
28
+ }
29
+ const wrapper = createWrapperElement(CLASS_NAMES.FLOATING.BASE, actualColor, className);
30
+ const iconFunction = FLOATING_ICON_MAP[actualColor];
31
+ const mobile = isMobile();
32
+ // FeaturedIcon 생성
33
+ let featuredIconElement = null;
34
+ if (iconFunction) {
35
+ const size = getSizes.featuredIcon(mobile);
36
+ const iconSize = getSizes.iconPixel(mobile);
37
+ const iconSvg = iconFunction(iconSize);
38
+ this.featuredIcon = FeaturedIcon.create({
39
+ svgString: iconSvg,
40
+ theme: 'dark-circle',
41
+ color: actualColor,
42
+ size: size,
43
+ });
44
+ featuredIconElement = this.featuredIcon.getElement();
45
+ }
46
+ wrapper.innerHTML = sanitizeHtml(this.buildTemplate({
47
+ title,
48
+ supportingText,
49
+ actions,
50
+ onClose,
51
+ isMobile: mobile,
52
+ }));
53
+ // FeaturedIcon을 container에 추가
54
+ if (featuredIconElement) {
55
+ const container = wrapper.querySelector(`.${CLASS_NAMES.FLOATING.CONTAINER}`);
56
+ if (container) {
57
+ container.insertBefore(featuredIconElement, container.firstChild);
58
+ }
59
+ }
60
+ return wrapper;
61
+ }
62
+ buildTemplate(params) {
63
+ const { title, supportingText, actions, onClose, isMobile } = params;
64
+ return `
65
+ <div class="${CLASS_NAMES.FLOATING.CONTENT}">
66
+ <div class="${CLASS_NAMES.FLOATING.CONTAINER}">
67
+ <div class="${CLASS_NAMES.FLOATING.TEXT_CONTAINER}">
68
+ <div class="${CLASS_NAMES.FLOATING.TITLE_WRAPPER}">
69
+ <span class="${CLASS_NAMES.FLOATING.TITLE}">${title}</span>
70
+ </div>
71
+ ${renderSupportingText(supportingText, CLASS_NAMES.FLOATING.SUPPORTING_TEXT)}
72
+ ${actions && actions.length > 0 ? renderActions(actions, CLASS_NAMES.FLOATING.ACTIONS) : ''}
73
+ </div>
74
+ </div>
75
+ </div>
76
+ ${this.renderCloseButton(onClose, isMobile)}
77
+ `;
78
+ }
79
+ renderCloseButton(onClose, isMobile = false) {
80
+ if (!onClose)
81
+ return '';
82
+ const size = getSizes.closeButton(isMobile);
83
+ return ButtonCloseX(size, 'light', CLASS_NAMES.FLOATING.CLOSE_BUTTON, '알림 닫기', onClose);
84
+ }
85
+ setupMobileListener() {
86
+ const mediaQuery = window.matchMedia(MEDIA_QUERY.mobile);
87
+ const handleChange = (e) => {
88
+ this.updateMobileStyles(e.matches);
89
+ if (e.matches && this.options.onClose) {
90
+ this.options.onClose();
91
+ this.remove();
92
+ }
93
+ };
94
+ handleChange({ matches: mediaQuery.matches });
95
+ mediaQuery.addEventListener('change', handleChange);
96
+ this.mobileCleanup = () => {
97
+ mediaQuery.removeEventListener('change', handleChange);
98
+ };
99
+ }
100
+ updateMobileStyles(mobile) {
101
+ if (this.featuredIcon) {
102
+ const newSize = getSizes.featuredIcon(mobile);
103
+ this.featuredIcon.updateSize(newSize);
104
+ }
105
+ const closeButton = this.element.querySelector('.ncua-button-close-x');
106
+ if (closeButton) {
107
+ const newSize = getSizes.closeButton(mobile);
108
+ const newSvgSize = getSizes.closeButtonSvg(newSize);
109
+ closeButton.className = closeButton.className.replace(/ncua-button-close-x--(xs|sm)/, `ncua-button-close-x--${newSize}`);
110
+ const svg = closeButton.querySelector('svg');
111
+ if (svg) {
112
+ svg.setAttribute('width', newSvgSize.toString());
113
+ svg.setAttribute('height', newSvgSize.toString());
114
+ }
115
+ }
116
+ }
117
+ bindEvents() {
118
+ bindNotificationEvents(this.element, this.options.actions, this.options.onClose, () => this.remove());
119
+ }
120
+ setupAutoClose() {
121
+ this.autoCloseTimer = setupAutoClose(this.options.autoClose, this.options.onClose, () => this.remove());
122
+ }
123
+ // Public methods
124
+ getElement() {
125
+ return this.element;
126
+ }
127
+ appendTo(parent) {
128
+ parent.appendChild(this.element);
129
+ }
130
+ remove() {
131
+ if (this.autoCloseTimer) {
132
+ clearTimeout(this.autoCloseTimer);
133
+ this.autoCloseTimer = undefined;
134
+ }
135
+ if (this.element?.parentNode) {
136
+ this.element.parentNode.removeChild(this.element);
137
+ }
138
+ }
139
+ destroy() {
140
+ // FeaturedIcon 정리
141
+ if (this.featuredIcon) {
142
+ this.featuredIcon.destroy();
143
+ this.featuredIcon = undefined;
144
+ }
145
+ // 모바일 리스너 정리
146
+ if (this.mobileCleanup) {
147
+ this.mobileCleanup();
148
+ this.mobileCleanup = undefined;
149
+ }
150
+ this.remove();
151
+ }
152
+ // Static factory methods
153
+ static create(options) {
154
+ return new FloatingNotification(options);
155
+ }
156
+ }
@@ -0,0 +1,21 @@
1
+ import type { BaseNotificationOptions } from './const';
2
+ export interface FullWidthNotificationOptions extends BaseNotificationOptions {
3
+ type?: 'full-width';
4
+ }
5
+ export declare class FullWidthNotification {
6
+ private element;
7
+ private options;
8
+ private autoCloseTimer?;
9
+ constructor(options: FullWidthNotificationOptions);
10
+ private createElement;
11
+ private buildTemplate;
12
+ private renderHidePermanentlyButton;
13
+ private renderCloseButton;
14
+ private bindEvents;
15
+ private setupAutoClose;
16
+ getElement(): HTMLElement;
17
+ appendTo(parent: HTMLElement): void;
18
+ remove(): void;
19
+ destroy(): void;
20
+ static create(options: FullWidthNotificationOptions): FullWidthNotification;
21
+ }
@@ -0,0 +1,111 @@
1
+ import { sanitizeHtml } from '../utils/sanitize';
2
+ import { CLASS_NAMES, FULL_WIDTH_ICON_MAP, FULL_WIDTH_SIZES, SVG_ICONS } from './const';
3
+ import { bindNotificationEvents, createWrapperElement, renderActions, renderSupportingText, setupAutoClose, } from './utils';
4
+ export class FullWidthNotification {
5
+ constructor(options) {
6
+ this.options = {
7
+ color: 'neutral',
8
+ className: '',
9
+ actions: [],
10
+ autoClose: 0,
11
+ supportingText: undefined,
12
+ ...options,
13
+ };
14
+ this.element = this.createElement();
15
+ this.bindEvents();
16
+ this.setupAutoClose();
17
+ }
18
+ createElement() {
19
+ const { title, supportingText, color, className, actions, onClose, supportTextLink, onHidePermanently } = this.options;
20
+ const wrapper = createWrapperElement(CLASS_NAMES.FULL_WIDTH.BASE, color, className);
21
+ const iconHtml = FULL_WIDTH_ICON_MAP[color](FULL_WIDTH_SIZES.ICON);
22
+ wrapper.innerHTML = sanitizeHtml(this.buildTemplate({
23
+ iconHtml,
24
+ title,
25
+ supportingText,
26
+ actions,
27
+ onClose,
28
+ supportTextLink,
29
+ onHidePermanently,
30
+ }));
31
+ return wrapper;
32
+ }
33
+ buildTemplate(params) {
34
+ const { iconHtml, title, supportingText, actions, onClose, supportTextLink, onHidePermanently } = params;
35
+ return `
36
+ <div class="${CLASS_NAMES.FULL_WIDTH.CONTAINER}">
37
+ <div class="${CLASS_NAMES.FULL_WIDTH.CONTENT}">
38
+ <div class="${CLASS_NAMES.FULL_WIDTH.CONTENT_WRAPPER}">
39
+ <div class="${CLASS_NAMES.FULL_WIDTH.ICON}">${iconHtml}</div>
40
+ <div class="${CLASS_NAMES.FULL_WIDTH.TEXT_CONTAINER}">
41
+ <span class="${CLASS_NAMES.FULL_WIDTH.TITLE}">${title}</span>
42
+ ${renderSupportingText(supportingText, CLASS_NAMES.FULL_WIDTH.SUPPORTING_TEXT, supportTextLink)}
43
+ </div>
44
+ </div>
45
+ <div class="${CLASS_NAMES.FULL_WIDTH.ACTIONS_CONTAINER}">
46
+ ${actions && actions.length > 0 ? renderActions(actions, CLASS_NAMES.FULL_WIDTH.ACTIONS) : ''}
47
+ ${this.renderHidePermanentlyButton(onHidePermanently)}
48
+ ${this.renderCloseButton(onClose)}
49
+ </div>
50
+ </div>
51
+ </div>
52
+ `;
53
+ }
54
+ renderHidePermanentlyButton(onHidePermanently) {
55
+ if (!onHidePermanently)
56
+ return '';
57
+ return `
58
+ <button type="button" class="ncua-notification__action-button ncua-notification__action-button--text ncua-full-width-notification__link" data-hide-permanently="true">
59
+ 다시보지 않기
60
+ </button>
61
+ `;
62
+ }
63
+ renderCloseButton(onClose) {
64
+ if (!onClose)
65
+ return '';
66
+ return `
67
+ <button type="button" class="${CLASS_NAMES.FULL_WIDTH.CLOSE_BUTTON}" aria-label="알림 닫기">
68
+ ${SVG_ICONS['x-close'](FULL_WIDTH_SIZES.CLOSE_BUTTON)}
69
+ </button>
70
+ `;
71
+ }
72
+ bindEvents() {
73
+ bindNotificationEvents(this.element, this.options.actions, this.options.onClose, () => this.remove());
74
+ // 다시보지 않기 버튼 이벤트 바인딩
75
+ if (this.options.onHidePermanently) {
76
+ const hidePermanentlyButton = this.element.querySelector('[data-hide-permanently="true"]');
77
+ if (hidePermanentlyButton) {
78
+ hidePermanentlyButton.addEventListener('click', () => {
79
+ this.options.onHidePermanently?.();
80
+ this.remove();
81
+ });
82
+ }
83
+ }
84
+ }
85
+ setupAutoClose() {
86
+ this.autoCloseTimer = setupAutoClose(this.options.autoClose, this.options.onClose, () => this.remove());
87
+ }
88
+ // Public methods
89
+ getElement() {
90
+ return this.element;
91
+ }
92
+ appendTo(parent) {
93
+ parent.appendChild(this.element);
94
+ }
95
+ remove() {
96
+ if (this.autoCloseTimer) {
97
+ clearTimeout(this.autoCloseTimer);
98
+ this.autoCloseTimer = undefined;
99
+ }
100
+ if (this.element?.parentNode) {
101
+ this.element.parentNode.removeChild(this.element);
102
+ }
103
+ }
104
+ destroy() {
105
+ this.remove();
106
+ }
107
+ // Static factory methods
108
+ static create(options) {
109
+ return new FullWidthNotification(options);
110
+ }
111
+ }