@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.
Files changed (134) hide show
  1. package/dist/cjs/assets/scripts/notification/FullWidthNotification.js +17 -6
  2. package/dist/cjs/assets/scripts/notification/MessageNotification.js +10 -48
  3. package/dist/cjs/assets/scripts/notification/const/classNames.js +3 -0
  4. package/dist/cjs/assets/scripts/notification/const/index.js +1 -1
  5. package/dist/cjs/assets/scripts/notification/const/sizes.js +4 -2
  6. package/dist/cjs/assets/scripts/notification/messageTemplate.js +106 -0
  7. package/dist/cjs/assets/scripts/notification/utils.js +40 -4
  8. package/dist/cjs/constant/notification.js +21 -0
  9. package/dist/cjs/src/components/forms-and-input/input-base/InputBase.js +52 -34
  10. package/dist/cjs/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +228 -0
  11. package/dist/cjs/src/components/forms-and-input/password-input/PasswordInput.js +3 -2
  12. package/dist/cjs/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js +59 -0
  13. package/dist/cjs/src/components/index.js +22 -0
  14. package/dist/cjs/src/components/layout/ncua-scope/NcuaScope.js +79 -0
  15. package/dist/cjs/src/components/layout/ncua-scope/index.js +16 -0
  16. package/dist/cjs/src/components/navigation/pagination/Pagination.js +3 -1
  17. package/dist/cjs/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
  18. package/dist/cjs/src/components/overlays/notification/FullWidthNotification.js +3 -1
  19. package/dist/cjs/src/components/overlays/notification/MessageNotification.js +14 -54
  20. package/dist/cjs/src/components/overlays/notification/MessageNotificationParts.js +92 -0
  21. package/dist/cjs/src/components/overlays/notification/__tests__/MessageNotification.test.js +246 -0
  22. package/dist/cjs/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +209 -0
  23. package/dist/cjs/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +259 -0
  24. package/dist/cjs/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +70 -0
  25. package/dist/cjs/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +623 -0
  26. package/dist/cjs/src/components/overlays/postcode-search-modal/index.js +16 -0
  27. package/dist/cjs/src/generated/scoped-css.js +9 -0
  28. package/dist/esm/assets/scripts/notification/FullWidthNotification.js +17 -6
  29. package/dist/esm/assets/scripts/notification/MessageNotification.js +12 -50
  30. package/dist/esm/assets/scripts/notification/const/classNames.js +3 -0
  31. package/dist/esm/assets/scripts/notification/const/index.js +3 -2
  32. package/dist/esm/assets/scripts/notification/const/sizes.js +4 -2
  33. package/dist/esm/assets/scripts/notification/messageTemplate.js +100 -0
  34. package/dist/esm/assets/scripts/notification/utils.js +39 -4
  35. package/dist/esm/constant/notification.js +15 -0
  36. package/dist/esm/src/components/forms-and-input/input-base/InputBase.js +52 -34
  37. package/dist/esm/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +228 -0
  38. package/dist/esm/src/components/forms-and-input/password-input/PasswordInput.js +3 -2
  39. package/dist/esm/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js +56 -0
  40. package/dist/esm/src/components/index.js +2 -0
  41. package/dist/esm/src/components/layout/ncua-scope/NcuaScope.js +73 -0
  42. package/dist/esm/src/components/layout/ncua-scope/index.js +1 -0
  43. package/dist/esm/src/components/navigation/pagination/Pagination.js +3 -1
  44. package/dist/esm/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
  45. package/dist/esm/src/components/overlays/notification/FullWidthNotification.js +3 -1
  46. package/dist/esm/src/components/overlays/notification/MessageNotification.js +15 -55
  47. package/dist/esm/src/components/overlays/notification/MessageNotificationParts.js +85 -0
  48. package/dist/esm/src/components/overlays/notification/__tests__/MessageNotification.test.js +243 -0
  49. package/dist/esm/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +206 -0
  50. package/dist/esm/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +252 -0
  51. package/dist/esm/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +63 -0
  52. package/dist/esm/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +620 -0
  53. package/dist/esm/src/components/overlays/postcode-search-modal/index.js +1 -0
  54. package/dist/esm/src/generated/scoped-css.js +3 -0
  55. package/dist/temp/assets/scripts/notification/FullWidthNotification.d.ts +6 -0
  56. package/dist/temp/assets/scripts/notification/FullWidthNotification.js +14 -5
  57. package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +0 -3
  58. package/dist/temp/assets/scripts/notification/MessageNotification.js +9 -44
  59. package/dist/temp/assets/scripts/notification/const/classNames.d.ts +1 -0
  60. package/dist/temp/assets/scripts/notification/const/classNames.js +3 -0
  61. package/dist/temp/assets/scripts/notification/const/index.d.ts +3 -3
  62. package/dist/temp/assets/scripts/notification/const/index.js +3 -2
  63. package/dist/temp/assets/scripts/notification/const/sizes.d.ts +2 -2
  64. package/dist/temp/assets/scripts/notification/const/sizes.js +4 -2
  65. package/dist/temp/assets/scripts/notification/const/types.d.ts +30 -2
  66. package/dist/temp/assets/scripts/notification/messageTemplate.d.ts +15 -0
  67. package/dist/temp/assets/scripts/notification/messageTemplate.js +79 -0
  68. package/dist/temp/assets/scripts/notification/utils.d.ts +19 -2
  69. package/dist/temp/assets/scripts/notification/utils.js +39 -5
  70. package/dist/temp/constant/notification.d.ts +15 -0
  71. package/dist/temp/constant/notification.js +15 -0
  72. package/dist/temp/src/components/forms-and-input/input-base/InputBase.d.ts +1 -1
  73. package/dist/temp/src/components/forms-and-input/input-base/InputBase.js +43 -26
  74. package/dist/temp/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +174 -0
  75. package/dist/temp/src/components/forms-and-input/password-input/PasswordInput.js +2 -1
  76. package/dist/temp/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.d.ts +1 -0
  77. package/dist/temp/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js +48 -0
  78. package/dist/temp/src/components/index.d.ts +2 -0
  79. package/dist/temp/src/components/index.js +2 -0
  80. package/dist/temp/src/components/layout/ncua-scope/NcuaScope.d.ts +32 -0
  81. package/dist/temp/src/components/layout/ncua-scope/NcuaScope.js +51 -0
  82. package/dist/temp/src/components/layout/ncua-scope/index.d.ts +1 -0
  83. package/dist/temp/src/components/layout/ncua-scope/index.js +1 -0
  84. package/dist/temp/src/components/navigation/pagination/Pagination.js +3 -1
  85. package/dist/temp/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
  86. package/dist/temp/src/components/overlays/notification/FullWidthNotification.d.ts +6 -0
  87. package/dist/temp/src/components/overlays/notification/FullWidthNotification.js +3 -2
  88. package/dist/temp/src/components/overlays/notification/MessageNotification.d.ts +6 -0
  89. package/dist/temp/src/components/overlays/notification/MessageNotification.js +4 -13
  90. package/dist/temp/src/components/overlays/notification/MessageNotificationParts.d.ts +28 -0
  91. package/dist/temp/src/components/overlays/notification/MessageNotificationParts.js +28 -0
  92. package/dist/temp/src/components/overlays/notification/Notification.d.ts +11 -2
  93. package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.d.ts +1 -0
  94. package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.js +190 -0
  95. package/dist/temp/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.d.ts +1 -0
  96. package/dist/temp/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +160 -0
  97. package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModal.d.ts +45 -0
  98. package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +125 -0
  99. package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.d.ts +16 -0
  100. package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +24 -0
  101. package/dist/temp/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.d.ts +1 -0
  102. package/dist/temp/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +503 -0
  103. package/dist/temp/src/components/overlays/postcode-search-modal/index.d.ts +1 -0
  104. package/dist/temp/src/components/overlays/postcode-search-modal/index.js +1 -0
  105. package/dist/temp/src/generated/scoped-css.d.ts +1 -0
  106. package/dist/temp/src/generated/scoped-css.js +3 -0
  107. package/dist/types/assets/scripts/notification/FullWidthNotification.d.ts +6 -0
  108. package/dist/types/assets/scripts/notification/MessageNotification.d.ts +0 -3
  109. package/dist/types/assets/scripts/notification/const/classNames.d.ts +1 -0
  110. package/dist/types/assets/scripts/notification/const/index.d.ts +3 -3
  111. package/dist/types/assets/scripts/notification/const/sizes.d.ts +2 -2
  112. package/dist/types/assets/scripts/notification/const/types.d.ts +30 -2
  113. package/dist/types/assets/scripts/notification/messageTemplate.d.ts +15 -0
  114. package/dist/types/assets/scripts/notification/utils.d.ts +19 -2
  115. package/dist/types/constant/notification.d.ts +15 -0
  116. package/dist/types/src/components/forms-and-input/input-base/InputBase.d.ts +1 -1
  117. package/dist/types/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.d.ts +1 -0
  118. package/dist/types/src/components/index.d.ts +2 -0
  119. package/dist/types/src/components/layout/ncua-scope/NcuaScope.d.ts +32 -0
  120. package/dist/types/src/components/layout/ncua-scope/index.d.ts +1 -0
  121. package/dist/types/src/components/overlays/notification/FullWidthNotification.d.ts +6 -0
  122. package/dist/types/src/components/overlays/notification/MessageNotification.d.ts +6 -0
  123. package/dist/types/src/components/overlays/notification/MessageNotificationParts.d.ts +28 -0
  124. package/dist/types/src/components/overlays/notification/Notification.d.ts +11 -2
  125. package/dist/types/src/components/overlays/notification/__tests__/MessageNotification.test.d.ts +1 -0
  126. package/dist/types/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.d.ts +1 -0
  127. package/dist/types/src/components/overlays/postcode-search-modal/PostcodeSearchModal.d.ts +45 -0
  128. package/dist/types/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.d.ts +16 -0
  129. package/dist/types/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.d.ts +1 -0
  130. package/dist/types/src/components/overlays/postcode-search-modal/index.d.ts +1 -0
  131. package/dist/types/src/generated/scoped-css.d.ts +1 -0
  132. package/dist/ui-admin/assets/styles/style.css +296 -56
  133. package/dist/ui-admin/assets/styles/style.scoped.css +8595 -0
  134. package/package.json +13 -6
@@ -1,8 +1,10 @@
1
1
  // @vitest-environment jsdom
2
+ import { SearchLg } from '@ncds/ui-admin-icon';
2
3
  import { createElement } from 'react';
3
4
  import { createRoot } from 'react-dom/client';
4
5
  import { act } from 'react-dom/test-utils';
5
6
  import { describe, expect, it, vi } from 'vitest';
7
+ import { COLOR } from '../../../../../constant/color';
6
8
  import { InputBase } from '../InputBase';
7
9
  // React 18에서 act() 사용 시 필요한 플래그 (미설정 시 console.error 경고 발생)
8
10
  globalThis.IS_REACT_ACT_ENVIRONMENT = true;
@@ -66,4 +68,230 @@ describe('InputBase — clearText prop DOM 누출', () => {
66
68
  expect(view.container.querySelector('.ncua-input__clear')).toBeNull();
67
69
  view.unmount();
68
70
  });
71
+ });
72
+ describe('InputBase — 아이콘 사이즈', () => {
73
+ const iconSizeOf = (container, selector) => {
74
+ const svg = container.querySelector(selector);
75
+ return {
76
+ width: svg?.getAttribute('width'),
77
+ height: svg?.getAttribute('height')
78
+ };
79
+ };
80
+ // 슬롯 아이콘과 상태 아이콘은 같은 크기를 쓴다 — 과거 상태 아이콘만 sm=16으로 어긋나 있었다
81
+ it.each([['xs', '14'], ['sm', '20']])('size=%s 일 때 슬롯 아이콘과 상태 아이콘이 모두 %spx로 렌더된다', (size, expected) => {
82
+ // Given/When: 슬롯 아이콘과 clear 버튼, destructive 상태를 함께 렌더하면
83
+ const view = mountInputBase({
84
+ size,
85
+ destructive: true,
86
+ clearText: true,
87
+ onClearText: vi.fn(),
88
+ leadingElement: {
89
+ type: 'icon',
90
+ icon: SearchLg
91
+ }
92
+ });
93
+ // Then: 슬롯·clear·destructive 아이콘의 크기가 서로 어긋나지 않는다
94
+ const expectedSize = {
95
+ width: expected,
96
+ height: expected
97
+ };
98
+ expect(iconSizeOf(view.container, '.ncua-input__left-icon')).toEqual(expectedSize);
99
+ expect(iconSizeOf(view.container, '.ncua-input__clear-icon')).toEqual(expectedSize);
100
+ expect(iconSizeOf(view.container, '.ncua-input__destructive-icon')).toEqual(expectedSize);
101
+ view.unmount();
102
+ });
103
+ it.each([['xs', '14'], ['sm', '20']])('size=%s 일 때 validation 아이콘도 %spx로 렌더된다', (size, expected) => {
104
+ // Given/When: validation 상태로 렌더하면
105
+ const view = mountInputBase({
106
+ size,
107
+ validation: true
108
+ });
109
+ // Then: 다른 아이콘과 같은 크기다
110
+ expect(iconSizeOf(view.container, '.ncua-input__validation-icon')).toEqual({
111
+ width: expected,
112
+ height: expected
113
+ });
114
+ view.unmount();
115
+ });
116
+ it('slot.size를 직접 주면 기본 사이즈보다 우선한다', () => {
117
+ // Given/When: 슬롯에 size를 명시해 렌더하면
118
+ const view = mountInputBase({
119
+ size: 'xs',
120
+ leadingElement: {
121
+ type: 'icon',
122
+ icon: SearchLg,
123
+ size: 24
124
+ }
125
+ });
126
+ // Then: 기본값(14)이 아니라 명시한 값이 적용된다
127
+ expect(iconSizeOf(view.container, '.ncua-input__left-icon')).toEqual({
128
+ width: '24',
129
+ height: '24'
130
+ });
131
+ view.unmount();
132
+ });
133
+ });
134
+ describe('InputBase — 슬롯 아이콘 상태 색상', () => {
135
+ // 상태별 색은 CSS 가 결정한다. jsdom 에서는 스타일시트를 로드하지 않으므로
136
+ // "상태 규칙을 타는 클래스가 붙었는지" 와 "지정 색이 인라인으로 남았는지" 로 검증한다.
137
+ const leftIconOf = container => container.querySelector('.ncua-input__left-icon');
138
+ it('color 를 지정하지 않으면 상태 색상 클래스가 붙는다', () => {
139
+ // Given/When: color 없이 슬롯 아이콘을 렌더하면
140
+ const view = mountInputBase({
141
+ leadingElement: {
142
+ type: 'icon',
143
+ icon: SearchLg
144
+ }
145
+ });
146
+ // Then: 상태 규칙을 타는 클래스가 붙고, 인라인 색은 지정되지 않는다
147
+ const icon = leftIconOf(view.container);
148
+ expect(icon?.classList.contains('ncua-input__slot-icon')).toBe(true);
149
+ expect(icon?.hasAttribute('color')).toBe(false);
150
+ view.unmount();
151
+ });
152
+ it('color 를 지정하면 상태 색상 클래스가 붙지 않고 지정 색이 유지된다', () => {
153
+ // Given/When: color 를 지정해 렌더하면
154
+ const view = mountInputBase({
155
+ leadingElement: {
156
+ type: 'icon',
157
+ icon: SearchLg,
158
+ color: 'blue500'
159
+ }
160
+ });
161
+ // Then: 상태 규칙에서 제외되고 지정한 색이 그대로 남는다
162
+ const icon = leftIconOf(view.container);
163
+ expect(icon?.classList.contains('ncua-input__slot-icon')).toBe(false);
164
+ expect(icon?.getAttribute('color')).toBe(COLOR.blue500);
165
+ view.unmount();
166
+ });
167
+ it('slot.className 을 함께 주어도 상태 색상 클래스가 유지된다', () => {
168
+ // Given/When: className 을 추가로 넘기면
169
+ const view = mountInputBase({
170
+ leadingElement: {
171
+ type: 'icon',
172
+ icon: SearchLg,
173
+ className: 'my-icon'
174
+ }
175
+ });
176
+ // Then: 두 클래스가 모두 붙는다
177
+ const icon = leftIconOf(view.container);
178
+ expect(icon?.classList.contains('ncua-input__slot-icon')).toBe(true);
179
+ expect(icon?.classList.contains('my-icon')).toBe(true);
180
+ view.unmount();
181
+ });
182
+ });
183
+ describe('InputBase — has-value 상태 클래스', () => {
184
+ const typeInto = (container, text) => {
185
+ const input = container.querySelector('input');
186
+ if (!input) throw new Error('input이 렌더되지 않았습니다');
187
+ act(() => {
188
+ input.value = text;
189
+ input.dispatchEvent(new Event('input', {
190
+ bubbles: true
191
+ }));
192
+ });
193
+ };
194
+ it('값이 비어 있으면 has-value가 붙지 않는다', () => {
195
+ // Given/When: 빈 상태로 렌더하면
196
+ const view = mountInputBase();
197
+ // Then: 루트에 has-value가 없다
198
+ expect(view.container.querySelector('.ncua-input')?.classList.contains('has-value')).toBe(false);
199
+ view.unmount();
200
+ });
201
+ // props.value 로 판정하면 uncontrolled 에서 영원히 빈 값으로 보인다 — 자물쇠 아이콘 색상이 반영되지 않던 원인
202
+ it('uncontrolled Input에 입력하면 has-value가 붙는다', () => {
203
+ // Given: value를 넘기지 않은 uncontrolled 상태에서
204
+ const view = mountInputBase();
205
+ // When: 실제로 입력하면
206
+ typeInto(view.container, 'hello');
207
+ // Then: has-value가 붙는다
208
+ expect(view.container.querySelector('.ncua-input')?.classList.contains('has-value')).toBe(true);
209
+ view.unmount();
210
+ });
211
+ it('입력값을 지우면 has-value가 떨어진다', () => {
212
+ // Given: 값이 있는 상태에서
213
+ const view = mountInputBase();
214
+ typeInto(view.container, 'hello');
215
+ // When: 값을 비우면
216
+ typeInto(view.container, '');
217
+ // Then: has-value가 사라진다
218
+ expect(view.container.querySelector('.ncua-input')?.classList.contains('has-value')).toBe(false);
219
+ view.unmount();
220
+ });
221
+ it('controlled Input은 value prop만으로도 has-value가 붙는다', () => {
222
+ // Given/When: value를 직접 넘겨 렌더하면 (input 이벤트 없이)
223
+ const view = mountInputBase({
224
+ value: 'preset',
225
+ onChange: vi.fn()
226
+ });
227
+ // Then: has-value가 붙는다
228
+ expect(view.container.querySelector('.ncua-input')?.classList.contains('has-value')).toBe(true);
229
+ view.unmount();
230
+ });
231
+ });
232
+ describe('InputBase — 텍스트 슬롯', () => {
233
+ it('leadingElement 텍스트는 leading 클래스와 wrap 클래스가 붙는다', () => {
234
+ const {
235
+ container,
236
+ unmount
237
+ } = mountInputBase({
238
+ leadingElement: {
239
+ type: 'text',
240
+ text: 'https://'
241
+ }
242
+ });
243
+ const text = container.querySelector('.ncua-input__leading-text');
244
+ expect(text?.textContent).toBe('https://');
245
+ expect(container.querySelector('.ncua-input__leading-text-wrap')).not.toBeNull();
246
+ unmount();
247
+ });
248
+ it('trailingElement 텍스트는 trailing 클래스와 wrap 클래스가 붙는다', () => {
249
+ const {
250
+ container,
251
+ unmount
252
+ } = mountInputBase({
253
+ trailingElement: {
254
+ type: 'text',
255
+ text: 'px'
256
+ }
257
+ });
258
+ const text = container.querySelector('.ncua-input__trailing-text');
259
+ expect(text?.textContent).toBe('px');
260
+ expect(container.querySelector('.ncua-input__trailing-text-wrap')).not.toBeNull();
261
+ // leading 클래스가 섞이면 모서리·테두리 방향이 반대가 된다
262
+ expect(container.querySelector('.ncua-input__leading-text')).toBeNull();
263
+ unmount();
264
+ });
265
+ it('trailingElement 텍스트는 입력 필드 뒤에 온다', () => {
266
+ const {
267
+ container,
268
+ unmount
269
+ } = mountInputBase({
270
+ trailingElement: {
271
+ type: 'text',
272
+ text: 'px'
273
+ }
274
+ });
275
+ const content = container.querySelector('.ncua-input__content');
276
+ const children = Array.from(content?.children ?? []);
277
+ const fieldIndex = children.findIndex(el => el.classList.contains('ncua-input__field'));
278
+ const textIndex = children.findIndex(el => el.classList.contains('ncua-input__trailing-text'));
279
+ expect(fieldIndex).toBeGreaterThanOrEqual(0);
280
+ expect(textIndex).toBeGreaterThan(fieldIndex);
281
+ unmount();
282
+ });
283
+ it('사이즈 modifier 가 함께 붙는다', () => {
284
+ const {
285
+ container,
286
+ unmount
287
+ } = mountInputBase({
288
+ size: 'sm',
289
+ trailingElement: {
290
+ type: 'text',
291
+ text: 'px'
292
+ }
293
+ });
294
+ expect(container.querySelector('.ncua-input__trailing-text--sm')).not.toBeNull();
295
+ unmount();
296
+ });
69
297
  });
@@ -26,8 +26,9 @@ export const PasswordInput = /*#__PURE__*/forwardRef((_ref, ref) => {
26
26
  type: isVisible ? 'text' : 'password',
27
27
  leadingElement: {
28
28
  type: 'icon',
29
- icon: Lock01,
30
- color: props.value ? 'gray600' : 'gray300'
29
+ icon: Lock01
30
+ // color 넘기지 않아 슬롯 아이콘 공통 규칙(상태별 색)을 그대로 따른다.
31
+ // 여기서 props.value 로 판정하면 uncontrolled Input 에서 영원히 빈 값 취급된다.
31
32
  },
32
33
  trailingElement: {
33
34
  type: 'custom',
@@ -0,0 +1,56 @@
1
+ // @vitest-environment jsdom
2
+ import { createElement } from 'react';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { act } from 'react-dom/test-utils';
5
+ import { describe, expect, it, vi } from 'vitest';
6
+ import { PasswordInput } from '../PasswordInput';
7
+ // React 18에서 act() 사용 시 필요한 플래그 (미설정 시 console.error 경고 발생)
8
+ globalThis.IS_REACT_ACT_ENVIRONMENT = true;
9
+ function mountPasswordInput() {
10
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11
+ const container = document.createElement('div');
12
+ document.body.appendChild(container);
13
+ const root = createRoot(container);
14
+ act(() => {
15
+ root.render(/*#__PURE__*/createElement(PasswordInput, props));
16
+ });
17
+ const unmount = () => {
18
+ act(() => {
19
+ root.unmount();
20
+ });
21
+ container.remove();
22
+ };
23
+ return {
24
+ container,
25
+ unmount
26
+ };
27
+ }
28
+ describe('PasswordInput — 자물쇠 아이콘 색상', () => {
29
+ // 자물쇠 색은 CSS 가 결정한다. 인라인 color 를 넘기면 상태 규칙이 무시되므로,
30
+ // "인라인 색이 없고 슬롯 아이콘 공통 클래스를 탄다" 는 것이 색상 반영의 전제다.
31
+ it('자물쇠에 인라인 색을 넘기지 않고 슬롯 아이콘 공통 클래스를 탄다', () => {
32
+ // Given/When: 기본 상태로 렌더하면
33
+ const view = mountPasswordInput();
34
+ // Then: 상태 규칙을 타는 클래스가 붙고 인라인 색은 없다
35
+ const lockIcon = view.container.querySelector('.ncua-input__left-icon');
36
+ expect(lockIcon).not.toBeNull();
37
+ expect(lockIcon?.classList.contains('ncua-input__slot-icon')).toBe(true);
38
+ expect(lockIcon?.hasAttribute('color')).toBe(false);
39
+ view.unmount();
40
+ });
41
+ // 값이 있는 채로 비활성화되면 has-value 가 살아 있어 자물쇠가 진하게 남던 문제
42
+ it('값이 있는 채로 disabled 여도 자물쇠가 상태 규칙 대상으로 남는다', () => {
43
+ // Given/When: 값이 있는 비활성화 상태로 렌더하면
44
+ const view = mountPasswordInput({
45
+ value: 'secret',
46
+ disabled: true,
47
+ onChange: vi.fn()
48
+ });
49
+ // Then: 루트에 is-disabled 와 has-value 가 함께 붙고, 자물쇠는 공통 클래스를 유지한다
50
+ const root = view.container.querySelector('.ncua-input');
51
+ expect(root?.classList.contains('is-disabled')).toBe(true);
52
+ expect(root?.classList.contains('has-value')).toBe(true);
53
+ expect(view.container.querySelector('.ncua-input__left-icon')?.classList.contains('ncua-input__slot-icon')).toBe(true);
54
+ view.unmount();
55
+ });
56
+ });
@@ -39,6 +39,7 @@ export * from './image-and-icons/featured-icon';
39
39
  export * from './layout/block-container';
40
40
  export * from './layout/block-header';
41
41
  export * from './layout/divider';
42
+ export * from './layout/ncua-scope';
42
43
  export * from './layout/page-title';
43
44
  // Navigation
44
45
  export * from './navigation/bread-crumb';
@@ -50,6 +51,7 @@ export * from './navigation/vertical-tab';
50
51
  export * from './overlays/dropdown';
51
52
  export * from './overlays/modal';
52
53
  export * from './overlays/notification';
54
+ export * from './overlays/postcode-search-modal';
53
55
  export * from './overlays/tooltip';
54
56
  // Shared
55
57
  export * from './select-dropdown';
@@ -0,0 +1,73 @@
1
+ 'use client';
2
+
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ import classnames from 'classnames';
5
+ import { createContext, forwardRef, version as reactVersion, useContext } from 'react';
6
+ import { NCUA_SCOPED_CSS } from '../../../generated/scoped-css';
7
+ // 조상에 NcuaScope 가 이미 있으면 스타일을 다시 심지 않는다 (중첩 대응).
8
+ const NcuaStyleMountedContext = /*#__PURE__*/createContext(false);
9
+ // React 19 는 <style> 에 href·precedence 가 함께 있으면 <head> 로 올리고 href 로 중복을
10
+ // 제거한다. 18 에는 그 기능도, 두 prop 의 타입 정의도 없어 Context 로 중첩만 막고
11
+ // 타입은 우회한다.
12
+ const STYLE_HOISTING_MIN_REACT_MAJOR = 19;
13
+ const DECIMAL_RADIX = 10;
14
+ const SUPPORTS_STYLE_HOISTING = Number.parseInt(reactVersion, DECIMAL_RADIX) >= STYLE_HOISTING_MIN_REACT_MAJOR;
15
+ const STYLE_KEY = 'ncua-scoped';
16
+ const STYLE_HOISTING_PROPS = {
17
+ href: STYLE_KEY,
18
+ precedence: 'default'
19
+ };
20
+ // SSR 은 <style> 의 자식 텍스트를 HTML 이스케이프하지만(' -> &#x27;), 브라우저는 <style>
21
+ // 안을 raw text 로 읽어 되돌리지 않는다. 그러면 CSS 가 깨지고 하이드레이션도 불일치한다.
22
+ // innerHTML 로 넣으면 서버가 원문 그대로 내보낸다.
23
+ const STYLE_CONTENT = {
24
+ __html: NCUA_SCOPED_CSS
25
+ };
26
+ /**
27
+ * NCUA 스타일을 이 엘리먼트 하위로 한정하는 경계.
28
+ *
29
+ * 다른 디자인 시스템을 전역 적용한 사용처에서 NCUA 컴포넌트를 이걸로 감싼다.
30
+ * 스타일을 직접 들고 있으므로 **CSS 파일을 따로 import 하지 않는다.**
31
+ *
32
+ * ```tsx
33
+ * import { NcuaScope, Button } from '@ncds/ui-admin';
34
+ *
35
+ * <NcuaScope>
36
+ * <Button label="신청하기" hierarchy="primary" size="md" />
37
+ * </NcuaScope>
38
+ * ```
39
+ *
40
+ * `document.body` 로 portal 되는 컴포넌트(Modal · Tooltip · Dropdown · SelectBox ·
41
+ * Notification)는 이 경계 밖에 놓이지만, 스코프 스타일시트가 그 루트 클래스들을 함께
42
+ * 지정하므로 토큰을 받는다 (`base/_scope.scss` 의 `$roots`). portal 목적지는 바뀌지
43
+ * 않으므로 어드민에서의 기존 동작과 같다.
44
+ *
45
+ * 어드민처럼 `style.css` 를 전역 적용하는 사용처는 이 컴포넌트가 필요 없다.
46
+ *
47
+ * 중첩해서 써도 스타일은 한 번만 들어간다. React 19 에서는 형제로 여러 개를 써도
48
+ * href 기준으로 중복이 제거된다. React 18 에서는 형제마다 `<style>` 이 하나씩 생기므로,
49
+ * 스코프가 여러 곳에 필요하면 공통 조상 한 곳에서 감싸는 편이 낫다.
50
+ */
51
+ export const NcuaScope = /*#__PURE__*/forwardRef((_ref, ref) => {
52
+ let {
53
+ className,
54
+ children
55
+ } = _ref;
56
+ const styleAlreadyMounted = useContext(NcuaStyleMountedContext);
57
+ const shouldRenderStyle = SUPPORTS_STYLE_HOISTING || !styleAlreadyMounted;
58
+ return _jsxs(NcuaStyleMountedContext.Provider, {
59
+ value: true,
60
+ children: [shouldRenderStyle && (SUPPORTS_STYLE_HOISTING ? _jsx("style", {
61
+ ...STYLE_HOISTING_PROPS,
62
+ dangerouslySetInnerHTML: STYLE_CONTENT
63
+ }) : _jsx("style", {
64
+ "data-ncua-scope": STYLE_KEY,
65
+ dangerouslySetInnerHTML: STYLE_CONTENT
66
+ })), _jsx("div", {
67
+ ref: ref,
68
+ className: classnames('ncua-scope', className),
69
+ children: children
70
+ })]
71
+ });
72
+ });
73
+ NcuaScope.displayName = 'NcuaScope';
@@ -0,0 +1 @@
1
+ export * from './NcuaScope';
@@ -19,7 +19,9 @@ export const Pagination = _ref => {
19
19
  const [start, setStart] = useState(1);
20
20
  const noPrev = breakPoint === 'mo' ? currentPage === 1 : start === 1;
21
21
  const noNext = breakPoint === 'mo' ? currentPage >= totalPage : start + pageCount - 1 >= totalPage;
22
- const showJumpPageButton = totalPage > pageCount;
22
+ // mo CSS 페이지 번호 목록과 first/last 를 숨겨 prev/next 만 남는다.
23
+ // pc 기준(totalPage > pageCount)을 그대로 쓰면 페이지가 적을 때 이동 수단이 하나도 없다.
24
+ const showJumpPageButton = breakPoint === 'mo' ? totalPage > 1 : totalPage > pageCount;
23
25
  const handleClickButton = pageNum => {
24
26
  if (isFunction(onPageChange)) {
25
27
  onPageChange(pageNum);
@@ -12,6 +12,12 @@ const CURRENT_PAGE = 91; // 100페이지 기준 마지막 그룹(91~100)을 보
12
12
  const GROUP_START_100_PAGES = 91; // currentPage=91 일 때의 그룹 시작
13
13
  const GROUP_START_50_PAGES = 41; // totalPage=50 으로 줄었을 때의 마지막 그룹 시작
14
14
  const LAST_PAGE_50 = 50;
15
+ /** 페이지 그룹 크기(10) 이하로 나뉘는 건수 — 3페이지 */
16
+ const TOTAL_COUNT_3_PAGES = 30;
17
+ /** TOTAL_COUNT_3_PAGES 기준 총 페이지 수 = 마지막 페이지 번호 */
18
+ const LAST_PAGE_3 = 3;
19
+ /** 페이지가 하나뿐인 건수 */
20
+ const TOTAL_COUNT_1_PAGE = 8;
15
21
  let root = null;
16
22
  let container = null;
17
23
  function render(props) {
@@ -34,6 +40,8 @@ afterEach(() => {
34
40
  container = null;
35
41
  });
36
42
  const pageNums = el => Array.from(el.querySelectorAll('.ncua-pagination__page-num')).map(b => Number(b.textContent));
43
+ const prevOf = el => el.querySelector('.ncua-pagination__before');
44
+ const nextOf = el => el.querySelector('.ncua-pagination__next');
37
45
  describe('#332 Pagination — totalPage 축소 시 start 보정', () => {
38
46
  it('totalPage 가 줄면 start 를 마지막 그룹으로 보정하고 범위 밖 페이지 버튼을 표시하지 않는다', () => {
39
47
  // 1) 100 페이지에서 91 페이지 보는 중 → 91~100 그룹 표시
@@ -56,4 +64,70 @@ describe('#332 Pagination — totalPage 축소 시 start 보정', () => {
56
64
  expect(nums[0]).toBe(GROUP_START_50_PAGES);
57
65
  expect(Math.max(...nums)).toBeLessThanOrEqual(LAST_PAGE_50);
58
66
  });
67
+ });
68
+ describe('Pagination — mo 모드 이전/다음 버튼 노출', () => {
69
+ it('페이지가 그룹 크기 이하여도 mo 에서는 이전·다음 버튼이 노출된다', () => {
70
+ // Given/When: 3페이지(그룹 크기 10 이하) 분량을 mo 로 렌더하면
71
+ const el = render({
72
+ totalCount: TOTAL_COUNT_3_PAGES,
73
+ itemCountPerPage: ITEM_COUNT_PER_PAGE,
74
+ pageCount: PAGE_GROUP_SIZE,
75
+ currentPage: 1,
76
+ breakPoint: 'mo'
77
+ });
78
+ // Then: mo 는 페이지 번호 목록이 CSS 로 숨겨지므로 이전·다음 버튼이 있어야 이동할 수 있다
79
+ expect(prevOf(el)).not.toBeNull();
80
+ expect(nextOf(el)).not.toBeNull();
81
+ });
82
+ it('첫 페이지에서는 이전 버튼이, 마지막 페이지에서는 다음 버튼이 비활성이다', () => {
83
+ // Given/When: 3페이지 중 첫 페이지를 mo 로 렌더하면
84
+ const first = render({
85
+ totalCount: TOTAL_COUNT_3_PAGES,
86
+ itemCountPerPage: ITEM_COUNT_PER_PAGE,
87
+ pageCount: PAGE_GROUP_SIZE,
88
+ currentPage: 1,
89
+ breakPoint: 'mo'
90
+ });
91
+ // Then: 이전만 막히고 다음은 누를 수 있다
92
+ expect(prevOf(first)?.disabled).toBe(true);
93
+ expect(nextOf(first)?.disabled).toBe(false);
94
+ // When: 마지막 페이지로 이동하면
95
+ const last = render({
96
+ totalCount: TOTAL_COUNT_3_PAGES,
97
+ itemCountPerPage: ITEM_COUNT_PER_PAGE,
98
+ pageCount: PAGE_GROUP_SIZE,
99
+ currentPage: LAST_PAGE_3,
100
+ breakPoint: 'mo'
101
+ });
102
+ // Then: 반대로 다음이 막힌다
103
+ expect(prevOf(last)?.disabled).toBe(false);
104
+ expect(nextOf(last)?.disabled).toBe(true);
105
+ });
106
+ it('페이지가 하나뿐이면 mo 에서도 이전·다음 버튼을 내보내지 않는다', () => {
107
+ // Given/When: 1페이지 분량을 mo 로 렌더하면
108
+ const el = render({
109
+ totalCount: TOTAL_COUNT_1_PAGE,
110
+ itemCountPerPage: ITEM_COUNT_PER_PAGE,
111
+ pageCount: PAGE_GROUP_SIZE,
112
+ currentPage: 1,
113
+ breakPoint: 'mo'
114
+ });
115
+ // Then: 이동할 곳이 없으므로 버튼도 없다
116
+ expect(prevOf(el)).toBeNull();
117
+ expect(nextOf(el)).toBeNull();
118
+ });
119
+ it('pc 는 기존대로 페이지 그룹을 넘길 때만 점프 버튼을 노출한다', () => {
120
+ // Given/When: 3페이지 분량을 pc 로 렌더하면
121
+ const el = render({
122
+ totalCount: TOTAL_COUNT_3_PAGES,
123
+ itemCountPerPage: ITEM_COUNT_PER_PAGE,
124
+ pageCount: PAGE_GROUP_SIZE,
125
+ currentPage: 1,
126
+ breakPoint: 'pc'
127
+ });
128
+ // Then: 페이지 번호로 직접 이동하므로 점프 버튼은 나오지 않는다
129
+ expect(prevOf(el)).toBeNull();
130
+ expect(nextOf(el)).toBeNull();
131
+ expect(pageNums(el)).toHaveLength(LAST_PAGE_3);
132
+ });
59
133
  });
@@ -3,6 +3,7 @@ import { AlertTriangle, CheckCircle, InfoCircle, MessageChatSquare, XClose } fro
3
3
  import classNames from 'classnames';
4
4
  import { forwardRef, useEffect, useRef, useState } from 'react';
5
5
  import { COLOR } from '../../../../constant/color';
6
+ import { HIDE_PERMANENTLY_LABEL } from '../../../../constant/notification';
6
7
  const iconMap = {
7
8
  neutral: MessageChatSquare,
8
9
  error: AlertTriangle,
@@ -28,6 +29,7 @@ const FullWidthNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
28
29
  autoClose = 0,
29
30
  supportTextLink,
30
31
  onHidePermanently,
32
+ hidePermanentlyLabel = HIDE_PERMANENTLY_LABEL.fullWidth,
31
33
  ...rest
32
34
  } = _ref;
33
35
  const [shouldRemove, setShouldRemove] = useState(false);
@@ -109,7 +111,7 @@ const FullWidthNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
109
111
  type: "button",
110
112
  className: classNames('ncua-notification__action-button', 'ncua-notification__action-button--text', 'ncua-full-width-notification__link'),
111
113
  onClick: onHidePermanently,
112
- children: "\uB2E4\uC2DC\uBCF4\uC9C0 \uC54A\uAE30"
114
+ children: hidePermanentlyLabel
113
115
  }), onClose && _jsx("button", {
114
116
  type: "button",
115
117
  className: "ncua-full-width-notification__close-button",
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { AlertCircle, AlertTriangle, CheckCircle, Pin02, XClose } from '@ncds/ui-admin-icon';
2
+ import { AlertCircle, AlertTriangle, CheckCircle, Pin02 } from '@ncds/ui-admin-icon';
3
3
  import classNames from 'classnames';
4
4
  import { forwardRef } from 'react';
5
5
  import { COLOR } from '../../../../constant/color';
6
- import { Button } from '../../action/button';
7
- import { FeaturedIcon } from '../../image-and-icons/featured-icon/FeaturedIcon';
6
+ import { MessageNotificationActions, MessageNotificationContent } from './MessageNotificationParts';
8
7
  const iconMap = {
9
8
  neutral: Pin02,
10
9
  error: AlertTriangle,
@@ -27,18 +26,11 @@ const MessageNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
27
26
  className,
28
27
  actions,
29
28
  onHidePermanently,
29
+ hidePermanentlyLabel,
30
30
  ...rest
31
31
  } = _ref;
32
32
  // message 타입은 neutral, error, warning, success 4가지 색상만 지원
33
33
  const validColor = color === 'info' ? 'neutral' : color;
34
- const iconColor = validColor;
35
- const featuredIconProps = {
36
- icon: Icon || iconMap[validColor] || Pin02,
37
- size: 'lg',
38
- color: iconColor,
39
- theme: 'light-circle'
40
- };
41
- const closeIconColor = COLOR[iconColorMap[validColor] || 'gray700'];
42
34
  return _jsx("div", {
43
35
  ref: ref,
44
36
  className: classNames('ncua-message-notification', `ncua-message-notification--${validColor}`, className),
@@ -48,50 +40,18 @@ const MessageNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
48
40
  className: "ncua-message-notification__container",
49
41
  children: _jsxs("div", {
50
42
  className: "ncua-message-notification__content",
51
- children: [_jsxs("div", {
52
- className: "ncua-message-notification__content-wrapper",
53
- children: [iconMap[validColor] && _jsx(FeaturedIcon, {
54
- ...featuredIconProps,
55
- className: "ncua-message-notification__icon"
56
- }), _jsxs("div", {
57
- className: "ncua-message-notification__text-container",
58
- children: [_jsx("span", {
59
- className: "ncua-message-notification__title",
60
- children: title
61
- }), supportingText && _jsx("span", {
62
- className: "ncua-message-notification__supporting-text",
63
- children: supportingText
64
- })]
65
- })]
66
- }), _jsx("div", {
67
- className: "ncua-message-notification__actions-container",
68
- children: actions && _jsx("div", {
69
- className: "ncua-message-notification__actions",
70
- children: actions.map(action => _jsx(Button, {
71
- size: "xs",
72
- hierarchy: action.hierarchy || 'text',
73
- label: action.label,
74
- onClick: action?.onClick
75
- }, `${action.label}-${action.hierarchy}`))
76
- })
77
- }), _jsxs("div", {
78
- className: "ncua-message-notification__footer-container",
79
- children: [onHidePermanently && _jsx("button", {
80
- type: "button",
81
- className: classNames('ncua-notification__action-button', 'ncua-notification__action-button--link', 'ncua-message-notification__hide-link'),
82
- onClick: onHidePermanently,
83
- children: "\uB2E4\uC2DC \uBCF4\uC9C0 \uC54A\uAE30"
84
- }), onClose && _jsx("button", {
85
- type: "button",
86
- className: "ncua-message-notification__close-button",
87
- onClick: onClose,
88
- "aria-label": "\uC54C\uB9BC \uB2EB\uAE30",
89
- children: _jsx(XClose, {
90
- width: 20,
91
- height: 20,
92
- color: closeIconColor
93
- })
94
- })]
43
+ children: [_jsx(MessageNotificationContent, {
44
+ title: title,
45
+ supportingText: supportingText,
46
+ icon: Icon || iconMap[validColor],
47
+ iconColor: validColor,
48
+ showIcon: Boolean(iconMap[validColor])
49
+ }), _jsx(MessageNotificationActions, {
50
+ actions: actions,
51
+ onClose: onClose,
52
+ onHidePermanently: onHidePermanently,
53
+ hidePermanentlyLabel: hidePermanentlyLabel,
54
+ closeIconColor: COLOR[iconColorMap[validColor] || 'gray700']
95
55
  })]
96
56
  })
97
57
  })