@ncds/ui-admin 1.8.21-alpha.0 β 1.8.21-alpha.10
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/notification/FullWidthNotification.js +17 -6
- package/dist/cjs/assets/scripts/notification/MessageNotification.js +10 -48
- package/dist/cjs/assets/scripts/notification/const/classNames.js +3 -0
- package/dist/cjs/assets/scripts/notification/const/index.js +1 -1
- package/dist/cjs/assets/scripts/notification/const/sizes.js +4 -2
- package/dist/cjs/assets/scripts/notification/messageTemplate.js +106 -0
- package/dist/cjs/assets/scripts/notification/utils.js +40 -4
- package/dist/cjs/constant/notification.js +21 -0
- package/dist/cjs/src/components/forms-and-input/input-base/InputBase.js +52 -34
- package/dist/cjs/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +228 -0
- package/dist/cjs/src/components/forms-and-input/password-input/PasswordInput.js +3 -2
- package/dist/cjs/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js +59 -0
- package/dist/cjs/src/components/index.js +22 -0
- package/dist/cjs/src/components/layout/ncua-scope/NcuaScope.js +79 -0
- package/dist/cjs/src/components/layout/ncua-scope/index.js +16 -0
- package/dist/cjs/src/components/navigation/pagination/Pagination.js +3 -1
- package/dist/cjs/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
- package/dist/cjs/src/components/overlays/notification/FullWidthNotification.js +3 -1
- package/dist/cjs/src/components/overlays/notification/MessageNotification.js +14 -54
- package/dist/cjs/src/components/overlays/notification/MessageNotificationParts.js +92 -0
- package/dist/cjs/src/components/overlays/notification/__tests__/MessageNotification.test.js +246 -0
- package/dist/cjs/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +209 -0
- package/dist/cjs/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +259 -0
- package/dist/cjs/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +70 -0
- package/dist/cjs/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +623 -0
- package/dist/cjs/src/components/overlays/postcode-search-modal/index.js +16 -0
- package/dist/cjs/src/generated/scoped-css.js +9 -0
- package/dist/esm/assets/scripts/notification/FullWidthNotification.js +17 -6
- package/dist/esm/assets/scripts/notification/MessageNotification.js +12 -50
- package/dist/esm/assets/scripts/notification/const/classNames.js +3 -0
- package/dist/esm/assets/scripts/notification/const/index.js +3 -2
- package/dist/esm/assets/scripts/notification/const/sizes.js +4 -2
- package/dist/esm/assets/scripts/notification/messageTemplate.js +100 -0
- package/dist/esm/assets/scripts/notification/utils.js +39 -4
- package/dist/esm/constant/notification.js +15 -0
- package/dist/esm/src/components/forms-and-input/input-base/InputBase.js +52 -34
- package/dist/esm/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +228 -0
- package/dist/esm/src/components/forms-and-input/password-input/PasswordInput.js +3 -2
- package/dist/esm/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js +56 -0
- package/dist/esm/src/components/index.js +2 -0
- package/dist/esm/src/components/layout/ncua-scope/NcuaScope.js +73 -0
- package/dist/esm/src/components/layout/ncua-scope/index.js +1 -0
- package/dist/esm/src/components/navigation/pagination/Pagination.js +3 -1
- package/dist/esm/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
- package/dist/esm/src/components/overlays/notification/FullWidthNotification.js +3 -1
- package/dist/esm/src/components/overlays/notification/MessageNotification.js +15 -55
- package/dist/esm/src/components/overlays/notification/MessageNotificationParts.js +85 -0
- package/dist/esm/src/components/overlays/notification/__tests__/MessageNotification.test.js +243 -0
- package/dist/esm/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +206 -0
- package/dist/esm/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +252 -0
- package/dist/esm/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +63 -0
- package/dist/esm/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +620 -0
- package/dist/esm/src/components/overlays/postcode-search-modal/index.js +1 -0
- package/dist/esm/src/generated/scoped-css.js +3 -0
- package/dist/temp/assets/scripts/notification/FullWidthNotification.d.ts +6 -0
- package/dist/temp/assets/scripts/notification/FullWidthNotification.js +14 -5
- package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +0 -3
- package/dist/temp/assets/scripts/notification/MessageNotification.js +9 -44
- package/dist/temp/assets/scripts/notification/const/classNames.d.ts +1 -0
- package/dist/temp/assets/scripts/notification/const/classNames.js +3 -0
- package/dist/temp/assets/scripts/notification/const/index.d.ts +3 -3
- package/dist/temp/assets/scripts/notification/const/index.js +3 -2
- package/dist/temp/assets/scripts/notification/const/sizes.d.ts +2 -2
- package/dist/temp/assets/scripts/notification/const/sizes.js +4 -2
- package/dist/temp/assets/scripts/notification/const/types.d.ts +30 -2
- package/dist/temp/assets/scripts/notification/messageTemplate.d.ts +15 -0
- package/dist/temp/assets/scripts/notification/messageTemplate.js +79 -0
- package/dist/temp/assets/scripts/notification/utils.d.ts +19 -2
- package/dist/temp/assets/scripts/notification/utils.js +39 -5
- package/dist/temp/constant/notification.d.ts +15 -0
- package/dist/temp/constant/notification.js +15 -0
- package/dist/temp/src/components/forms-and-input/input-base/InputBase.d.ts +1 -1
- package/dist/temp/src/components/forms-and-input/input-base/InputBase.js +43 -26
- package/dist/temp/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +174 -0
- package/dist/temp/src/components/forms-and-input/password-input/PasswordInput.js +2 -1
- package/dist/temp/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.d.ts +1 -0
- package/dist/temp/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js +48 -0
- package/dist/temp/src/components/index.d.ts +2 -0
- package/dist/temp/src/components/index.js +2 -0
- package/dist/temp/src/components/layout/ncua-scope/NcuaScope.d.ts +32 -0
- package/dist/temp/src/components/layout/ncua-scope/NcuaScope.js +51 -0
- package/dist/temp/src/components/layout/ncua-scope/index.d.ts +1 -0
- package/dist/temp/src/components/layout/ncua-scope/index.js +1 -0
- package/dist/temp/src/components/navigation/pagination/Pagination.js +3 -1
- package/dist/temp/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
- package/dist/temp/src/components/overlays/notification/FullWidthNotification.d.ts +6 -0
- package/dist/temp/src/components/overlays/notification/FullWidthNotification.js +3 -2
- package/dist/temp/src/components/overlays/notification/MessageNotification.d.ts +6 -0
- package/dist/temp/src/components/overlays/notification/MessageNotification.js +4 -13
- package/dist/temp/src/components/overlays/notification/MessageNotificationParts.d.ts +28 -0
- package/dist/temp/src/components/overlays/notification/MessageNotificationParts.js +28 -0
- package/dist/temp/src/components/overlays/notification/Notification.d.ts +11 -2
- package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.d.ts +1 -0
- package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.js +190 -0
- package/dist/temp/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.d.ts +1 -0
- package/dist/temp/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +160 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModal.d.ts +45 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +125 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.d.ts +16 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +24 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.d.ts +1 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +503 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/index.d.ts +1 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/index.js +1 -0
- package/dist/temp/src/generated/scoped-css.d.ts +1 -0
- package/dist/temp/src/generated/scoped-css.js +3 -0
- package/dist/types/assets/scripts/notification/FullWidthNotification.d.ts +6 -0
- package/dist/types/assets/scripts/notification/MessageNotification.d.ts +0 -3
- package/dist/types/assets/scripts/notification/const/classNames.d.ts +1 -0
- package/dist/types/assets/scripts/notification/const/index.d.ts +3 -3
- package/dist/types/assets/scripts/notification/const/sizes.d.ts +2 -2
- package/dist/types/assets/scripts/notification/const/types.d.ts +30 -2
- package/dist/types/assets/scripts/notification/messageTemplate.d.ts +15 -0
- package/dist/types/assets/scripts/notification/utils.d.ts +19 -2
- package/dist/types/constant/notification.d.ts +15 -0
- package/dist/types/src/components/forms-and-input/input-base/InputBase.d.ts +1 -1
- package/dist/types/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.d.ts +1 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/layout/ncua-scope/NcuaScope.d.ts +32 -0
- package/dist/types/src/components/layout/ncua-scope/index.d.ts +1 -0
- package/dist/types/src/components/overlays/notification/FullWidthNotification.d.ts +6 -0
- package/dist/types/src/components/overlays/notification/MessageNotification.d.ts +6 -0
- package/dist/types/src/components/overlays/notification/MessageNotificationParts.d.ts +28 -0
- package/dist/types/src/components/overlays/notification/Notification.d.ts +11 -2
- package/dist/types/src/components/overlays/notification/__tests__/MessageNotification.test.d.ts +1 -0
- package/dist/types/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.d.ts +1 -0
- package/dist/types/src/components/overlays/postcode-search-modal/PostcodeSearchModal.d.ts +45 -0
- package/dist/types/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.d.ts +16 -0
- package/dist/types/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.d.ts +1 -0
- package/dist/types/src/components/overlays/postcode-search-modal/index.d.ts +1 -0
- package/dist/types/src/generated/scoped-css.d.ts +1 -0
- package/dist/ui-admin/assets/styles/style.css +296 -56
- package/dist/ui-admin/assets/styles/style.scoped.css +8595 -0
- package/package.json +13 -6
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _uiAdminIcon = require("@ncds/ui-admin-icon");
|
|
3
4
|
var _react = require("react");
|
|
4
5
|
var _client = require("react-dom/client");
|
|
5
6
|
var _testUtils = require("react-dom/test-utils");
|
|
6
7
|
var _vitest = require("vitest");
|
|
8
|
+
var _color = require("../../../../../constant/color");
|
|
7
9
|
var _InputBase = require("../InputBase");
|
|
8
10
|
// @vitest-environment jsdom
|
|
9
11
|
|
|
@@ -69,4 +71,230 @@ function mountInputBase() {
|
|
|
69
71
|
(0, _vitest.expect)(view.container.querySelector('.ncua-input__clear')).toBeNull();
|
|
70
72
|
view.unmount();
|
|
71
73
|
});
|
|
74
|
+
});
|
|
75
|
+
(0, _vitest.describe)('InputBase β μμ΄μ½ μ¬μ΄μ¦', () => {
|
|
76
|
+
const iconSizeOf = (container, selector) => {
|
|
77
|
+
const svg = container.querySelector(selector);
|
|
78
|
+
return {
|
|
79
|
+
width: svg?.getAttribute('width'),
|
|
80
|
+
height: svg?.getAttribute('height')
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
// μ¬λ‘― μμ΄μ½κ³Ό μν μμ΄μ½μ κ°μ ν¬κΈ°λ₯Ό μ΄λ€ β κ³Όκ±° μν μμ΄μ½λ§ sm=16μΌλ‘ μ΄κΈλ μμλ€
|
|
84
|
+
_vitest.it.each([['xs', '14'], ['sm', '20']])('size=%s μΌ λ μ¬λ‘― μμ΄μ½κ³Ό μν μμ΄μ½μ΄ λͺ¨λ %spxλ‘ λ λλλ€', (size, expected) => {
|
|
85
|
+
// Given/When: μ¬λ‘― μμ΄μ½κ³Ό clear λ²νΌ, destructive μνλ₯Ό ν¨κ» λ λνλ©΄
|
|
86
|
+
const view = mountInputBase({
|
|
87
|
+
size,
|
|
88
|
+
destructive: true,
|
|
89
|
+
clearText: true,
|
|
90
|
+
onClearText: _vitest.vi.fn(),
|
|
91
|
+
leadingElement: {
|
|
92
|
+
type: 'icon',
|
|
93
|
+
icon: _uiAdminIcon.SearchLg
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
// Then: μ¬λ‘―Β·clearΒ·destructive μμ΄μ½μ ν¬κΈ°κ° μλ‘ μ΄κΈλμ§ μλλ€
|
|
97
|
+
const expectedSize = {
|
|
98
|
+
width: expected,
|
|
99
|
+
height: expected
|
|
100
|
+
};
|
|
101
|
+
(0, _vitest.expect)(iconSizeOf(view.container, '.ncua-input__left-icon')).toEqual(expectedSize);
|
|
102
|
+
(0, _vitest.expect)(iconSizeOf(view.container, '.ncua-input__clear-icon')).toEqual(expectedSize);
|
|
103
|
+
(0, _vitest.expect)(iconSizeOf(view.container, '.ncua-input__destructive-icon')).toEqual(expectedSize);
|
|
104
|
+
view.unmount();
|
|
105
|
+
});
|
|
106
|
+
_vitest.it.each([['xs', '14'], ['sm', '20']])('size=%s μΌ λ validation μμ΄μ½λ %spxλ‘ λ λλλ€', (size, expected) => {
|
|
107
|
+
// Given/When: validation μνλ‘ λ λνλ©΄
|
|
108
|
+
const view = mountInputBase({
|
|
109
|
+
size,
|
|
110
|
+
validation: true
|
|
111
|
+
});
|
|
112
|
+
// Then: λ€λ₯Έ μμ΄μ½κ³Ό κ°μ ν¬κΈ°λ€
|
|
113
|
+
(0, _vitest.expect)(iconSizeOf(view.container, '.ncua-input__validation-icon')).toEqual({
|
|
114
|
+
width: expected,
|
|
115
|
+
height: expected
|
|
116
|
+
});
|
|
117
|
+
view.unmount();
|
|
118
|
+
});
|
|
119
|
+
(0, _vitest.it)('slot.sizeλ₯Ό μ§μ μ£Όλ©΄ κΈ°λ³Έ μ¬μ΄μ¦λ³΄λ€ μ°μ νλ€', () => {
|
|
120
|
+
// Given/When: μ¬λ‘―μ sizeλ₯Ό λͺ
μν΄ λ λνλ©΄
|
|
121
|
+
const view = mountInputBase({
|
|
122
|
+
size: 'xs',
|
|
123
|
+
leadingElement: {
|
|
124
|
+
type: 'icon',
|
|
125
|
+
icon: _uiAdminIcon.SearchLg,
|
|
126
|
+
size: 24
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
// Then: κΈ°λ³Έκ°(14)μ΄ μλλΌ λͺ
μν κ°μ΄ μ μ©λλ€
|
|
130
|
+
(0, _vitest.expect)(iconSizeOf(view.container, '.ncua-input__left-icon')).toEqual({
|
|
131
|
+
width: '24',
|
|
132
|
+
height: '24'
|
|
133
|
+
});
|
|
134
|
+
view.unmount();
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
(0, _vitest.describe)('InputBase β μ¬λ‘― μμ΄μ½ μν μμ', () => {
|
|
138
|
+
// μνλ³ μμ CSS κ° κ²°μ νλ€. jsdom μμλ μ€νμΌμνΈλ₯Ό λ‘λνμ§ μμΌλ―λ‘
|
|
139
|
+
// "μν κ·μΉμ νλ ν΄λμ€κ° λΆμλμ§" μ "μ§μ μμ΄ μΈλΌμΈμΌλ‘ λ¨μλμ§" λ‘ κ²μ¦νλ€.
|
|
140
|
+
const leftIconOf = container => container.querySelector('.ncua-input__left-icon');
|
|
141
|
+
(0, _vitest.it)('color λ₯Ό μ§μ νμ§ μμΌλ©΄ μν μμ ν΄λμ€κ° λΆλλ€', () => {
|
|
142
|
+
// Given/When: color μμ΄ μ¬λ‘― μμ΄μ½μ λ λνλ©΄
|
|
143
|
+
const view = mountInputBase({
|
|
144
|
+
leadingElement: {
|
|
145
|
+
type: 'icon',
|
|
146
|
+
icon: _uiAdminIcon.SearchLg
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
// Then: μν κ·μΉμ νλ ν΄λμ€κ° λΆκ³ , μΈλΌμΈ μμ μ§μ λμ§ μλλ€
|
|
150
|
+
const icon = leftIconOf(view.container);
|
|
151
|
+
(0, _vitest.expect)(icon?.classList.contains('ncua-input__slot-icon')).toBe(true);
|
|
152
|
+
(0, _vitest.expect)(icon?.hasAttribute('color')).toBe(false);
|
|
153
|
+
view.unmount();
|
|
154
|
+
});
|
|
155
|
+
(0, _vitest.it)('color λ₯Ό μ§μ νλ©΄ μν μμ ν΄λμ€κ° λΆμ§ μκ³ μ§μ μμ΄ μ μ§λλ€', () => {
|
|
156
|
+
// Given/When: color λ₯Ό μ§μ ν΄ λ λνλ©΄
|
|
157
|
+
const view = mountInputBase({
|
|
158
|
+
leadingElement: {
|
|
159
|
+
type: 'icon',
|
|
160
|
+
icon: _uiAdminIcon.SearchLg,
|
|
161
|
+
color: 'blue500'
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
// Then: μν κ·μΉμμ μ μΈλκ³ μ§μ ν μμ΄ κ·Έλλ‘ λ¨λλ€
|
|
165
|
+
const icon = leftIconOf(view.container);
|
|
166
|
+
(0, _vitest.expect)(icon?.classList.contains('ncua-input__slot-icon')).toBe(false);
|
|
167
|
+
(0, _vitest.expect)(icon?.getAttribute('color')).toBe(_color.COLOR.blue500);
|
|
168
|
+
view.unmount();
|
|
169
|
+
});
|
|
170
|
+
(0, _vitest.it)('slot.className μ ν¨κ» μ£Όμ΄λ μν μμ ν΄λμ€κ° μ μ§λλ€', () => {
|
|
171
|
+
// Given/When: className μ μΆκ°λ‘ λκΈ°λ©΄
|
|
172
|
+
const view = mountInputBase({
|
|
173
|
+
leadingElement: {
|
|
174
|
+
type: 'icon',
|
|
175
|
+
icon: _uiAdminIcon.SearchLg,
|
|
176
|
+
className: 'my-icon'
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
// Then: λ ν΄λμ€κ° λͺ¨λ λΆλλ€
|
|
180
|
+
const icon = leftIconOf(view.container);
|
|
181
|
+
(0, _vitest.expect)(icon?.classList.contains('ncua-input__slot-icon')).toBe(true);
|
|
182
|
+
(0, _vitest.expect)(icon?.classList.contains('my-icon')).toBe(true);
|
|
183
|
+
view.unmount();
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
(0, _vitest.describe)('InputBase β has-value μν ν΄λμ€', () => {
|
|
187
|
+
const typeInto = (container, text) => {
|
|
188
|
+
const input = container.querySelector('input');
|
|
189
|
+
if (!input) throw new Error('inputμ΄ λ λλμ§ μμμ΅λλ€');
|
|
190
|
+
(0, _testUtils.act)(() => {
|
|
191
|
+
input.value = text;
|
|
192
|
+
input.dispatchEvent(new Event('input', {
|
|
193
|
+
bubbles: true
|
|
194
|
+
}));
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
(0, _vitest.it)('κ°μ΄ λΉμ΄ μμΌλ©΄ has-valueκ° λΆμ§ μλλ€', () => {
|
|
198
|
+
// Given/When: λΉ μνλ‘ λ λνλ©΄
|
|
199
|
+
const view = mountInputBase();
|
|
200
|
+
// Then: 루νΈμ has-valueκ° μλ€
|
|
201
|
+
(0, _vitest.expect)(view.container.querySelector('.ncua-input')?.classList.contains('has-value')).toBe(false);
|
|
202
|
+
view.unmount();
|
|
203
|
+
});
|
|
204
|
+
// props.value λ‘ νμ νλ©΄ uncontrolled μμ μμν λΉ κ°μΌλ‘ 보μΈλ€ β μλ¬Όμ μμ΄μ½ μμμ΄ λ°μλμ§ μλ μμΈ
|
|
205
|
+
(0, _vitest.it)('uncontrolled Inputμ μ
λ ₯νλ©΄ has-valueκ° λΆλλ€', () => {
|
|
206
|
+
// Given: valueλ₯Ό λκΈ°μ§ μμ uncontrolled μνμμ
|
|
207
|
+
const view = mountInputBase();
|
|
208
|
+
// When: μ€μ λ‘ μ
λ ₯νλ©΄
|
|
209
|
+
typeInto(view.container, 'hello');
|
|
210
|
+
// Then: has-valueκ° λΆλλ€
|
|
211
|
+
(0, _vitest.expect)(view.container.querySelector('.ncua-input')?.classList.contains('has-value')).toBe(true);
|
|
212
|
+
view.unmount();
|
|
213
|
+
});
|
|
214
|
+
(0, _vitest.it)('μ
λ ₯κ°μ μ§μ°λ©΄ has-valueκ° λ¨μ΄μ§λ€', () => {
|
|
215
|
+
// Given: κ°μ΄ μλ μνμμ
|
|
216
|
+
const view = mountInputBase();
|
|
217
|
+
typeInto(view.container, 'hello');
|
|
218
|
+
// When: κ°μ λΉμ°λ©΄
|
|
219
|
+
typeInto(view.container, '');
|
|
220
|
+
// Then: has-valueκ° μ¬λΌμ§λ€
|
|
221
|
+
(0, _vitest.expect)(view.container.querySelector('.ncua-input')?.classList.contains('has-value')).toBe(false);
|
|
222
|
+
view.unmount();
|
|
223
|
+
});
|
|
224
|
+
(0, _vitest.it)('controlled Inputμ value propλ§μΌλ‘λ has-valueκ° λΆλλ€', () => {
|
|
225
|
+
// Given/When: valueλ₯Ό μ§μ λ겨 λ λνλ©΄ (input μ΄λ²€νΈ μμ΄)
|
|
226
|
+
const view = mountInputBase({
|
|
227
|
+
value: 'preset',
|
|
228
|
+
onChange: _vitest.vi.fn()
|
|
229
|
+
});
|
|
230
|
+
// Then: has-valueκ° λΆλλ€
|
|
231
|
+
(0, _vitest.expect)(view.container.querySelector('.ncua-input')?.classList.contains('has-value')).toBe(true);
|
|
232
|
+
view.unmount();
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
(0, _vitest.describe)('InputBase β ν
μ€νΈ μ¬λ‘―', () => {
|
|
236
|
+
(0, _vitest.it)('leadingElement ν
μ€νΈλ leading ν΄λμ€μ wrap ν΄λμ€κ° λΆλλ€', () => {
|
|
237
|
+
const {
|
|
238
|
+
container,
|
|
239
|
+
unmount
|
|
240
|
+
} = mountInputBase({
|
|
241
|
+
leadingElement: {
|
|
242
|
+
type: 'text',
|
|
243
|
+
text: 'https://'
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
const text = container.querySelector('.ncua-input__leading-text');
|
|
247
|
+
(0, _vitest.expect)(text?.textContent).toBe('https://');
|
|
248
|
+
(0, _vitest.expect)(container.querySelector('.ncua-input__leading-text-wrap')).not.toBeNull();
|
|
249
|
+
unmount();
|
|
250
|
+
});
|
|
251
|
+
(0, _vitest.it)('trailingElement ν
μ€νΈλ trailing ν΄λμ€μ wrap ν΄λμ€κ° λΆλλ€', () => {
|
|
252
|
+
const {
|
|
253
|
+
container,
|
|
254
|
+
unmount
|
|
255
|
+
} = mountInputBase({
|
|
256
|
+
trailingElement: {
|
|
257
|
+
type: 'text',
|
|
258
|
+
text: 'px'
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
const text = container.querySelector('.ncua-input__trailing-text');
|
|
262
|
+
(0, _vitest.expect)(text?.textContent).toBe('px');
|
|
263
|
+
(0, _vitest.expect)(container.querySelector('.ncua-input__trailing-text-wrap')).not.toBeNull();
|
|
264
|
+
// leading ν΄λμ€κ° μμ΄λ©΄ λͺ¨μ리·ν
λ리 λ°©ν₯μ΄ λ°λκ° λλ€
|
|
265
|
+
(0, _vitest.expect)(container.querySelector('.ncua-input__leading-text')).toBeNull();
|
|
266
|
+
unmount();
|
|
267
|
+
});
|
|
268
|
+
(0, _vitest.it)('trailingElement ν
μ€νΈλ μ
λ ₯ νλ λ€μ μ¨λ€', () => {
|
|
269
|
+
const {
|
|
270
|
+
container,
|
|
271
|
+
unmount
|
|
272
|
+
} = mountInputBase({
|
|
273
|
+
trailingElement: {
|
|
274
|
+
type: 'text',
|
|
275
|
+
text: 'px'
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
const content = container.querySelector('.ncua-input__content');
|
|
279
|
+
const children = Array.from(content?.children ?? []);
|
|
280
|
+
const fieldIndex = children.findIndex(el => el.classList.contains('ncua-input__field'));
|
|
281
|
+
const textIndex = children.findIndex(el => el.classList.contains('ncua-input__trailing-text'));
|
|
282
|
+
(0, _vitest.expect)(fieldIndex).toBeGreaterThanOrEqual(0);
|
|
283
|
+
(0, _vitest.expect)(textIndex).toBeGreaterThan(fieldIndex);
|
|
284
|
+
unmount();
|
|
285
|
+
});
|
|
286
|
+
(0, _vitest.it)('μ¬μ΄μ¦ modifier κ° ν¨κ» λΆλλ€', () => {
|
|
287
|
+
const {
|
|
288
|
+
container,
|
|
289
|
+
unmount
|
|
290
|
+
} = mountInputBase({
|
|
291
|
+
size: 'sm',
|
|
292
|
+
trailingElement: {
|
|
293
|
+
type: 'text',
|
|
294
|
+
text: 'px'
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
(0, _vitest.expect)(container.querySelector('.ncua-input__trailing-text--sm')).not.toBeNull();
|
|
298
|
+
unmount();
|
|
299
|
+
});
|
|
72
300
|
});
|
|
@@ -33,8 +33,9 @@ const PasswordInput = exports.PasswordInput = /*#__PURE__*/(0, _react.forwardRef
|
|
|
33
33
|
type: isVisible ? 'text' : 'password',
|
|
34
34
|
leadingElement: {
|
|
35
35
|
type: 'icon',
|
|
36
|
-
icon: _uiAdminIcon.Lock01
|
|
37
|
-
color
|
|
36
|
+
icon: _uiAdminIcon.Lock01
|
|
37
|
+
// color λ₯Ό λκΈ°μ§ μμ μ¬λ‘― μμ΄μ½ κ³΅ν΅ κ·μΉ(μνλ³ μ)μ κ·Έλλ‘ λ°λ₯Έλ€.
|
|
38
|
+
// μ¬κΈ°μ props.value λ‘ νμ νλ©΄ uncontrolled Input μμ μμν λΉ κ° μ·¨κΈλλ€.
|
|
38
39
|
},
|
|
39
40
|
trailingElement: {
|
|
40
41
|
type: 'custom',
|
package/dist/cjs/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = require("react");
|
|
4
|
+
var _client = require("react-dom/client");
|
|
5
|
+
var _testUtils = require("react-dom/test-utils");
|
|
6
|
+
var _vitest = require("vitest");
|
|
7
|
+
var _PasswordInput = require("../PasswordInput");
|
|
8
|
+
// @vitest-environment jsdom
|
|
9
|
+
|
|
10
|
+
// React 18μμ act() μ¬μ© μ νμν νλκ·Έ (λ―Έμ€μ μ console.error κ²½κ³ λ°μ)
|
|
11
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
12
|
+
function mountPasswordInput() {
|
|
13
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
14
|
+
const container = document.createElement('div');
|
|
15
|
+
document.body.appendChild(container);
|
|
16
|
+
const root = (0, _client.createRoot)(container);
|
|
17
|
+
(0, _testUtils.act)(() => {
|
|
18
|
+
root.render(/*#__PURE__*/(0, _react.createElement)(_PasswordInput.PasswordInput, props));
|
|
19
|
+
});
|
|
20
|
+
const unmount = () => {
|
|
21
|
+
(0, _testUtils.act)(() => {
|
|
22
|
+
root.unmount();
|
|
23
|
+
});
|
|
24
|
+
container.remove();
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
container,
|
|
28
|
+
unmount
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
(0, _vitest.describe)('PasswordInput β μλ¬Όμ μμ΄μ½ μμ', () => {
|
|
32
|
+
// μλ¬Όμ μμ CSS κ° κ²°μ νλ€. μΈλΌμΈ color λ₯Ό λκΈ°λ©΄ μν κ·μΉμ΄ 무μλλ―λ‘,
|
|
33
|
+
// "μΈλΌμΈ μμ΄ μκ³ μ¬λ‘― μμ΄μ½ κ³΅ν΅ ν΄λμ€λ₯Ό νλ€" λ κ²μ΄ μμ λ°μμ μ μ λ€.
|
|
34
|
+
(0, _vitest.it)('μλ¬Όμ μ μΈλΌμΈ μμ λκΈ°μ§ μκ³ μ¬λ‘― μμ΄μ½ κ³΅ν΅ ν΄λμ€λ₯Ό νλ€', () => {
|
|
35
|
+
// Given/When: κΈ°λ³Έ μνλ‘ λ λνλ©΄
|
|
36
|
+
const view = mountPasswordInput();
|
|
37
|
+
// Then: μν κ·μΉμ νλ ν΄λμ€κ° λΆκ³ μΈλΌμΈ μμ μλ€
|
|
38
|
+
const lockIcon = view.container.querySelector('.ncua-input__left-icon');
|
|
39
|
+
(0, _vitest.expect)(lockIcon).not.toBeNull();
|
|
40
|
+
(0, _vitest.expect)(lockIcon?.classList.contains('ncua-input__slot-icon')).toBe(true);
|
|
41
|
+
(0, _vitest.expect)(lockIcon?.hasAttribute('color')).toBe(false);
|
|
42
|
+
view.unmount();
|
|
43
|
+
});
|
|
44
|
+
// κ°μ΄ μλ μ±λ‘ λΉνμ±νλλ©΄ has-value κ° μ΄μ μμ΄ μλ¬Όμ κ° μ§νκ² λ¨λ λ¬Έμ
|
|
45
|
+
(0, _vitest.it)('κ°μ΄ μλ μ±λ‘ disabled μ¬λ μλ¬Όμ κ° μν κ·μΉ λμμΌλ‘ λ¨λλ€', () => {
|
|
46
|
+
// Given/When: κ°μ΄ μλ λΉνμ±ν μνλ‘ λ λνλ©΄
|
|
47
|
+
const view = mountPasswordInput({
|
|
48
|
+
value: 'secret',
|
|
49
|
+
disabled: true,
|
|
50
|
+
onChange: _vitest.vi.fn()
|
|
51
|
+
});
|
|
52
|
+
// Then: 루νΈμ is-disabled μ has-value κ° ν¨κ» λΆκ³ , μλ¬Όμ λ κ³΅ν΅ ν΄λμ€λ₯Ό μ μ§νλ€
|
|
53
|
+
const root = view.container.querySelector('.ncua-input');
|
|
54
|
+
(0, _vitest.expect)(root?.classList.contains('is-disabled')).toBe(true);
|
|
55
|
+
(0, _vitest.expect)(root?.classList.contains('has-value')).toBe(true);
|
|
56
|
+
(0, _vitest.expect)(view.container.querySelector('.ncua-input__left-icon')?.classList.contains('ncua-input__slot-icon')).toBe(true);
|
|
57
|
+
view.unmount();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -388,6 +388,17 @@ Object.keys(_divider).forEach(function (key) {
|
|
|
388
388
|
}
|
|
389
389
|
});
|
|
390
390
|
});
|
|
391
|
+
var _ncuaScope = require("./layout/ncua-scope");
|
|
392
|
+
Object.keys(_ncuaScope).forEach(function (key) {
|
|
393
|
+
if (key === "default" || key === "__esModule") return;
|
|
394
|
+
if (key in exports && exports[key] === _ncuaScope[key]) return;
|
|
395
|
+
Object.defineProperty(exports, key, {
|
|
396
|
+
enumerable: true,
|
|
397
|
+
get: function () {
|
|
398
|
+
return _ncuaScope[key];
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
});
|
|
391
402
|
var _pageTitle = require("./layout/page-title");
|
|
392
403
|
Object.keys(_pageTitle).forEach(function (key) {
|
|
393
404
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -487,6 +498,17 @@ Object.keys(_notification).forEach(function (key) {
|
|
|
487
498
|
}
|
|
488
499
|
});
|
|
489
500
|
});
|
|
501
|
+
var _postcodeSearchModal = require("./overlays/postcode-search-modal");
|
|
502
|
+
Object.keys(_postcodeSearchModal).forEach(function (key) {
|
|
503
|
+
if (key === "default" || key === "__esModule") return;
|
|
504
|
+
if (key in exports && exports[key] === _postcodeSearchModal[key]) return;
|
|
505
|
+
Object.defineProperty(exports, key, {
|
|
506
|
+
enumerable: true,
|
|
507
|
+
get: function () {
|
|
508
|
+
return _postcodeSearchModal[key];
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
});
|
|
490
512
|
var _tooltip = require("./overlays/tooltip");
|
|
491
513
|
Object.keys(_tooltip).forEach(function (key) {
|
|
492
514
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.NcuaScope = void 0;
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _scopedCss = require("../../../generated/scoped-css");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
// μ‘°μμ NcuaScope κ° μ΄λ―Έ μμΌλ©΄ μ€νμΌμ λ€μ μ¬μ§ μλλ€ (μ€μ²© λμ).
|
|
14
|
+
const NcuaStyleMountedContext = /*#__PURE__*/(0, _react.createContext)(false);
|
|
15
|
+
// React 19 λ <style> μ hrefΒ·precedence κ° ν¨κ» μμΌλ©΄ <head> λ‘ μ¬λ¦¬κ³ href λ‘ μ€λ³΅μ
|
|
16
|
+
// μ κ±°νλ€. 18 μλ κ·Έ κΈ°λ₯λ, λ prop μ νμ
μ μλ μμ΄ Context λ‘ μ€μ²©λ§ λ§κ³
|
|
17
|
+
// νμ
μ μ°ννλ€.
|
|
18
|
+
const STYLE_HOISTING_MIN_REACT_MAJOR = 19;
|
|
19
|
+
const DECIMAL_RADIX = 10;
|
|
20
|
+
const SUPPORTS_STYLE_HOISTING = Number.parseInt(_react.version, DECIMAL_RADIX) >= STYLE_HOISTING_MIN_REACT_MAJOR;
|
|
21
|
+
const STYLE_KEY = 'ncua-scoped';
|
|
22
|
+
const STYLE_HOISTING_PROPS = {
|
|
23
|
+
href: STYLE_KEY,
|
|
24
|
+
precedence: 'default'
|
|
25
|
+
};
|
|
26
|
+
// SSR μ <style> μ μμ ν
μ€νΈλ₯Ό HTML μ΄μ€μΌμ΄ννμ§λ§(' -> '), λΈλΌμ°μ λ <style>
|
|
27
|
+
// μμ raw text λ‘ μ½μ΄ λλλ¦¬μ§ μλλ€. κ·Έλ¬λ©΄ CSS κ° κΉ¨μ§κ³ νμ΄λλ μ΄μ
λ λΆμΌμΉνλ€.
|
|
28
|
+
// innerHTML λ‘ λ£μΌλ©΄ μλ²κ° μλ¬Έ κ·Έλλ‘ λ΄λ³΄λΈλ€.
|
|
29
|
+
const STYLE_CONTENT = {
|
|
30
|
+
__html: _scopedCss.NCUA_SCOPED_CSS
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* NCUA μ€νμΌμ μ΄ μλ¦¬λ¨ΌνΈ νμλ‘ νμ νλ κ²½κ³.
|
|
34
|
+
*
|
|
35
|
+
* λ€λ₯Έ λμμΈ μμ€ν
μ μ μ μ μ©ν μ¬μ©μ²μμ NCUA μ»΄ν¬λνΈλ₯Ό μ΄κ±Έλ‘ κ°μΌλ€.
|
|
36
|
+
* μ€νμΌμ μ§μ λ€κ³ μμΌλ―λ‘ **CSS νμΌμ λ°λ‘ import νμ§ μλλ€.**
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* import { NcuaScope, Button } from '@ncds/ui-admin';
|
|
40
|
+
*
|
|
41
|
+
* <NcuaScope>
|
|
42
|
+
* <Button label="μ μ²νκΈ°" hierarchy="primary" size="md" />
|
|
43
|
+
* </NcuaScope>
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* `document.body` λ‘ portal λλ μ»΄ν¬λνΈ(Modal Β· Tooltip Β· Dropdown Β· SelectBox Β·
|
|
47
|
+
* Notification)λ μ΄ κ²½κ³ λ°μ λμ΄μ§λ§, μ€μ½ν μ€νμΌμνΈκ° κ·Έ λ£¨νΈ ν΄λμ€λ€μ ν¨κ»
|
|
48
|
+
* μ§μ νλ―λ‘ ν ν°μ λ°λλ€ (`base/_scope.scss` μ `$roots`). portal λͺ©μ μ§λ λ°λμ§
|
|
49
|
+
* μμΌλ―λ‘ μ΄λλ―Όμμμ κΈ°μ‘΄ λμκ³Ό κ°λ€.
|
|
50
|
+
*
|
|
51
|
+
* μ΄λλ―Όμ²λΌ `style.css` λ₯Ό μ μ μ μ©νλ μ¬μ©μ²λ μ΄ μ»΄ν¬λνΈκ° νμ μλ€.
|
|
52
|
+
*
|
|
53
|
+
* μ€μ²©ν΄μ μ¨λ μ€νμΌμ ν λ²λ§ λ€μ΄κ°λ€. React 19 μμλ νμ λ‘ μ¬λ¬ κ°λ₯Ό μ¨λ
|
|
54
|
+
* href κΈ°μ€μΌλ‘ μ€λ³΅μ΄ μ κ±°λλ€. React 18 μμλ νμ λ§λ€ `<style>` μ΄ νλμ© μκΈ°λ―λ‘,
|
|
55
|
+
* μ€μ½νκ° μ¬λ¬ κ³³μ νμνλ©΄ κ³΅ν΅ μ‘°μ ν κ³³μμ κ°μΈλ νΈμ΄ λ«λ€.
|
|
56
|
+
*/
|
|
57
|
+
const NcuaScope = exports.NcuaScope = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
58
|
+
let {
|
|
59
|
+
className,
|
|
60
|
+
children
|
|
61
|
+
} = _ref;
|
|
62
|
+
const styleAlreadyMounted = (0, _react.useContext)(NcuaStyleMountedContext);
|
|
63
|
+
const shouldRenderStyle = SUPPORTS_STYLE_HOISTING || !styleAlreadyMounted;
|
|
64
|
+
return (0, _jsxRuntime.jsxs)(NcuaStyleMountedContext.Provider, {
|
|
65
|
+
value: true,
|
|
66
|
+
children: [shouldRenderStyle && (SUPPORTS_STYLE_HOISTING ? (0, _jsxRuntime.jsx)("style", {
|
|
67
|
+
...STYLE_HOISTING_PROPS,
|
|
68
|
+
dangerouslySetInnerHTML: STYLE_CONTENT
|
|
69
|
+
}) : (0, _jsxRuntime.jsx)("style", {
|
|
70
|
+
"data-ncua-scope": STYLE_KEY,
|
|
71
|
+
dangerouslySetInnerHTML: STYLE_CONTENT
|
|
72
|
+
})), (0, _jsxRuntime.jsx)("div", {
|
|
73
|
+
ref: ref,
|
|
74
|
+
className: (0, _classnames.default)('ncua-scope', className),
|
|
75
|
+
children: children
|
|
76
|
+
})]
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
NcuaScope.displayName = 'NcuaScope';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _NcuaScope = require("./NcuaScope");
|
|
7
|
+
Object.keys(_NcuaScope).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _NcuaScope[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _NcuaScope[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -26,7 +26,9 @@ const Pagination = _ref => {
|
|
|
26
26
|
const [start, setStart] = (0, _react.useState)(1);
|
|
27
27
|
const noPrev = breakPoint === 'mo' ? currentPage === 1 : start === 1;
|
|
28
28
|
const noNext = breakPoint === 'mo' ? currentPage >= totalPage : start + pageCount - 1 >= totalPage;
|
|
29
|
-
|
|
29
|
+
// mo λ CSS κ° νμ΄μ§ λ²νΈ λͺ©λ‘κ³Ό first/last λ₯Ό μ¨κ²¨ prev/next λ§ λ¨λλ€.
|
|
30
|
+
// pc κΈ°μ€(totalPage > pageCount)μ κ·Έλλ‘ μ°λ©΄ νμ΄μ§κ° μ μ λ μ΄λ μλ¨μ΄ νλλ μλ€.
|
|
31
|
+
const showJumpPageButton = breakPoint === 'mo' ? totalPage > 1 : totalPage > pageCount;
|
|
30
32
|
const handleClickButton = pageNum => {
|
|
31
33
|
if ((0, _lodashEs.isFunction)(onPageChange)) {
|
|
32
34
|
onPageChange(pageNum);
|
|
@@ -15,6 +15,12 @@ const CURRENT_PAGE = 91; // 100νμ΄μ§ κΈ°μ€ λ§μ§λ§ κ·Έλ£Ή(91~100)μ 보
|
|
|
15
15
|
const GROUP_START_100_PAGES = 91; // currentPage=91 μΌ λμ κ·Έλ£Ή μμ
|
|
16
16
|
const GROUP_START_50_PAGES = 41; // totalPage=50 μΌλ‘ μ€μμ λμ λ§μ§λ§ κ·Έλ£Ή μμ
|
|
17
17
|
const LAST_PAGE_50 = 50;
|
|
18
|
+
/** νμ΄μ§ κ·Έλ£Ή ν¬κΈ°(10) μ΄νλ‘ λλλ 건μ β 3νμ΄μ§ */
|
|
19
|
+
const TOTAL_COUNT_3_PAGES = 30;
|
|
20
|
+
/** TOTAL_COUNT_3_PAGES κΈ°μ€ μ΄ νμ΄μ§ μ = λ§μ§λ§ νμ΄μ§ λ²νΈ */
|
|
21
|
+
const LAST_PAGE_3 = 3;
|
|
22
|
+
/** νμ΄μ§κ° νλλΏμΈ 건μ */
|
|
23
|
+
const TOTAL_COUNT_1_PAGE = 8;
|
|
18
24
|
let root = null;
|
|
19
25
|
let container = null;
|
|
20
26
|
function render(props) {
|
|
@@ -37,6 +43,8 @@ function render(props) {
|
|
|
37
43
|
container = null;
|
|
38
44
|
});
|
|
39
45
|
const pageNums = el => Array.from(el.querySelectorAll('.ncua-pagination__page-num')).map(b => Number(b.textContent));
|
|
46
|
+
const prevOf = el => el.querySelector('.ncua-pagination__before');
|
|
47
|
+
const nextOf = el => el.querySelector('.ncua-pagination__next');
|
|
40
48
|
(0, _vitest.describe)('#332 Pagination β totalPage μΆμ μ start 보μ ', () => {
|
|
41
49
|
(0, _vitest.it)('totalPage κ° μ€λ©΄ start λ₯Ό λ§μ§λ§ κ·Έλ£ΉμΌλ‘ 보μ νκ³ λ²μ λ° νμ΄μ§ λ²νΌμ νμνμ§ μλλ€', () => {
|
|
42
50
|
// 1) 100 νμ΄μ§μμ 91 νμ΄μ§ 보λ μ€ β 91~100 κ·Έλ£Ή νμ
|
|
@@ -59,4 +67,70 @@ const pageNums = el => Array.from(el.querySelectorAll('.ncua-pagination__page-nu
|
|
|
59
67
|
(0, _vitest.expect)(nums[0]).toBe(GROUP_START_50_PAGES);
|
|
60
68
|
(0, _vitest.expect)(Math.max(...nums)).toBeLessThanOrEqual(LAST_PAGE_50);
|
|
61
69
|
});
|
|
70
|
+
});
|
|
71
|
+
(0, _vitest.describe)('Pagination β mo λͺ¨λ μ΄μ /λ€μ λ²νΌ λ
ΈμΆ', () => {
|
|
72
|
+
(0, _vitest.it)('νμ΄μ§κ° κ·Έλ£Ή ν¬κΈ° μ΄νμ¬λ mo μμλ μ΄μ Β·λ€μ λ²νΌμ΄ λ
ΈμΆλλ€', () => {
|
|
73
|
+
// Given/When: 3νμ΄μ§(κ·Έλ£Ή ν¬κΈ° 10 μ΄ν) λΆλμ mo λ‘ λ λνλ©΄
|
|
74
|
+
const el = render({
|
|
75
|
+
totalCount: TOTAL_COUNT_3_PAGES,
|
|
76
|
+
itemCountPerPage: ITEM_COUNT_PER_PAGE,
|
|
77
|
+
pageCount: PAGE_GROUP_SIZE,
|
|
78
|
+
currentPage: 1,
|
|
79
|
+
breakPoint: 'mo'
|
|
80
|
+
});
|
|
81
|
+
// Then: mo λ νμ΄μ§ λ²νΈ λͺ©λ‘μ΄ CSS λ‘ μ¨κ²¨μ§λ―λ‘ μ΄μ Β·λ€μ λ²νΌμ΄ μμ΄μΌ μ΄λν μ μλ€
|
|
82
|
+
(0, _vitest.expect)(prevOf(el)).not.toBeNull();
|
|
83
|
+
(0, _vitest.expect)(nextOf(el)).not.toBeNull();
|
|
84
|
+
});
|
|
85
|
+
(0, _vitest.it)('첫 νμ΄μ§μμλ μ΄μ λ²νΌμ΄, λ§μ§λ§ νμ΄μ§μμλ λ€μ λ²νΌμ΄ λΉνμ±μ΄λ€', () => {
|
|
86
|
+
// Given/When: 3νμ΄μ§ μ€ μ²« νμ΄μ§λ₯Ό mo λ‘ λ λνλ©΄
|
|
87
|
+
const first = render({
|
|
88
|
+
totalCount: TOTAL_COUNT_3_PAGES,
|
|
89
|
+
itemCountPerPage: ITEM_COUNT_PER_PAGE,
|
|
90
|
+
pageCount: PAGE_GROUP_SIZE,
|
|
91
|
+
currentPage: 1,
|
|
92
|
+
breakPoint: 'mo'
|
|
93
|
+
});
|
|
94
|
+
// Then: μ΄μ λ§ λ§νκ³ λ€μμ λλ₯Ό μ μλ€
|
|
95
|
+
(0, _vitest.expect)(prevOf(first)?.disabled).toBe(true);
|
|
96
|
+
(0, _vitest.expect)(nextOf(first)?.disabled).toBe(false);
|
|
97
|
+
// When: λ§μ§λ§ νμ΄μ§λ‘ μ΄λνλ©΄
|
|
98
|
+
const last = render({
|
|
99
|
+
totalCount: TOTAL_COUNT_3_PAGES,
|
|
100
|
+
itemCountPerPage: ITEM_COUNT_PER_PAGE,
|
|
101
|
+
pageCount: PAGE_GROUP_SIZE,
|
|
102
|
+
currentPage: LAST_PAGE_3,
|
|
103
|
+
breakPoint: 'mo'
|
|
104
|
+
});
|
|
105
|
+
// Then: λ°λλ‘ λ€μμ΄ λ§νλ€
|
|
106
|
+
(0, _vitest.expect)(prevOf(last)?.disabled).toBe(false);
|
|
107
|
+
(0, _vitest.expect)(nextOf(last)?.disabled).toBe(true);
|
|
108
|
+
});
|
|
109
|
+
(0, _vitest.it)('νμ΄μ§κ° νλλΏμ΄λ©΄ mo μμλ μ΄μ Β·λ€μ λ²νΌμ λ΄λ³΄λ΄μ§ μλλ€', () => {
|
|
110
|
+
// Given/When: 1νμ΄μ§ λΆλμ mo λ‘ λ λνλ©΄
|
|
111
|
+
const el = render({
|
|
112
|
+
totalCount: TOTAL_COUNT_1_PAGE,
|
|
113
|
+
itemCountPerPage: ITEM_COUNT_PER_PAGE,
|
|
114
|
+
pageCount: PAGE_GROUP_SIZE,
|
|
115
|
+
currentPage: 1,
|
|
116
|
+
breakPoint: 'mo'
|
|
117
|
+
});
|
|
118
|
+
// Then: μ΄λν κ³³μ΄ μμΌλ―λ‘ λ²νΌλ μλ€
|
|
119
|
+
(0, _vitest.expect)(prevOf(el)).toBeNull();
|
|
120
|
+
(0, _vitest.expect)(nextOf(el)).toBeNull();
|
|
121
|
+
});
|
|
122
|
+
(0, _vitest.it)('pc λ κΈ°μ‘΄λλ‘ νμ΄μ§ κ·Έλ£Ήμ λκΈΈ λλ§ μ ν λ²νΌμ λ
ΈμΆνλ€', () => {
|
|
123
|
+
// Given/When: 3νμ΄μ§ λΆλμ pc λ‘ λ λνλ©΄
|
|
124
|
+
const el = render({
|
|
125
|
+
totalCount: TOTAL_COUNT_3_PAGES,
|
|
126
|
+
itemCountPerPage: ITEM_COUNT_PER_PAGE,
|
|
127
|
+
pageCount: PAGE_GROUP_SIZE,
|
|
128
|
+
currentPage: 1,
|
|
129
|
+
breakPoint: 'pc'
|
|
130
|
+
});
|
|
131
|
+
// Then: νμ΄μ§ λ²νΈλ‘ μ§μ μ΄λνλ―λ‘ μ ν λ²νΌμ λμ€μ§ μλλ€
|
|
132
|
+
(0, _vitest.expect)(prevOf(el)).toBeNull();
|
|
133
|
+
(0, _vitest.expect)(nextOf(el)).toBeNull();
|
|
134
|
+
(0, _vitest.expect)(pageNums(el)).toHaveLength(LAST_PAGE_3);
|
|
135
|
+
});
|
|
62
136
|
});
|
|
@@ -9,6 +9,7 @@ var _uiAdminIcon = require("@ncds/ui-admin-icon");
|
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _color = require("../../../../constant/color");
|
|
12
|
+
var _notification = require("../../../../constant/notification");
|
|
12
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
14
|
const iconMap = {
|
|
14
15
|
neutral: _uiAdminIcon.MessageChatSquare,
|
|
@@ -35,6 +36,7 @@ const FullWidthNotification = exports.FullWidthNotification = /*#__PURE__*/(0, _
|
|
|
35
36
|
autoClose = 0,
|
|
36
37
|
supportTextLink,
|
|
37
38
|
onHidePermanently,
|
|
39
|
+
hidePermanentlyLabel = _notification.HIDE_PERMANENTLY_LABEL.fullWidth,
|
|
38
40
|
...rest
|
|
39
41
|
} = _ref;
|
|
40
42
|
const [shouldRemove, setShouldRemove] = (0, _react.useState)(false);
|
|
@@ -116,7 +118,7 @@ const FullWidthNotification = exports.FullWidthNotification = /*#__PURE__*/(0, _
|
|
|
116
118
|
type: "button",
|
|
117
119
|
className: (0, _classnames.default)('ncua-notification__action-button', 'ncua-notification__action-button--text', 'ncua-full-width-notification__link'),
|
|
118
120
|
onClick: onHidePermanently,
|
|
119
|
-
children:
|
|
121
|
+
children: hidePermanentlyLabel
|
|
120
122
|
}), onClose && (0, _jsxRuntime.jsx)("button", {
|
|
121
123
|
type: "button",
|
|
122
124
|
className: "ncua-full-width-notification__close-button",
|
|
@@ -9,8 +9,7 @@ var _uiAdminIcon = require("@ncds/ui-admin-icon");
|
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _color = require("../../../../constant/color");
|
|
12
|
-
var
|
|
13
|
-
var _FeaturedIcon = require("../../image-and-icons/featured-icon/FeaturedIcon");
|
|
12
|
+
var _MessageNotificationParts = require("./MessageNotificationParts");
|
|
14
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
14
|
const iconMap = {
|
|
16
15
|
neutral: _uiAdminIcon.Pin02,
|
|
@@ -34,18 +33,11 @@ const MessageNotification = exports.MessageNotification = /*#__PURE__*/(0, _reac
|
|
|
34
33
|
className,
|
|
35
34
|
actions,
|
|
36
35
|
onHidePermanently,
|
|
36
|
+
hidePermanentlyLabel,
|
|
37
37
|
...rest
|
|
38
38
|
} = _ref;
|
|
39
39
|
// message νμ
μ neutral, error, warning, success 4κ°μ§ μμλ§ μ§μ
|
|
40
40
|
const validColor = color === 'info' ? 'neutral' : color;
|
|
41
|
-
const iconColor = validColor;
|
|
42
|
-
const featuredIconProps = {
|
|
43
|
-
icon: Icon || iconMap[validColor] || _uiAdminIcon.Pin02,
|
|
44
|
-
size: 'lg',
|
|
45
|
-
color: iconColor,
|
|
46
|
-
theme: 'light-circle'
|
|
47
|
-
};
|
|
48
|
-
const closeIconColor = _color.COLOR[iconColorMap[validColor] || 'gray700'];
|
|
49
41
|
return (0, _jsxRuntime.jsx)("div", {
|
|
50
42
|
ref: ref,
|
|
51
43
|
className: (0, _classnames.default)('ncua-message-notification', `ncua-message-notification--${validColor}`, className),
|
|
@@ -55,50 +47,18 @@ const MessageNotification = exports.MessageNotification = /*#__PURE__*/(0, _reac
|
|
|
55
47
|
className: "ncua-message-notification__container",
|
|
56
48
|
children: (0, _jsxRuntime.jsxs)("div", {
|
|
57
49
|
className: "ncua-message-notification__content",
|
|
58
|
-
children: [(0, _jsxRuntime.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
children: supportingText
|
|
71
|
-
})]
|
|
72
|
-
})]
|
|
73
|
-
}), (0, _jsxRuntime.jsx)("div", {
|
|
74
|
-
className: "ncua-message-notification__actions-container",
|
|
75
|
-
children: actions && (0, _jsxRuntime.jsx)("div", {
|
|
76
|
-
className: "ncua-message-notification__actions",
|
|
77
|
-
children: actions.map(action => (0, _jsxRuntime.jsx)(_button.Button, {
|
|
78
|
-
size: "xs",
|
|
79
|
-
hierarchy: action.hierarchy || 'text',
|
|
80
|
-
label: action.label,
|
|
81
|
-
onClick: action?.onClick
|
|
82
|
-
}, `${action.label}-${action.hierarchy}`))
|
|
83
|
-
})
|
|
84
|
-
}), (0, _jsxRuntime.jsxs)("div", {
|
|
85
|
-
className: "ncua-message-notification__footer-container",
|
|
86
|
-
children: [onHidePermanently && (0, _jsxRuntime.jsx)("button", {
|
|
87
|
-
type: "button",
|
|
88
|
-
className: (0, _classnames.default)('ncua-notification__action-button', 'ncua-notification__action-button--link', 'ncua-message-notification__hide-link'),
|
|
89
|
-
onClick: onHidePermanently,
|
|
90
|
-
children: "\uB2E4\uC2DC \uBCF4\uC9C0 \uC54A\uAE30"
|
|
91
|
-
}), onClose && (0, _jsxRuntime.jsx)("button", {
|
|
92
|
-
type: "button",
|
|
93
|
-
className: "ncua-message-notification__close-button",
|
|
94
|
-
onClick: onClose,
|
|
95
|
-
"aria-label": "\uC54C\uB9BC \uB2EB\uAE30",
|
|
96
|
-
children: (0, _jsxRuntime.jsx)(_uiAdminIcon.XClose, {
|
|
97
|
-
width: 20,
|
|
98
|
-
height: 20,
|
|
99
|
-
color: closeIconColor
|
|
100
|
-
})
|
|
101
|
-
})]
|
|
50
|
+
children: [(0, _jsxRuntime.jsx)(_MessageNotificationParts.MessageNotificationContent, {
|
|
51
|
+
title: title,
|
|
52
|
+
supportingText: supportingText,
|
|
53
|
+
icon: Icon || iconMap[validColor],
|
|
54
|
+
iconColor: validColor,
|
|
55
|
+
showIcon: Boolean(iconMap[validColor])
|
|
56
|
+
}), (0, _jsxRuntime.jsx)(_MessageNotificationParts.MessageNotificationActions, {
|
|
57
|
+
actions: actions,
|
|
58
|
+
onClose: onClose,
|
|
59
|
+
onHidePermanently: onHidePermanently,
|
|
60
|
+
hidePermanentlyLabel: hidePermanentlyLabel,
|
|
61
|
+
closeIconColor: _color.COLOR[iconColorMap[validColor] || 'gray700']
|
|
102
62
|
})]
|
|
103
63
|
})
|
|
104
64
|
})
|