@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.
- package/dist/cjs/assets/scripts/featuredIcon.js +87 -0
- package/dist/cjs/assets/scripts/notification/FloatingNotification.js +178 -0
- package/dist/cjs/assets/scripts/notification/FullWidthNotification.js +133 -0
- package/dist/cjs/assets/scripts/notification/MessageNotification.js +159 -0
- package/dist/cjs/assets/scripts/notification/Notification.js +120 -0
- package/dist/cjs/assets/scripts/notification/const/classNames.js +50 -0
- package/dist/cjs/assets/scripts/notification/const/icons.js +31 -0
- package/dist/cjs/assets/scripts/notification/const/index.js +87 -0
- package/dist/cjs/assets/scripts/notification/const/sizes.js +46 -0
- package/dist/cjs/assets/scripts/notification/const/types.js +14 -0
- package/dist/cjs/assets/scripts/notification/index.js +116 -0
- package/dist/cjs/assets/scripts/notification/positionSync.js +180 -0
- package/dist/cjs/assets/scripts/notification/utils.js +122 -0
- package/dist/cjs/assets/scripts/shared/ButtonCloseX.js +45 -0
- package/dist/cjs/assets/scripts/utils/sanitize.js +39 -0
- package/dist/cjs/src/components/data-display/data-grid/DataGrid.js +5 -1
- package/dist/cjs/src/components/data-display/table/Table.js +118 -96
- package/dist/cjs/src/components/data-display/table/useTableScrollbars.js +187 -0
- package/dist/cjs/src/components/forms-and-input/combo-box/ComboBox.js +11 -10
- package/dist/cjs/src/components/forms-and-input/image-file-input/ImageFileInput.js +5 -2
- package/dist/cjs/src/components/forms-and-input/select-box/SelectBox.js +67 -29
- package/dist/cjs/src/components/overlays/dropdown/Dropdown.js +47 -19
- package/dist/cjs/src/components/overlays/notification/CalloutNotification.js +25 -0
- package/dist/cjs/src/components/overlays/notification/FloatingNotification.js +86 -13
- package/dist/cjs/src/components/overlays/notification/Notification.js +7 -0
- package/dist/cjs/src/components/overlays/notification/host.js +12 -0
- package/dist/cjs/src/components/overlays/tooltip/Tooltip.js +57 -44
- package/dist/cjs/src/components/select-dropdown/SelectDropdown.js +2 -1
- package/dist/cjs/src/contexts/FloatingContext.js +11 -0
- package/dist/cjs/src/contexts/index.js +16 -0
- package/dist/cjs/src/hooks/index.js +11 -0
- package/dist/cjs/src/hooks/useFloatingPosition.js +78 -0
- package/dist/cjs/src/hooks/usePortalState.js +17 -0
- package/dist/cjs/src/utils/dropdown/maxSelection.js +35 -0
- package/dist/cjs/src/utils/dropdown/multiSelect.js +72 -15
- package/dist/esm/assets/scripts/featuredIcon.js +80 -0
- package/dist/esm/assets/scripts/notification/FloatingNotification.js +171 -0
- package/dist/esm/assets/scripts/notification/FullWidthNotification.js +126 -0
- package/dist/esm/assets/scripts/notification/MessageNotification.js +152 -0
- package/dist/esm/assets/scripts/notification/Notification.js +113 -0
- package/dist/esm/assets/scripts/notification/const/classNames.js +44 -0
- package/dist/esm/assets/scripts/notification/const/icons.js +25 -0
- package/dist/esm/assets/scripts/notification/const/index.js +4 -0
- package/dist/esm/assets/scripts/notification/const/sizes.js +40 -0
- package/dist/esm/assets/scripts/notification/const/types.js +8 -0
- package/dist/esm/assets/scripts/notification/index.js +10 -0
- package/dist/esm/assets/scripts/notification/positionSync.js +171 -0
- package/dist/esm/assets/scripts/notification/utils.js +109 -0
- package/dist/esm/assets/scripts/shared/ButtonCloseX.js +37 -0
- package/dist/esm/assets/scripts/utils/sanitize.js +31 -0
- package/dist/esm/src/components/data-display/data-grid/DataGrid.js +5 -1
- package/dist/esm/src/components/data-display/table/Table.js +118 -96
- package/dist/esm/src/components/data-display/table/useTableScrollbars.js +179 -0
- package/dist/esm/src/components/forms-and-input/combo-box/ComboBox.js +11 -10
- package/dist/esm/src/components/forms-and-input/image-file-input/ImageFileInput.js +5 -2
- package/dist/esm/src/components/forms-and-input/select-box/SelectBox.js +67 -29
- package/dist/esm/src/components/overlays/dropdown/Dropdown.js +47 -19
- package/dist/esm/src/components/overlays/notification/CalloutNotification.js +19 -0
- package/dist/esm/src/components/overlays/notification/FloatingNotification.js +86 -14
- package/dist/esm/src/components/overlays/notification/Notification.js +7 -0
- package/dist/esm/src/components/overlays/notification/host.js +9 -0
- package/dist/esm/src/components/overlays/tooltip/Tooltip.js +58 -45
- package/dist/esm/src/components/select-dropdown/SelectDropdown.js +2 -1
- package/dist/esm/src/contexts/FloatingContext.js +4 -0
- package/dist/esm/src/contexts/index.js +1 -0
- package/dist/esm/src/hooks/index.js +1 -0
- package/dist/esm/src/hooks/useFloatingPosition.js +71 -0
- package/dist/esm/src/hooks/usePortalState.js +10 -0
- package/dist/esm/src/utils/dropdown/maxSelection.js +27 -0
- package/dist/esm/src/utils/dropdown/multiSelect.js +70 -14
- package/dist/temp/assets/scripts/featuredIcon.d.ts +22 -0
- package/dist/temp/assets/scripts/featuredIcon.js +79 -0
- package/dist/temp/assets/scripts/notification/FloatingNotification.d.ts +24 -0
- package/dist/temp/assets/scripts/notification/FloatingNotification.js +156 -0
- package/dist/temp/assets/scripts/notification/FullWidthNotification.d.ts +21 -0
- package/dist/temp/assets/scripts/notification/FullWidthNotification.js +111 -0
- package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +22 -0
- package/dist/temp/assets/scripts/notification/MessageNotification.js +140 -0
- package/dist/temp/assets/scripts/notification/Notification.d.ts +22 -0
- package/dist/temp/assets/scripts/notification/Notification.js +112 -0
- package/dist/temp/assets/scripts/notification/const/classNames.d.ts +43 -0
- package/dist/temp/assets/scripts/notification/const/classNames.js +44 -0
- package/dist/temp/assets/scripts/notification/const/icons.d.ts +25 -0
- package/dist/temp/assets/scripts/notification/const/icons.js +25 -0
- package/dist/temp/assets/scripts/notification/const/index.d.ts +5 -0
- package/dist/temp/assets/scripts/notification/const/index.js +4 -0
- package/dist/temp/assets/scripts/notification/const/sizes.d.ts +32 -0
- package/dist/temp/assets/scripts/notification/const/sizes.js +40 -0
- package/dist/temp/assets/scripts/notification/const/types.d.ts +19 -0
- package/dist/temp/assets/scripts/notification/const/types.js +8 -0
- package/dist/temp/assets/scripts/notification/index.d.ts +8 -0
- package/dist/temp/assets/scripts/notification/index.js +10 -0
- package/dist/temp/assets/scripts/notification/positionSync.d.ts +50 -0
- package/dist/temp/assets/scripts/notification/positionSync.js +170 -0
- package/dist/temp/assets/scripts/notification/utils.d.ts +8 -0
- package/dist/temp/assets/scripts/notification/utils.js +115 -0
- package/dist/temp/assets/scripts/shared/ButtonCloseX.d.ts +5 -0
- package/dist/temp/assets/scripts/shared/ButtonCloseX.js +33 -0
- package/dist/temp/assets/scripts/utils/sanitize.d.ts +22 -0
- package/dist/temp/assets/scripts/utils/sanitize.js +31 -0
- package/dist/temp/src/components/data-display/data-grid/DataGrid.js +1 -1
- package/dist/temp/src/components/data-display/data-grid/DataGrid.types.d.ts +7 -0
- package/dist/temp/src/components/data-display/table/Table.d.ts +4 -1
- package/dist/temp/src/components/data-display/table/Table.js +53 -68
- package/dist/temp/src/components/data-display/table/types.d.ts +18 -0
- package/dist/temp/src/components/data-display/table/useTableScrollbars.d.ts +25 -0
- package/dist/temp/src/components/data-display/table/useTableScrollbars.js +136 -0
- package/dist/temp/src/components/forms-and-input/combo-box/ComboBox.d.ts +8 -0
- package/dist/temp/src/components/forms-and-input/combo-box/ComboBox.js +7 -11
- package/dist/temp/src/components/forms-and-input/image-file-input/ImageFileInput.js +1 -1
- package/dist/temp/src/components/forms-and-input/select-box/SelectBox.d.ts +13 -0
- package/dist/temp/src/components/forms-and-input/select-box/SelectBox.js +30 -3
- package/dist/temp/src/components/overlays/dropdown/Dropdown.d.ts +5 -0
- package/dist/temp/src/components/overlays/dropdown/Dropdown.js +35 -11
- package/dist/temp/src/components/overlays/notification/CalloutNotification.d.ts +9 -0
- package/dist/temp/src/components/overlays/notification/CalloutNotification.js +6 -0
- package/dist/temp/src/components/overlays/notification/FloatingNotification.d.ts +15 -0
- package/dist/temp/src/components/overlays/notification/FloatingNotification.js +81 -13
- package/dist/temp/src/components/overlays/notification/Notification.d.ts +18 -3
- package/dist/temp/src/components/overlays/notification/Notification.js +4 -0
- package/dist/temp/src/components/overlays/notification/host.d.ts +9 -0
- package/dist/temp/src/components/overlays/notification/host.js +9 -0
- package/dist/temp/src/components/overlays/tooltip/Tooltip.d.ts +5 -1
- package/dist/temp/src/components/overlays/tooltip/Tooltip.js +25 -22
- package/dist/temp/src/components/select-dropdown/SelectDropdown.d.ts +6 -0
- package/dist/temp/src/components/select-dropdown/SelectDropdown.js +2 -2
- package/dist/temp/src/contexts/FloatingContext.d.ts +6 -0
- package/dist/temp/src/contexts/FloatingContext.js +4 -0
- package/dist/temp/src/contexts/index.d.ts +1 -0
- package/dist/temp/src/contexts/index.js +1 -0
- package/dist/temp/src/hooks/index.d.ts +1 -0
- package/dist/temp/src/hooks/index.js +1 -0
- package/dist/temp/src/hooks/useFloatingPosition.d.ts +19 -0
- package/dist/temp/src/hooks/useFloatingPosition.js +55 -0
- package/dist/temp/src/hooks/usePortalState.d.ts +6 -0
- package/dist/temp/src/hooks/usePortalState.js +7 -0
- package/dist/temp/src/utils/dropdown/maxSelection.d.ts +24 -0
- package/dist/temp/src/utils/dropdown/maxSelection.js +28 -0
- package/dist/temp/src/utils/dropdown/multiSelect.d.ts +42 -2
- package/dist/temp/src/utils/dropdown/multiSelect.js +66 -13
- package/dist/types/assets/scripts/featuredIcon.d.ts +22 -0
- package/dist/types/assets/scripts/notification/FloatingNotification.d.ts +24 -0
- package/dist/types/assets/scripts/notification/FullWidthNotification.d.ts +21 -0
- package/dist/types/assets/scripts/notification/MessageNotification.d.ts +22 -0
- package/dist/types/assets/scripts/notification/Notification.d.ts +22 -0
- package/dist/types/assets/scripts/notification/const/classNames.d.ts +43 -0
- package/dist/types/assets/scripts/notification/const/icons.d.ts +25 -0
- package/dist/types/assets/scripts/notification/const/index.d.ts +5 -0
- package/dist/types/assets/scripts/notification/const/sizes.d.ts +32 -0
- package/dist/types/assets/scripts/notification/const/types.d.ts +19 -0
- package/dist/types/assets/scripts/notification/index.d.ts +8 -0
- package/dist/types/assets/scripts/notification/positionSync.d.ts +50 -0
- package/dist/types/assets/scripts/notification/utils.d.ts +8 -0
- package/dist/types/assets/scripts/shared/ButtonCloseX.d.ts +5 -0
- package/dist/types/assets/scripts/utils/sanitize.d.ts +22 -0
- package/dist/types/src/components/data-display/data-grid/DataGrid.types.d.ts +7 -0
- package/dist/types/src/components/data-display/table/Table.d.ts +4 -1
- package/dist/types/src/components/data-display/table/types.d.ts +18 -0
- package/dist/types/src/components/data-display/table/useTableScrollbars.d.ts +25 -0
- package/dist/types/src/components/forms-and-input/combo-box/ComboBox.d.ts +8 -0
- package/dist/types/src/components/forms-and-input/select-box/SelectBox.d.ts +13 -0
- package/dist/types/src/components/overlays/dropdown/Dropdown.d.ts +5 -0
- package/dist/types/src/components/overlays/notification/CalloutNotification.d.ts +9 -0
- package/dist/types/src/components/overlays/notification/FloatingNotification.d.ts +15 -0
- package/dist/types/src/components/overlays/notification/Notification.d.ts +18 -3
- package/dist/types/src/components/overlays/notification/host.d.ts +9 -0
- package/dist/types/src/components/overlays/tooltip/Tooltip.d.ts +5 -1
- package/dist/types/src/components/select-dropdown/SelectDropdown.d.ts +6 -0
- package/dist/types/src/contexts/FloatingContext.d.ts +6 -0
- package/dist/types/src/contexts/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/useFloatingPosition.d.ts +19 -0
- package/dist/types/src/hooks/usePortalState.d.ts +6 -0
- package/dist/types/src/utils/dropdown/maxSelection.d.ts +24 -0
- package/dist/types/src/utils/dropdown/multiSelect.d.ts +42 -2
- package/dist/ui-admin/assets/styles/style.css +304 -64
- package/package.json +1 -1
|
@@ -77,6 +77,42 @@ const computePanelCoords = (prefer, anchor, panel) => {
|
|
|
77
77
|
calculatedPosition
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
|
+
const buildPanelStyle = (disablePortal, coords, visible, zIndex) => {
|
|
81
|
+
const opacity = visible ? 1 : 0;
|
|
82
|
+
if (disablePortal) return {
|
|
83
|
+
opacity
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
top: `${coords.top}px`,
|
|
87
|
+
left: `${coords.left}px`,
|
|
88
|
+
opacity,
|
|
89
|
+
...(zIndex && {
|
|
90
|
+
zIndex
|
|
91
|
+
})
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
const renderIcon = (iconStyle, iconType, iconSize, iconColor) => {
|
|
95
|
+
if (iconStyle === 'help-circle') {
|
|
96
|
+
return iconType === 'stroke' ? (0, _jsxRuntime.jsx)(_uiAdminIcon.HelpCircle, {
|
|
97
|
+
width: iconSize,
|
|
98
|
+
height: iconSize,
|
|
99
|
+
color: iconColor
|
|
100
|
+
}) : (0, _jsxRuntime.jsx)(_uiAdminIcon.HelpCircleFill, {
|
|
101
|
+
width: iconSize,
|
|
102
|
+
height: iconSize,
|
|
103
|
+
color: iconColor
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return iconType === 'stroke' ? (0, _jsxRuntime.jsx)(_uiAdminIcon.AlertCircle, {
|
|
107
|
+
width: iconSize,
|
|
108
|
+
height: iconSize,
|
|
109
|
+
color: iconColor
|
|
110
|
+
}) : (0, _jsxRuntime.jsx)(_uiAdminIcon.AlertCircleFill, {
|
|
111
|
+
width: iconSize,
|
|
112
|
+
height: iconSize,
|
|
113
|
+
color: iconColor
|
|
114
|
+
});
|
|
115
|
+
};
|
|
80
116
|
const Tooltip = _ref => {
|
|
81
117
|
let {
|
|
82
118
|
tooltipType = 'white',
|
|
@@ -90,7 +126,9 @@ const Tooltip = _ref => {
|
|
|
90
126
|
iconColor = 'var(--gray-300)',
|
|
91
127
|
iconStyle = 'help-circle',
|
|
92
128
|
className,
|
|
93
|
-
zIndex
|
|
129
|
+
zIndex,
|
|
130
|
+
forceVisible,
|
|
131
|
+
disablePortal = false
|
|
94
132
|
} = _ref;
|
|
95
133
|
const iconSize = size === 'sm' ? ICON_SIZE_SM : ICON_SIZE_DEFAULT;
|
|
96
134
|
const anchorRef = (0, _react.useRef)(null);
|
|
@@ -104,6 +142,7 @@ const Tooltip = _ref => {
|
|
|
104
142
|
const [calculatedPosition, setCalculatedPosition] = (0, _react.useState)(position === 'auto' ? 'bottom' : position);
|
|
105
143
|
const [isVisible, setIsVisible] = (0, _react.useState)(false);
|
|
106
144
|
const [isManuallyClose, setIsManuallyClose] = (0, _react.useState)(false);
|
|
145
|
+
const effectiveVisible = forceVisible ?? isVisible;
|
|
107
146
|
(0, _react.useEffect)(() => {
|
|
108
147
|
setMounted(true);
|
|
109
148
|
return () => {
|
|
@@ -114,7 +153,7 @@ const Tooltip = _ref => {
|
|
|
114
153
|
};
|
|
115
154
|
}, []);
|
|
116
155
|
const updatePosition = (0, _react.useCallback)(() => {
|
|
117
|
-
if (!anchorRef.current || !panelRef.current) return;
|
|
156
|
+
if (disablePortal || !anchorRef.current || !panelRef.current) return;
|
|
118
157
|
const anchor = anchorRef.current.getBoundingClientRect();
|
|
119
158
|
const panel = panelRef.current.getBoundingClientRect();
|
|
120
159
|
const next = computePanelCoords(position, anchor, panel);
|
|
@@ -123,9 +162,9 @@ const Tooltip = _ref => {
|
|
|
123
162
|
left: next.left
|
|
124
163
|
});
|
|
125
164
|
setCalculatedPosition(next.calculatedPosition);
|
|
126
|
-
}, [position]);
|
|
165
|
+
}, [position, disablePortal]);
|
|
127
166
|
(0, _react.useEffect)(() => {
|
|
128
|
-
if (!
|
|
167
|
+
if (!effectiveVisible || disablePortal) return;
|
|
129
168
|
updatePosition();
|
|
130
169
|
window.addEventListener('resize', updatePosition, {
|
|
131
170
|
passive: true
|
|
@@ -140,13 +179,10 @@ const Tooltip = _ref => {
|
|
|
140
179
|
capture: true
|
|
141
180
|
});
|
|
142
181
|
};
|
|
143
|
-
}, [
|
|
182
|
+
}, [effectiveVisible, updatePosition, disablePortal]);
|
|
144
183
|
const handleMouseEnter = (0, _react.useCallback)(() => {
|
|
145
184
|
if (isManuallyClose) return;
|
|
146
|
-
// opacity 전환 전에 좌표 확정 (ref 가드는 updatePosition 내부)
|
|
147
185
|
updatePosition();
|
|
148
|
-
// 웹폰트 로드·max-content 재계산 등 비동기 layout 안정화 후 한 번 더 보정
|
|
149
|
-
// 빠른 hover in/out 시 이전 프레임 요청은 취소해 중복/unmount 후 실행 방지
|
|
150
186
|
if (rafIdRef.current !== null) cancelAnimationFrame(rafIdRef.current);
|
|
151
187
|
rafIdRef.current = requestAnimationFrame(() => {
|
|
152
188
|
rafIdRef.current = null;
|
|
@@ -170,18 +206,13 @@ const Tooltip = _ref => {
|
|
|
170
206
|
'ncua-tooltip--stroke': iconType === 'stroke',
|
|
171
207
|
'ncua-tooltip--auto': position === 'auto'
|
|
172
208
|
}, className), [size, type, hideArrow, iconType, position, className]);
|
|
173
|
-
const panelClassName = (0, _react.useMemo)(() => (0, _classnames.default)(
|
|
174
|
-
'ncua-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
opacity: isVisible ? 1 : 0,
|
|
181
|
-
...(zIndex && {
|
|
182
|
-
zIndex
|
|
183
|
-
})
|
|
184
|
-
};
|
|
209
|
+
const panelClassName = (0, _react.useMemo)(() => (0, _classnames.default)({
|
|
210
|
+
'ncua-tooltip-panel': !disablePortal
|
|
211
|
+
}, 'ncua-tooltip__bg', `ncua-tooltip__bg--${tooltipType}`, `ncua-tooltip__bg--${finalPosition}`, {
|
|
212
|
+
'ncua-tooltip__bg--visible': effectiveVisible,
|
|
213
|
+
'ncua-tooltip__bg--force-hidden': isManuallyClose && !forceVisible
|
|
214
|
+
}), [tooltipType, finalPosition, effectiveVisible, isManuallyClose, forceVisible, disablePortal]);
|
|
215
|
+
const panelStyle = buildPanelStyle(disablePortal, coords, effectiveVisible, zIndex);
|
|
185
216
|
const portalTarget = mounted ? resolvePortalTarget() : null;
|
|
186
217
|
const panel = (0, _jsxRuntime.jsxs)("span", {
|
|
187
218
|
ref: panelRef,
|
|
@@ -201,30 +232,12 @@ const Tooltip = _ref => {
|
|
|
201
232
|
"aria-label": "\uD234\uD301 \uB2EB\uAE30"
|
|
202
233
|
})]
|
|
203
234
|
});
|
|
204
|
-
return (0, _jsxRuntime.jsxs)(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
children: [iconStyle === 'help-circle' && (iconType === 'stroke' ? (0, _jsxRuntime.jsx)(_uiAdminIcon.HelpCircle, {
|
|
211
|
-
width: iconSize,
|
|
212
|
-
height: iconSize,
|
|
213
|
-
color: iconColor
|
|
214
|
-
}) : (0, _jsxRuntime.jsx)(_uiAdminIcon.HelpCircleFill, {
|
|
215
|
-
width: iconSize,
|
|
216
|
-
height: iconSize,
|
|
217
|
-
color: iconColor
|
|
218
|
-
})), iconStyle === 'alert-circle' && (iconType === 'stroke' ? (0, _jsxRuntime.jsx)(_uiAdminIcon.AlertCircle, {
|
|
219
|
-
width: iconSize,
|
|
220
|
-
height: iconSize,
|
|
221
|
-
color: iconColor
|
|
222
|
-
}) : (0, _jsxRuntime.jsx)(_uiAdminIcon.AlertCircleFill, {
|
|
223
|
-
width: iconSize,
|
|
224
|
-
height: iconSize,
|
|
225
|
-
color: iconColor
|
|
226
|
-
}))]
|
|
227
|
-
}), portalTarget && /*#__PURE__*/(0, _reactDom.createPortal)(panel, portalTarget)]
|
|
235
|
+
return (0, _jsxRuntime.jsxs)("span", {
|
|
236
|
+
ref: anchorRef,
|
|
237
|
+
className: tooltipClassName,
|
|
238
|
+
onMouseEnter: handleMouseEnter,
|
|
239
|
+
onMouseLeave: handleMouseLeave,
|
|
240
|
+
children: [renderIcon(iconStyle, iconType, iconSize, iconColor), disablePortal ? panel : portalTarget && /*#__PURE__*/(0, _reactDom.createPortal)(panel, portalTarget)]
|
|
228
241
|
});
|
|
229
242
|
};
|
|
230
243
|
exports.Tooltip = Tooltip;
|
|
@@ -27,6 +27,7 @@ const SelectDropdown = exports.SelectDropdown = /*#__PURE__*/(0, _react.forwardR
|
|
|
27
27
|
multiple = false,
|
|
28
28
|
showFooterButtons = false,
|
|
29
29
|
selectAllButtonText = '전체 선택',
|
|
30
|
+
showSelectAllAction = true,
|
|
30
31
|
onSelectAll,
|
|
31
32
|
onEdit,
|
|
32
33
|
onComplete,
|
|
@@ -92,7 +93,7 @@ const SelectDropdown = exports.SelectDropdown = /*#__PURE__*/(0, _react.forwardR
|
|
|
92
93
|
className: "ncua-select-dropdown__footer-buttons",
|
|
93
94
|
children: [(0, _jsxRuntime.jsx)("div", {
|
|
94
95
|
className: "ncua-select-dropdown__footer-left",
|
|
95
|
-
children: multiple && (0, _jsxRuntime.jsx)(_button.Button, {
|
|
96
|
+
children: multiple && showSelectAllAction && (0, _jsxRuntime.jsx)(_button.Button, {
|
|
96
97
|
label: selectAllButtonText,
|
|
97
98
|
hierarchy: "text",
|
|
98
99
|
size: "xs",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useFloatingContext = exports.FloatingProvider = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
const FloatingContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
9
|
+
const FloatingProvider = exports.FloatingProvider = FloatingContext.Provider;
|
|
10
|
+
const useFloatingContext = () => (0, _react.useContext)(FloatingContext);
|
|
11
|
+
exports.useFloatingContext = useFloatingContext;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _FloatingContext = require("./FloatingContext");
|
|
7
|
+
Object.keys(_FloatingContext).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _FloatingContext[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _FloatingContext[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -25,6 +25,17 @@ Object.keys(_useCallbackRef).forEach(function (key) {
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
+
var _useFloatingPosition = require("./useFloatingPosition");
|
|
29
|
+
Object.keys(_useFloatingPosition).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _useFloatingPosition[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _useFloatingPosition[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
28
39
|
var _useMediaQuery = require("./useMediaQuery");
|
|
29
40
|
Object.keys(_useMediaQuery).forEach(function (key) {
|
|
30
41
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useFloatingPosition = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
const FLOATING_Z_INDEX = 1500;
|
|
9
|
+
const useFloatingPosition = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
enabled,
|
|
12
|
+
isOpen,
|
|
13
|
+
triggerRef,
|
|
14
|
+
floatingRef,
|
|
15
|
+
direction,
|
|
16
|
+
offset = 4,
|
|
17
|
+
align = 'left',
|
|
18
|
+
matchTriggerWidth = false
|
|
19
|
+
} = _ref;
|
|
20
|
+
const [style, setStyle] = (0, _react.useState)(null);
|
|
21
|
+
(0, _react.useLayoutEffect)(() => {
|
|
22
|
+
if (!enabled || !isOpen) {
|
|
23
|
+
setStyle(null);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const trigger = triggerRef.current;
|
|
27
|
+
if (!trigger) return;
|
|
28
|
+
const calculatePosition = (trigger, floatingHeight, floatingWidth) => {
|
|
29
|
+
const top = direction === 'up' ? trigger.top - floatingHeight - offset : trigger.bottom + offset;
|
|
30
|
+
const left = align === 'right' ? trigger.right - floatingWidth : trigger.left;
|
|
31
|
+
return {
|
|
32
|
+
top,
|
|
33
|
+
left
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const update = () => {
|
|
37
|
+
const t = triggerRef.current;
|
|
38
|
+
const f = floatingRef.current;
|
|
39
|
+
if (!t) return;
|
|
40
|
+
const r = t.getBoundingClientRect();
|
|
41
|
+
const floatingHeight = f?.offsetHeight ?? 0;
|
|
42
|
+
const floatingWidth = matchTriggerWidth ? r.width : f?.offsetWidth ?? r.width;
|
|
43
|
+
const {
|
|
44
|
+
top,
|
|
45
|
+
left
|
|
46
|
+
} = calculatePosition(r, floatingHeight, floatingWidth);
|
|
47
|
+
// matchTriggerWidth=true: width는 max-content(콘텐츠 자연 너비), min-width만 trigger 너비로 보장.
|
|
48
|
+
// 옵션이 짧으면 trigger 너비, 길면 자연 확장 — 기존 absolute 모드와 동일한 UX.
|
|
49
|
+
setStyle({
|
|
50
|
+
position: 'fixed',
|
|
51
|
+
top,
|
|
52
|
+
left,
|
|
53
|
+
zIndex: FLOATING_Z_INDEX,
|
|
54
|
+
...(matchTriggerWidth ? {
|
|
55
|
+
minWidth: r.width
|
|
56
|
+
} : {})
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
update();
|
|
60
|
+
window.addEventListener('scroll', update, true);
|
|
61
|
+
window.addEventListener('resize', update);
|
|
62
|
+
const triggerObserver = new ResizeObserver(update);
|
|
63
|
+
triggerObserver.observe(trigger);
|
|
64
|
+
let floatingObserver;
|
|
65
|
+
if (floatingRef.current) {
|
|
66
|
+
floatingObserver = new ResizeObserver(update);
|
|
67
|
+
floatingObserver.observe(floatingRef.current);
|
|
68
|
+
}
|
|
69
|
+
return () => {
|
|
70
|
+
window.removeEventListener('scroll', update, true);
|
|
71
|
+
window.removeEventListener('resize', update);
|
|
72
|
+
triggerObserver.disconnect();
|
|
73
|
+
floatingObserver?.disconnect();
|
|
74
|
+
};
|
|
75
|
+
}, [enabled, isOpen, direction, offset, align, matchTriggerWidth, triggerRef, floatingRef]);
|
|
76
|
+
return style;
|
|
77
|
+
};
|
|
78
|
+
exports.useFloatingPosition = useFloatingPosition;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePortalState = void 0;
|
|
7
|
+
var _FloatingContext = require("../contexts/FloatingContext");
|
|
8
|
+
const usePortalState = usePortalProp => {
|
|
9
|
+
const floatingContext = (0, _FloatingContext.useFloatingContext)();
|
|
10
|
+
const shouldPortal = usePortalProp ?? floatingContext?.preferPortal ?? false;
|
|
11
|
+
const portalContainer = floatingContext?.portalContainer ?? (typeof document !== 'undefined' ? document.body : null);
|
|
12
|
+
return {
|
|
13
|
+
shouldPortal,
|
|
14
|
+
portalContainer
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.usePortalState = usePortalState;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isMaxSelectionReached = exports.isMaxSelectionLimitActive = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* SelectBox / ComboBox 공통 — 최대 선택 개수 제한 활성 여부 판정.
|
|
9
|
+
*
|
|
10
|
+
* React 훅(`useMultiSelect`)과 vanilla 드롭다운(`DropdownModel`)가 동일 로직을 공유하므로
|
|
11
|
+
* 두 곳에 정의가 갈라지지 않도록 단일 source-of-truth로 둔다.
|
|
12
|
+
*
|
|
13
|
+
* **계약**
|
|
14
|
+
* - `0` 이상의 정수 → 활성 (단, `0`은 모든 새 선택을 차단하는 의미)
|
|
15
|
+
* - 음수 / 비정수 / `undefined` / `null` → 비활성 (제한 없는 것과 동일)
|
|
16
|
+
*
|
|
17
|
+
* `0`을 활성으로 보는 이유: 호출자가 `maxSelection={0}`을 명시적으로 전달했을 때
|
|
18
|
+
* "선택 자체를 막겠다"는 의도로 해석하기 위함. 음수는 일반적으로 "값 없음"의 sentinel이므로 비활성.
|
|
19
|
+
*/
|
|
20
|
+
const isMaxSelectionLimitActive = maxSelection => typeof maxSelection === 'number' && Number.isInteger(maxSelection) && maxSelection >= 0;
|
|
21
|
+
/**
|
|
22
|
+
* 현재 선택 길이가 최대치에 도달했는지 단일 함수로 판정.
|
|
23
|
+
*
|
|
24
|
+
* 호출 측에서 `>=`을 직접 작성하지 않도록 의미를 노출하고, type predicate가 내부에서 적용되어
|
|
25
|
+
* `maxSelection`의 narrowing이 보장된다 (외부 predicate 호출로 인한 narrowing 누락 방지).
|
|
26
|
+
*
|
|
27
|
+
* - 제한 비활성(음수 / null / undefined / 비정수): 항상 `false`.
|
|
28
|
+
* - 활성: `currentLength >= maxSelection`.
|
|
29
|
+
*/
|
|
30
|
+
exports.isMaxSelectionLimitActive = isMaxSelectionLimitActive;
|
|
31
|
+
const isMaxSelectionReached = (currentLength, maxSelection) => {
|
|
32
|
+
if (!isMaxSelectionLimitActive(maxSelection)) return false;
|
|
33
|
+
return currentLength >= maxSelection;
|
|
34
|
+
};
|
|
35
|
+
exports.isMaxSelectionReached = isMaxSelectionReached;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useMultiSelect = exports.removeTagFromSelected = exports.isAllItemsSelected = exports.handleSelectAllItems = exports.getSelectedTags = exports.getSelectAllButtonText = void 0;
|
|
6
|
+
exports.useMultiSelect = exports.useMaxSelection = exports.removeTagFromSelected = exports.isAllItemsSelected = exports.handleSelectAllItems = exports.getSelectedTags = exports.getSelectAllButtonText = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _maxSelection = require("./maxSelection");
|
|
7
9
|
/**
|
|
8
10
|
* 전체 선택 상태를 확인하는 유틸 함수
|
|
9
11
|
*/
|
|
@@ -54,27 +56,82 @@ const removeTagFromSelected = (selectedValues, tagIdToRemove) => {
|
|
|
54
56
|
return selectedValues.filter(id => id !== tagIdToRemove);
|
|
55
57
|
};
|
|
56
58
|
/**
|
|
57
|
-
*
|
|
59
|
+
* 최대 선택 개수 관련 응집을 별도 훅으로 분리.
|
|
60
|
+
*
|
|
61
|
+
* - `isMaxSelectionActive`: 제한 활성 여부.
|
|
62
|
+
* - `isMaxReached`: 현재 선택 길이가 최대치에 도달했는지.
|
|
63
|
+
* - `canAdd(currentLength)`: 새 항목 추가가 허용되는지 (도달 시 `false`).
|
|
64
|
+
*
|
|
65
|
+
* 도메인 규칙(`>=` 비교 등)을 외부로 노출하지 않고 헬퍼를 통해 의미만 반환한다.
|
|
66
|
+
* `useMultiSelect`가 내부에서 사용하지만, 단독으로도 필요한 호출자가 쓸 수 있게 export한다.
|
|
58
67
|
*/
|
|
59
68
|
exports.removeTagFromSelected = removeTagFromSelected;
|
|
60
|
-
const
|
|
69
|
+
const useMaxSelection = (selectedValues, maxSelection) => {
|
|
70
|
+
const isMaxSelectionActive = (0, _maxSelection.isMaxSelectionLimitActive)(maxSelection);
|
|
71
|
+
const isMaxReached = (0, _maxSelection.isMaxSelectionReached)(selectedValues.length, maxSelection);
|
|
72
|
+
const canAdd = (0, _react.useCallback)(currentLength => !(0, _maxSelection.isMaxSelectionReached)(currentLength, maxSelection), [maxSelection]);
|
|
73
|
+
return {
|
|
74
|
+
isMaxSelectionActive,
|
|
75
|
+
isMaxReached,
|
|
76
|
+
canAdd
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* 전체 선택 관련 로직을 한 번에 처리하는 커스텀 훅.
|
|
81
|
+
*
|
|
82
|
+
* 시그니처는 호출자가 maxSelection만 지정하더라도 텍스트 라벨을 건너뛰지 않도록 옵션 객체로 받는다.
|
|
83
|
+
*
|
|
84
|
+
* **반환의 `tryToggle`**: multiple 토글 결과를 직접 돌려준다.
|
|
85
|
+
* - 새 배열 반환: 정상 토글 (추가 또는 해제).
|
|
86
|
+
* - `null` 반환: 최대 개수 도달로 추가가 차단됨 (호출자는 변경 없이 종료해야 함).
|
|
87
|
+
*
|
|
88
|
+
* 호출자가 `>= maxSelection` 같은 도메인 규칙을 직접 검사하지 않도록 결과만 노출한다.
|
|
89
|
+
*/
|
|
90
|
+
exports.useMaxSelection = useMaxSelection;
|
|
91
|
+
const useMultiSelect = function (selectedValues, options) {
|
|
92
|
+
let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
93
|
+
const {
|
|
94
|
+
selectText,
|
|
95
|
+
deselectText,
|
|
96
|
+
maxSelection
|
|
97
|
+
} = config;
|
|
61
98
|
const isAllSelected = isAllItemsSelected(selectedValues, options);
|
|
62
99
|
const buttonText = getSelectAllButtonText(selectedValues, options, selectText, deselectText);
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
100
|
+
const {
|
|
101
|
+
isMaxSelectionActive,
|
|
102
|
+
isMaxReached,
|
|
103
|
+
canAdd
|
|
104
|
+
} = useMaxSelection(selectedValues, maxSelection);
|
|
105
|
+
const toggleSelectAll = (0, _react.useCallback)(() => handleSelectAllItems(selectedValues, options), [selectedValues, options]);
|
|
106
|
+
const getSelectedTagsData = (0, _react.useCallback)(() => getSelectedTags(selectedValues, options), [selectedValues, options]);
|
|
107
|
+
const removeTag = (0, _react.useCallback)(tagId => removeTagFromSelected(selectedValues, tagId), [selectedValues]);
|
|
108
|
+
/**
|
|
109
|
+
* multiple 선택 토글을 한 번에 처리한다.
|
|
110
|
+
* - 이미 포함된 항목: 해제 (배열에서 제거하여 반환).
|
|
111
|
+
* - 미포함 항목: 추가 시도. 최대치 도달이면 `null` 반환(차단).
|
|
112
|
+
*
|
|
113
|
+
* 호출 측은 `null` 여부만 확인하면 되며 maxSelection 도메인 규칙을 알 필요가 없다.
|
|
114
|
+
*/
|
|
115
|
+
const tryToggle = (0, _react.useCallback)((optionId, currentArray) => {
|
|
116
|
+
const base = Array.isArray(currentArray) ? currentArray : [];
|
|
117
|
+
const idx = base.indexOf(optionId);
|
|
118
|
+
if (idx > -1) {
|
|
119
|
+
const next = [...base];
|
|
120
|
+
next.splice(idx, 1);
|
|
121
|
+
return next;
|
|
122
|
+
}
|
|
123
|
+
if (!canAdd(base.length)) return null;
|
|
124
|
+
return [...base, optionId];
|
|
125
|
+
}, [canAdd]);
|
|
126
|
+
return (0, _react.useMemo)(() => ({
|
|
73
127
|
isAllSelected,
|
|
74
128
|
buttonText,
|
|
75
129
|
toggleSelectAll,
|
|
76
130
|
getSelectedTagsData,
|
|
77
|
-
removeTag
|
|
78
|
-
|
|
131
|
+
removeTag,
|
|
132
|
+
isMaxSelectionActive,
|
|
133
|
+
isMaxReached,
|
|
134
|
+
tryToggle
|
|
135
|
+
}), [isAllSelected, buttonText, toggleSelectAll, getSelectedTagsData, removeTag, isMaxSelectionActive, isMaxReached, tryToggle]);
|
|
79
136
|
};
|
|
80
137
|
exports.useMultiSelect = useMultiSelect;
|
|
@@ -0,0 +1,80 @@
|
|
|
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 {
|
|
22
|
+
theme,
|
|
23
|
+
color,
|
|
24
|
+
size,
|
|
25
|
+
className,
|
|
26
|
+
svgString
|
|
27
|
+
} = this.options;
|
|
28
|
+
// React FeaturedIcon과 동일한 클래스 구조
|
|
29
|
+
const classes = ['ncua-featured-icon', `ncua-featured-icon--${theme}`, `ncua-featured-icon--${color}`, `ncua-featured-icon--${size}`];
|
|
30
|
+
if (className) {
|
|
31
|
+
classes.push(className);
|
|
32
|
+
}
|
|
33
|
+
const div = document.createElement('div');
|
|
34
|
+
div.className = classes.join(' ');
|
|
35
|
+
// outline-circle 테마일 때 추가 요소들 (React 컴포넌트와 동일)
|
|
36
|
+
if (theme === 'outline-circle') {
|
|
37
|
+
const innerOutline = document.createElement('div');
|
|
38
|
+
innerOutline.className = 'ncua-featured-icon__outline ncua-featured-icon__outline--inner';
|
|
39
|
+
div.appendChild(innerOutline);
|
|
40
|
+
const outerOutline = document.createElement('div');
|
|
41
|
+
outerOutline.className = 'ncua-featured-icon__outline ncua-featured-icon__outline--outer';
|
|
42
|
+
div.appendChild(outerOutline);
|
|
43
|
+
}
|
|
44
|
+
// SVG 아이콘 추가
|
|
45
|
+
const iconSize = iconSizeMap[size];
|
|
46
|
+
const svgWithSize = this.addSizeToSvg(svgString, iconSize);
|
|
47
|
+
div.innerHTML += svgWithSize;
|
|
48
|
+
return div;
|
|
49
|
+
}
|
|
50
|
+
addSizeToSvg(svgString, size) {
|
|
51
|
+
return svgString.replace(/<svg([^>]*)>/, `<svg$1 width="${size}" height="${size}">`);
|
|
52
|
+
}
|
|
53
|
+
// Public methods
|
|
54
|
+
getElement() {
|
|
55
|
+
return this.element;
|
|
56
|
+
}
|
|
57
|
+
updateColor(color) {
|
|
58
|
+
this.element.className = this.element.className.replace(/ncua-featured-icon--(neutral|error|warning|success)/, `ncua-featured-icon--${color}`);
|
|
59
|
+
this.options.color = color;
|
|
60
|
+
}
|
|
61
|
+
updateSize(size) {
|
|
62
|
+
const iconSize = iconSizeMap[size];
|
|
63
|
+
this.element.className = this.element.className.replace(/ncua-featured-icon--(sm|md|lg|xl)/, `ncua-featured-icon--${size}`);
|
|
64
|
+
const svgIcon = this.element.querySelector('svg');
|
|
65
|
+
if (svgIcon) {
|
|
66
|
+
svgIcon.setAttribute('width', String(iconSize));
|
|
67
|
+
svgIcon.setAttribute('height', String(iconSize));
|
|
68
|
+
}
|
|
69
|
+
this.options.size = size;
|
|
70
|
+
}
|
|
71
|
+
destroy() {
|
|
72
|
+
if (this.element.parentNode) {
|
|
73
|
+
this.element.parentNode.removeChild(this.element);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Static factory method
|
|
77
|
+
static create(options) {
|
|
78
|
+
return new FeaturedIcon(options);
|
|
79
|
+
}
|
|
80
|
+
}
|