sh-ui-cli 0.15.0 → 0.21.1

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 (163) hide show
  1. package/bin/sh-ui.mjs +6 -0
  2. package/data/changelog/versions.json +366 -0
  3. package/data/registry/flutter/foundation/sh_ui_tokens.dart +385 -0
  4. package/data/registry/flutter/registry.json +336 -0
  5. package/data/registry/flutter/widgets/sh_ui_accordion.dart +255 -0
  6. package/data/registry/flutter/widgets/sh_ui_app_shell.dart +267 -0
  7. package/data/registry/flutter/widgets/sh_ui_avatar.dart +95 -0
  8. package/data/registry/flutter/widgets/sh_ui_badge.dart +82 -0
  9. package/data/registry/flutter/widgets/sh_ui_breadcrumb.dart +107 -0
  10. package/data/registry/flutter/widgets/sh_ui_button.dart +201 -0
  11. package/data/registry/flutter/widgets/sh_ui_card.dart +159 -0
  12. package/data/registry/flutter/widgets/sh_ui_carousel.dart +204 -0
  13. package/data/registry/flutter/widgets/sh_ui_checkbox.dart +154 -0
  14. package/data/registry/flutter/widgets/sh_ui_color_picker.dart +264 -0
  15. package/data/registry/flutter/widgets/sh_ui_combobox.dart +614 -0
  16. package/data/registry/flutter/widgets/sh_ui_context_menu.dart +71 -0
  17. package/data/registry/flutter/widgets/sh_ui_date_picker.dart +648 -0
  18. package/data/registry/flutter/widgets/sh_ui_dialog.dart +567 -0
  19. package/data/registry/flutter/widgets/sh_ui_dropdown_menu.dart +251 -0
  20. package/data/registry/flutter/widgets/sh_ui_file_upload.dart +200 -0
  21. package/data/registry/flutter/widgets/sh_ui_header.dart +488 -0
  22. package/data/registry/flutter/widgets/sh_ui_input.dart +664 -0
  23. package/data/registry/flutter/widgets/sh_ui_label.dart +145 -0
  24. package/data/registry/flutter/widgets/sh_ui_menubar.dart +98 -0
  25. package/data/registry/flutter/widgets/sh_ui_pagination.dart +276 -0
  26. package/data/registry/flutter/widgets/sh_ui_popover.dart +248 -0
  27. package/data/registry/flutter/widgets/sh_ui_progress.dart +47 -0
  28. package/data/registry/flutter/widgets/sh_ui_radio.dart +108 -0
  29. package/data/registry/flutter/widgets/sh_ui_select.dart +904 -0
  30. package/data/registry/flutter/widgets/sh_ui_separator.dart +42 -0
  31. package/data/registry/flutter/widgets/sh_ui_sidebar.dart +1116 -0
  32. package/data/registry/flutter/widgets/sh_ui_skeleton.dart +129 -0
  33. package/data/registry/flutter/widgets/sh_ui_slider.dart +147 -0
  34. package/data/registry/flutter/widgets/sh_ui_spinner.dart +56 -0
  35. package/data/registry/flutter/widgets/sh_ui_switch.dart +109 -0
  36. package/data/registry/flutter/widgets/sh_ui_tabs.dart +329 -0
  37. package/data/registry/flutter/widgets/sh_ui_textarea.dart +126 -0
  38. package/data/registry/flutter/widgets/sh_ui_toast.dart +362 -0
  39. package/data/registry/flutter/widgets/sh_ui_toggle.dart +229 -0
  40. package/data/registry/flutter/widgets/sh_ui_tooltip.dart +62 -0
  41. package/data/registry/react/components/accordion/index.tsx +85 -0
  42. package/data/registry/react/components/accordion/styles.css +94 -0
  43. package/data/registry/react/components/animations/animations.css +51 -0
  44. package/data/registry/react/components/avatar/index.tsx +75 -0
  45. package/data/registry/react/components/avatar/styles.css +36 -0
  46. package/data/registry/react/components/badge/index.tsx +42 -0
  47. package/data/registry/react/components/badge/styles.css +57 -0
  48. package/data/registry/react/components/base/base.css +102 -0
  49. package/data/registry/react/components/breadcrumb/index.tsx +154 -0
  50. package/data/registry/react/components/breadcrumb/styles.css +82 -0
  51. package/data/registry/react/components/breakpoints/breakpoints.css +17 -0
  52. package/data/registry/react/components/button/index.tsx +47 -0
  53. package/data/registry/react/components/button/styles.css +93 -0
  54. package/data/registry/react/components/card/index.tsx +86 -0
  55. package/data/registry/react/components/card/styles.css +73 -0
  56. package/data/registry/react/components/carousel/index.tsx +432 -0
  57. package/data/registry/react/components/carousel/styles.css +155 -0
  58. package/data/registry/react/components/checkbox/index.tsx +98 -0
  59. package/data/registry/react/components/checkbox/styles.css +75 -0
  60. package/data/registry/react/components/code-panel/copy.tsx +56 -0
  61. package/data/registry/react/components/code-panel/index.tsx +193 -0
  62. package/data/registry/react/components/code-panel/styles.css +124 -0
  63. package/data/registry/react/components/color-picker/index.tsx +466 -0
  64. package/data/registry/react/components/color-picker/styles.css +166 -0
  65. package/data/registry/react/components/combobox/index.tsx +167 -0
  66. package/data/registry/react/components/combobox/styles.css +151 -0
  67. package/data/registry/react/components/context-menu/index.tsx +253 -0
  68. package/data/registry/react/components/context-menu/styles.css +140 -0
  69. package/data/registry/react/components/date-picker/index.tsx +757 -0
  70. package/data/registry/react/components/date-picker/styles.css +279 -0
  71. package/data/registry/react/components/dialog/index.tsx +97 -0
  72. package/data/registry/react/components/dialog/styles.css +127 -0
  73. package/data/registry/react/components/dropdown-menu/index.tsx +257 -0
  74. package/data/registry/react/components/dropdown-menu/styles.css +150 -0
  75. package/data/registry/react/components/file-upload/index.tsx +489 -0
  76. package/data/registry/react/components/file-upload/styles.css +170 -0
  77. package/data/registry/react/components/focus-ring/focus-ring.css +23 -0
  78. package/data/registry/react/components/form/context.ts +92 -0
  79. package/data/registry/react/components/form/field.test.tsx +230 -0
  80. package/data/registry/react/components/form/field.tsx +236 -0
  81. package/data/registry/react/components/form/focus-first-error.ts +54 -0
  82. package/data/registry/react/components/form/form.section.test.tsx +58 -0
  83. package/data/registry/react/components/form/form.test.tsx +146 -0
  84. package/data/registry/react/components/form/form.tsx +180 -0
  85. package/data/registry/react/components/form/index.tsx +61 -0
  86. package/data/registry/react/components/form/steps.test.tsx +106 -0
  87. package/data/registry/react/components/form/steps.tsx +193 -0
  88. package/data/registry/react/components/form/store.test.ts +206 -0
  89. package/data/registry/react/components/form/store.ts +318 -0
  90. package/data/registry/react/components/form/styles.css +47 -0
  91. package/data/registry/react/components/form/types.ts +104 -0
  92. package/data/registry/react/components/form/use-sh-ui-form.ts +15 -0
  93. package/data/registry/react/components/form/utils.test.ts +44 -0
  94. package/data/registry/react/components/form/utils.ts +49 -0
  95. package/data/registry/react/components/form/validation.test.ts +67 -0
  96. package/data/registry/react/components/form/validation.ts +64 -0
  97. package/data/registry/react/components/form-rhf/README.md +27 -0
  98. package/data/registry/react/components/form-rhf/index.tsx +289 -0
  99. package/data/registry/react/components/form-rhf/rhf.test.tsx +42 -0
  100. package/data/registry/react/components/form-tanstack/README.md +27 -0
  101. package/data/registry/react/components/form-tanstack/index.tsx +352 -0
  102. package/data/registry/react/components/form-tanstack/tanstack.test.tsx +45 -0
  103. package/data/registry/react/components/form-yup/README.md +22 -0
  104. package/data/registry/react/components/form-yup/index.tsx +50 -0
  105. package/data/registry/react/components/form-yup/yup.test.ts +27 -0
  106. package/data/registry/react/components/header/index.tsx +257 -0
  107. package/data/registry/react/components/header/styles.css +190 -0
  108. package/data/registry/react/components/input/index.tsx +517 -0
  109. package/data/registry/react/components/input/styles.css +203 -0
  110. package/data/registry/react/components/label/index.tsx +54 -0
  111. package/data/registry/react/components/label/styles.css +90 -0
  112. package/data/registry/react/components/menubar/index.tsx +34 -0
  113. package/data/registry/react/components/menubar/styles.css +45 -0
  114. package/data/registry/react/components/pagination/index.tsx +271 -0
  115. package/data/registry/react/components/pagination/styles.css +105 -0
  116. package/data/registry/react/components/popover/index.tsx +115 -0
  117. package/data/registry/react/components/popover/styles.css +65 -0
  118. package/data/registry/react/components/progress/index.tsx +56 -0
  119. package/data/registry/react/components/progress/styles.css +41 -0
  120. package/data/registry/react/components/radio/index.tsx +67 -0
  121. package/data/registry/react/components/radio/styles.css +80 -0
  122. package/data/registry/react/components/select/index.tsx +236 -0
  123. package/data/registry/react/components/select/styles.css +193 -0
  124. package/data/registry/react/components/separator/index.tsx +48 -0
  125. package/data/registry/react/components/separator/styles.css +15 -0
  126. package/data/registry/react/components/sidebar/index.tsx +1084 -0
  127. package/data/registry/react/components/sidebar/styles.css +502 -0
  128. package/data/registry/react/components/skeleton/index.tsx +24 -0
  129. package/data/registry/react/components/skeleton/styles.css +24 -0
  130. package/data/registry/react/components/slider/index.tsx +300 -0
  131. package/data/registry/react/components/slider/styles.css +64 -0
  132. package/data/registry/react/components/spinner/index.tsx +40 -0
  133. package/data/registry/react/components/spinner/styles.css +37 -0
  134. package/data/registry/react/components/switch/index.tsx +41 -0
  135. package/data/registry/react/components/switch/styles.css +83 -0
  136. package/data/registry/react/components/tabs/index.tsx +93 -0
  137. package/data/registry/react/components/tabs/styles.css +148 -0
  138. package/data/registry/react/components/textarea/index.tsx +25 -0
  139. package/data/registry/react/components/textarea/styles.css +54 -0
  140. package/data/registry/react/components/theme/index.tsx +91 -0
  141. package/data/registry/react/components/toast/index.tsx +257 -0
  142. package/data/registry/react/components/toast/styles.css +290 -0
  143. package/data/registry/react/components/toggle/index.tsx +133 -0
  144. package/data/registry/react/components/toggle/styles.css +85 -0
  145. package/data/registry/react/components/tooltip/index.tsx +85 -0
  146. package/data/registry/react/components/tooltip/styles.css +44 -0
  147. package/data/registry/react/components/z-index/z-index.css +16 -0
  148. package/data/registry/react/hooks/use-active-section.ts +104 -0
  149. package/data/registry/react/hooks/use-media-query.ts +27 -0
  150. package/data/registry/react/lib/cn.ts +39 -0
  151. package/data/registry/react/peer-versions.json +10 -0
  152. package/data/registry/react/registry.json +835 -0
  153. package/data/summaries/flutter.json +42 -0
  154. package/data/summaries/react.json +50 -0
  155. package/data/tokens/build.mjs +553 -0
  156. package/data/tokens/src/primitives.json +146 -0
  157. package/data/tokens/src/semantic.json +146 -0
  158. package/package.json +9 -2
  159. package/src/add.mjs +41 -15
  160. package/src/list.mjs +3 -11
  161. package/src/mcp.mjs +308 -0
  162. package/src/paths.mjs +59 -0
  163. package/src/remove.mjs +4 -11
@@ -0,0 +1,203 @@
1
+ .sh-ui-input {
2
+ display: block;
3
+ width: 100%;
4
+ height: var(--control-md);
5
+ padding: 0 var(--space-3);
6
+ background: var(--background);
7
+ color: var(--foreground);
8
+ border: 1px solid var(--border);
9
+ border-radius: var(--radius);
10
+ font-family: inherit;
11
+ font-size: var(--text-sm);
12
+ line-height: 1;
13
+ transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
14
+ -webkit-tap-highlight-color: transparent;
15
+ }
16
+
17
+ /* 모바일/터치: 최소 탭 영역 + iOS 자동 줌 방지(16px) */
18
+ @media (hover: none) and (pointer: coarse) {
19
+ .sh-ui-input {
20
+ height: 2.75rem;
21
+ font-size: var(--text-base);
22
+ }
23
+ }
24
+
25
+ .sh-ui-input::placeholder {
26
+ color: var(--foreground-subtle);
27
+ }
28
+
29
+ .sh-ui-input:hover:not(:disabled):not(:focus) {
30
+ border-color: var(--border-strong);
31
+ }
32
+
33
+ .sh-ui-input:focus {
34
+ outline: none;
35
+ border-color: var(--foreground);
36
+ box-shadow: 0 0 0 1px var(--foreground);
37
+ }
38
+
39
+ .sh-ui-input:disabled {
40
+ opacity: var(--opacity-disabled);
41
+ cursor: not-allowed;
42
+ background: var(--background-subtle);
43
+ }
44
+
45
+
46
+ .sh-ui-input:read-only {
47
+ background: var(--background-subtle);
48
+ }
49
+
50
+ /* 숫자 input 화살표 제거 (원하는 경우) */
51
+ .sh-ui-input[type="number"]::-webkit-outer-spin-button,
52
+ .sh-ui-input[type="number"]::-webkit-inner-spin-button {
53
+ -webkit-appearance: none;
54
+ margin: 0;
55
+ }
56
+ .sh-ui-input[type="number"] {
57
+ -moz-appearance: textfield;
58
+ }
59
+
60
+ /* ───────── prefix / suffix ───────── */
61
+
62
+ .sh-ui-input-wrap {
63
+ position: relative;
64
+ width: 100%;
65
+ display: block;
66
+ }
67
+
68
+ .sh-ui-input--with-prefix { padding-left: var(--space-10); }
69
+ .sh-ui-input--with-suffix { padding-right: var(--space-10); }
70
+
71
+ .sh-ui-input__affix {
72
+ position: absolute;
73
+ top: 50%;
74
+ transform: translateY(-50%);
75
+ display: inline-flex;
76
+ align-items: center;
77
+ justify-content: center;
78
+ color: var(--foreground-muted);
79
+ pointer-events: none;
80
+ }
81
+ .sh-ui-input__affix--prefix { left: var(--space-3); }
82
+ .sh-ui-input__affix--suffix { right: var(--space-1); }
83
+
84
+ /* suffix 내부 클릭 가능한 요소(버튼 등)는 pointer-events 복원 */
85
+ .sh-ui-input__affix > * { pointer-events: auto; }
86
+
87
+ /* 비밀번호 토글 버튼 */
88
+ .sh-ui-input__toggle {
89
+ display: inline-flex;
90
+ align-items: center;
91
+ justify-content: center;
92
+ width: 2rem;
93
+ height: 2rem;
94
+ padding: 0;
95
+ background: transparent;
96
+ border: none;
97
+ border-radius: calc(var(--radius) - 2px);
98
+ color: var(--foreground-muted);
99
+ cursor: pointer;
100
+ transition: color var(--duration-fast), background-color var(--duration-fast);
101
+ -webkit-tap-highlight-color: transparent;
102
+ }
103
+ .sh-ui-input__toggle:hover { color: var(--foreground); background: var(--background-muted); }
104
+ .sh-ui-input__toggle:focus-visible {
105
+ outline: var(--border-width-strong) solid var(--foreground);
106
+ outline-offset: 2px;
107
+ }
108
+
109
+ /* 에러 상태 — aria-invalid="true" 기반 */
110
+ .sh-ui-input[aria-invalid="true"] {
111
+ border-color: var(--danger);
112
+ }
113
+ .sh-ui-input[aria-invalid="true"]:focus {
114
+ box-shadow: 0 0 0 1px var(--danger);
115
+ }
116
+
117
+ /* ───────── InputGroup + InputAdornment ───────── */
118
+
119
+ .sh-ui-input-group {
120
+ display: flex;
121
+ align-items: center;
122
+ width: 100%;
123
+ min-height: var(--control-md);
124
+ padding: 0 var(--space-2);
125
+ gap: var(--space-2);
126
+ background: var(--background);
127
+ color: var(--foreground);
128
+ border: 1px solid var(--border);
129
+ border-radius: var(--radius);
130
+ transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
131
+ cursor: text;
132
+ -webkit-tap-highlight-color: transparent;
133
+ }
134
+
135
+ @media (hover: none) and (pointer: coarse) {
136
+ .sh-ui-input-group {
137
+ min-height: 2.75rem;
138
+ }
139
+ }
140
+
141
+ .sh-ui-input-group:hover:not([data-disabled]):not(:focus-within) {
142
+ border-color: var(--border-strong);
143
+ }
144
+
145
+ .sh-ui-input-group:focus-within {
146
+ border-color: var(--foreground);
147
+ box-shadow: 0 0 0 1px var(--foreground);
148
+ }
149
+
150
+ .sh-ui-input-group[aria-invalid="true"] {
151
+ border-color: var(--danger);
152
+ }
153
+ .sh-ui-input-group[aria-invalid="true"]:focus-within {
154
+ box-shadow: 0 0 0 1px var(--danger);
155
+ }
156
+
157
+ .sh-ui-input-group[data-disabled] {
158
+ opacity: var(--opacity-disabled);
159
+ cursor: not-allowed;
160
+ background: var(--background-subtle);
161
+ }
162
+
163
+ /* 그룹 내부의 Input은 자체 보더/배경/포커스 링을 모두 감춘다 */
164
+ .sh-ui-input[data-in-group] {
165
+ flex: 1 1 auto;
166
+ min-width: 0;
167
+ height: auto;
168
+ padding: 0;
169
+ background: transparent;
170
+ border: none;
171
+ border-radius: 0;
172
+ box-shadow: none;
173
+ }
174
+
175
+ .sh-ui-input[data-in-group]:focus,
176
+ .sh-ui-input[data-in-group]:hover {
177
+ border: none;
178
+ box-shadow: none;
179
+ outline: none;
180
+ }
181
+
182
+ .sh-ui-input[data-in-group]:disabled {
183
+ background: transparent;
184
+ }
185
+
186
+ /* 그룹 안에서는 Input-wrap도 단순 flex 자식으로 */
187
+ .sh-ui-input-wrap[data-in-group] {
188
+ flex: 1 1 auto;
189
+ min-width: 0;
190
+ }
191
+
192
+ .sh-ui-input-group__adornment {
193
+ display: inline-flex;
194
+ align-items: center;
195
+ justify-content: center;
196
+ flex: 0 0 auto;
197
+ color: var(--foreground-muted);
198
+ padding: 0 var(--space-1);
199
+ }
200
+
201
+ .sh-ui-input-group__adornment[data-interactive] {
202
+ padding: 0;
203
+ }
@@ -0,0 +1,54 @@
1
+ import * as React from "react";
2
+ import "./styles.css";
3
+
4
+ export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
5
+ /**
6
+ * 필수 필드 표시. `true`면 `::after`로 `*` 표시가 붙는다.
7
+ * Input에 `required` 속성이 있으면 CSS `:has()`로 자동 감지되므로 보통 명시 불필요.
8
+ *
9
+ * @default false
10
+ */
11
+ isRequired?: boolean;
12
+ }
13
+
14
+ function cx(...args: (string | undefined | false)[]) {
15
+ return args.filter(Boolean).join(" ");
16
+ }
17
+
18
+ /**
19
+ * 폼 컨트롤과 1:1로 연결되는 레이블. `htmlFor`로 컨트롤의 `id`와 매칭하거나
20
+ * Label 안에 컨트롤을 감싸 묵시적으로 연결한다. 클릭 시 자동으로 컨트롤에 포커스가 간다.
21
+ */
22
+ export const Label = React.forwardRef<HTMLLabelElement, LabelProps>(
23
+ ({ className, children, isRequired, ...props }, ref) => (
24
+ <label
25
+ ref={ref}
26
+ className={cx("sh-ui-label", className)}
27
+ data-required={isRequired || undefined}
28
+ {...props}
29
+ >
30
+ {children}
31
+ </label>
32
+ ),
33
+ );
34
+ Label.displayName = "Label";
35
+
36
+ /** Label 안의 주 라벨 텍스트. 구조적 그룹핑이 필요할 때 Label과 함께 사용. */
37
+ export function LabelTitle({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) {
38
+ return <span className={cx("sh-ui-label__title", className)} {...props} />;
39
+ }
40
+
41
+ /** 라벨 옆에 약하게 표시되는 보조 텍스트(예: "선택 사항"). */
42
+ export function LabelSubtitle({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) {
43
+ return <span className={cx("sh-ui-label__subtitle", className)} {...props} />;
44
+ }
45
+
46
+ /** 라벨 아래에 붙는 안내 문구. 컨트롤과 `aria-describedby`로 연결할 것. */
47
+ export function LabelDescription({ className, ...props }: React.HTMLAttributes<HTMLParagraphElement>) {
48
+ return <p className={cx("sh-ui-label__description", className)} {...props} />;
49
+ }
50
+
51
+ /** 라벨 아래의 보조 캡션(예: 입력 형식 예시, 글자 수 제한). */
52
+ export function LabelCaption({ className, ...props }: React.HTMLAttributes<HTMLParagraphElement>) {
53
+ return <p className={cx("sh-ui-label__caption", className)} {...props} />;
54
+ }
@@ -0,0 +1,90 @@
1
+ .sh-ui-label {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 0.125rem;
5
+ font-size: var(--text-sm);
6
+ font-weight: var(--weight-medium);
7
+ line-height: 1.4;
8
+ color: var(--foreground);
9
+ cursor: pointer;
10
+ user-select: none;
11
+ }
12
+
13
+ .sh-ui-label:not(:has(.sh-ui-label__title, .sh-ui-label__subtitle, .sh-ui-label__description, .sh-ui-label__caption)) {
14
+ display: block;
15
+ }
16
+
17
+ /* ───── 텍스트 계층 ───── */
18
+
19
+ /* Title — 주 라벨 텍스트 (기본). Label에 서브컴포넌트 없이 텍스트만 넣으면 이 스타일. */
20
+ .sh-ui-label__title {
21
+ font-weight: var(--weight-semibold);
22
+ font-size: var(--text-sm);
23
+ color: var(--foreground);
24
+ }
25
+
26
+ /* Subtitle — 부제. 타이틀 옆이나 아래에 보조 강조. */
27
+ .sh-ui-label__subtitle {
28
+ font-weight: var(--weight-regular);
29
+ font-size: 0.8125rem;
30
+ color: var(--foreground);
31
+ }
32
+
33
+ /* Description — 설명. 입력 필드 가이드. */
34
+ .sh-ui-label__description {
35
+ margin: 0;
36
+ font-weight: var(--weight-regular);
37
+ font-size: 0.8125rem;
38
+ line-height: 1.4;
39
+ color: var(--foreground-muted);
40
+ }
41
+
42
+ /* Caption — 흐린 설명. 가장 덜 중요한 보조 텍스트. */
43
+ .sh-ui-label__caption {
44
+ margin: 0;
45
+ font-weight: var(--weight-regular);
46
+ font-size: var(--text-xs);
47
+ line-height: 1.3;
48
+ color: var(--foreground-subtle, var(--foreground-muted));
49
+ opacity: 0.75;
50
+ }
51
+
52
+ /* ───── 필수 표시 (* 마크) ─────
53
+ * 1) isRequired prop (data-required) — 명시적 수동 지정
54
+ * 2) 인접 폼 컴포넌트에 required 속성 — CSS :has()로 자동 감지
55
+ * ::after는 Label의 첫 번째 인라인 자식(타이틀) 뒤에 표시. */
56
+
57
+ /* LabelTitle sub-component가 있는 경우 */
58
+ .sh-ui-label[data-required] > .sh-ui-label__title::after,
59
+ .sh-ui-label:has(+ .sh-ui-input:required) > .sh-ui-label__title::after,
60
+ .sh-ui-label:has(+ .sh-ui-input-wrap .sh-ui-input:required) > .sh-ui-label__title::after,
61
+ .sh-ui-label:has(+ .sh-ui-textarea:required) > .sh-ui-label__title::after,
62
+ .sh-ui-label:has(+ .sh-ui-combobox__input:required) > .sh-ui-label__title::after {
63
+ content: " *";
64
+ color: var(--danger);
65
+ font-weight: var(--weight-semibold);
66
+ }
67
+
68
+ /* Title 없이 Label에 직접 텍스트를 넣은 경우 */
69
+ .sh-ui-label[data-required]:not(:has(.sh-ui-label__title))::after,
70
+ .sh-ui-label:not(:has(.sh-ui-label__title)):has(+ .sh-ui-input:required)::after,
71
+ .sh-ui-label:not(:has(.sh-ui-label__title)):has(+ .sh-ui-input-wrap .sh-ui-input:required)::after,
72
+ .sh-ui-label:not(:has(.sh-ui-label__title)):has(+ .sh-ui-textarea:required)::after,
73
+ .sh-ui-label:not(:has(.sh-ui-label__title)):has(+ .sh-ui-combobox__input:required)::after {
74
+ content: " *";
75
+ color: var(--danger);
76
+ font-weight: var(--weight-semibold);
77
+ }
78
+
79
+ /* ───── disabled 자동 감지 ─────
80
+ * 인접 폼 컴포넌트가 disabled이면 Label도 흐리게. */
81
+ .sh-ui-label:has(+ .sh-ui-input:disabled),
82
+ .sh-ui-label:has(+ .sh-ui-input-wrap .sh-ui-input:disabled),
83
+ .sh-ui-label:has(+ .sh-ui-textarea:disabled),
84
+ .sh-ui-label:has(+ .sh-ui-select__trigger:disabled),
85
+ .sh-ui-label:has(+ .sh-ui-combobox__input:disabled),
86
+ .sh-ui-label:has(+ .sh-ui-date-picker__trigger:disabled),
87
+ .sh-ui-label:has(+ .sh-ui-file-upload .sh-ui-file-upload__dropzone--disabled) {
88
+ opacity: var(--opacity-disabled);
89
+ cursor: not-allowed;
90
+ }
@@ -0,0 +1,34 @@
1
+ import * as React from "react";
2
+ import { Menubar as BaseMenubar } from "@base-ui-components/react/menubar";
3
+ import "./styles.css";
4
+
5
+ type WithStringClassName<T> = Omit<T, "className"> & { className?: string };
6
+
7
+ function cx(...args: (string | undefined | false | null)[]) {
8
+ return args.filter(Boolean).join(" ");
9
+ }
10
+
11
+ /**
12
+ * 상단 앱 메뉴바(파일/편집/보기 등). 내부에 DropdownMenu를 나란히 배치하여
13
+ * 좌우 화살표로 메뉴 간 이동이 가능해진다.
14
+ *
15
+ * <Menubar>
16
+ * <DropdownMenu>
17
+ * <DropdownMenuTrigger>파일</DropdownMenuTrigger>
18
+ * <DropdownMenuContent>...</DropdownMenuContent>
19
+ * </DropdownMenu>
20
+ * <DropdownMenu>...</DropdownMenu>
21
+ * </Menubar>
22
+ */
23
+ export const Menubar = React.forwardRef<
24
+ HTMLDivElement,
25
+ WithStringClassName<React.ComponentPropsWithoutRef<typeof BaseMenubar>>
26
+ >(function Menubar({ className, ...props }, ref) {
27
+ return (
28
+ <BaseMenubar
29
+ ref={ref}
30
+ className={cx("sh-ui-menubar", className)}
31
+ {...props}
32
+ />
33
+ );
34
+ });
@@ -0,0 +1,45 @@
1
+ .sh-ui-menubar {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ gap: var(--space-1);
5
+ padding: var(--space-1);
6
+ background: var(--background);
7
+ border: 1px solid var(--border);
8
+ border-radius: var(--radius);
9
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
10
+ }
11
+
12
+ /* Menubar 안의 DropdownMenuTrigger는 메뉴바 항목 스타일로 재지정.
13
+ dropdown-menu가 함께 설치되어 있어야 한다(registryDependencies).
14
+ 사용자가 render로 자체 엘리먼트를 넘겨 덮어쓸 수 있다. */
15
+ .sh-ui-menubar .sh-ui-dm__trigger {
16
+ display: inline-flex;
17
+ align-items: center;
18
+ gap: var(--space-1);
19
+ padding: var(--space-1) var(--space-3);
20
+ height: var(--control-md);
21
+ border: 0;
22
+ border-radius: calc(var(--radius) - 2px);
23
+ background: transparent;
24
+ color: var(--foreground);
25
+ font-size: var(--text-sm);
26
+ line-height: 1;
27
+ cursor: pointer;
28
+ transition: background-color var(--duration-fast), color var(--duration-fast);
29
+ }
30
+
31
+ .sh-ui-menubar .sh-ui-dm__trigger:hover,
32
+ .sh-ui-menubar .sh-ui-dm__trigger[data-popup-open] {
33
+ background: var(--background-muted);
34
+ }
35
+
36
+ .sh-ui-menubar .sh-ui-dm__trigger:focus-visible {
37
+ outline: var(--border-width-strong) solid var(--foreground);
38
+ outline-offset: -1px;
39
+ }
40
+
41
+ @media (prefers-reduced-motion: reduce) {
42
+ .sh-ui-menubar .sh-ui-dm__trigger {
43
+ transition: none;
44
+ }
45
+ }
@@ -0,0 +1,271 @@
1
+ import * as React from "react";
2
+ import "./styles.css";
3
+
4
+ function cx(...args: (string | undefined | false | null)[]) {
5
+ return args.filter(Boolean).join(" ");
6
+ }
7
+
8
+ /* ───────── Pagination (nav) ─────────
9
+ * 시맨틱: <nav aria-label="Pagination"><ul>...</ul></nav>.
10
+ * 현재 페이지 링크에 aria-current="page"를 부여해 스크린리더가 위치를 읽게 한다.
11
+ */
12
+
13
+ /**
14
+ * 페이지 분할 내비게이션의 시맨틱 컨테이너(`<nav aria-label="Pagination">`).
15
+ * 자식 구조: PaginationContent > PaginationItem × n > PaginationLink/Previous/Next/Ellipsis.
16
+ */
17
+ export const Pagination = React.forwardRef<
18
+ HTMLElement,
19
+ React.HTMLAttributes<HTMLElement>
20
+ >(function Pagination({ className, ...props }, ref) {
21
+ return (
22
+ <nav
23
+ ref={ref}
24
+ aria-label="Pagination"
25
+ className={cx("sh-ui-pagination", className)}
26
+ {...props}
27
+ />
28
+ );
29
+ });
30
+
31
+ /* ───────── Content (ul) ───────── */
32
+
33
+ /** 페이지 항목들을 담는 정렬되지 않은 리스트(`<ul>`). */
34
+ export const PaginationContent = React.forwardRef<
35
+ HTMLUListElement,
36
+ React.HTMLAttributes<HTMLUListElement>
37
+ >(function PaginationContent({ className, ...props }, ref) {
38
+ return (
39
+ <ul
40
+ ref={ref}
41
+ className={cx("sh-ui-pagination__content", className)}
42
+ {...props}
43
+ />
44
+ );
45
+ });
46
+
47
+ /* ───────── Item (li) ───────── */
48
+
49
+ /** 한 페이지 슬롯(`<li>`). PaginationLink/Previous/Next/Ellipsis를 자식으로 둔다. */
50
+ export const PaginationItem = React.forwardRef<
51
+ HTMLLIElement,
52
+ React.LiHTMLAttributes<HTMLLIElement>
53
+ >(function PaginationItem({ className, ...props }, ref) {
54
+ return (
55
+ <li
56
+ ref={ref}
57
+ className={cx("sh-ui-pagination__item", className)}
58
+ {...props}
59
+ />
60
+ );
61
+ });
62
+
63
+ /* ───────── Link ─────────
64
+ * 숫자 페이지 링크. isActive일 때 aria-current="page" + 시각 강조.
65
+ */
66
+
67
+ export interface PaginationLinkProps
68
+ extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
69
+ /**
70
+ * 현재 페이지 표시. `true`면 `aria-current="page"`가 자동 부여되고 시각적으로 강조된다.
71
+ * @default false
72
+ */
73
+ isActive?: boolean;
74
+ /**
75
+ * 크기.
76
+ * - `sm` — 컴팩트
77
+ * - `md` — 일반 (기본)
78
+ *
79
+ * @default "md"
80
+ */
81
+ size?: "sm" | "md";
82
+ }
83
+
84
+ /**
85
+ * 숫자 페이지 링크. `isActive`이면 `aria-current="page"`가 자동 부여되어
86
+ * 스크린리더가 현재 위치를 읽는다.
87
+ */
88
+ export const PaginationLink = React.forwardRef<
89
+ HTMLAnchorElement,
90
+ PaginationLinkProps
91
+ >(function PaginationLink(
92
+ { className, isActive, size = "md", ...props },
93
+ ref,
94
+ ) {
95
+ return (
96
+ <a
97
+ ref={ref}
98
+ aria-current={isActive ? "page" : undefined}
99
+ data-active={isActive ? "" : undefined}
100
+ data-size={size}
101
+ className={cx("sh-ui-pagination__link", className)}
102
+ {...props}
103
+ />
104
+ );
105
+ });
106
+
107
+ /* ───────── Previous / Next ─────────
108
+ * 아이콘 + 레이블. 레이블이 없는 아이콘 버튼에는 aria-label로 의미 전달.
109
+ */
110
+
111
+ /** "이전 페이지" 링크. 화살표 아이콘과 라벨이 함께 렌더되며 `aria-label`이 자동 부여된다. */
112
+ export const PaginationPrevious = React.forwardRef<
113
+ HTMLAnchorElement,
114
+ PaginationLinkProps
115
+ >(function PaginationPrevious({ className, children, ...props }, ref) {
116
+ return (
117
+ <PaginationLink
118
+ ref={ref}
119
+ aria-label="이전 페이지"
120
+ className={cx("sh-ui-pagination__nav", className)}
121
+ {...props}
122
+ >
123
+ <ChevronLeftIcon />
124
+ {children ?? <span>이전</span>}
125
+ </PaginationLink>
126
+ );
127
+ });
128
+
129
+ /** "다음 페이지" 링크. */
130
+ export const PaginationNext = React.forwardRef<
131
+ HTMLAnchorElement,
132
+ PaginationLinkProps
133
+ >(function PaginationNext({ className, children, ...props }, ref) {
134
+ return (
135
+ <PaginationLink
136
+ ref={ref}
137
+ aria-label="다음 페이지"
138
+ className={cx("sh-ui-pagination__nav", className)}
139
+ {...props}
140
+ >
141
+ {children ?? <span>다음</span>}
142
+ <ChevronRightIcon />
143
+ </PaginationLink>
144
+ );
145
+ });
146
+
147
+ /* ───────── Ellipsis — 생략 표시 ───────── */
148
+
149
+ /** 페이지 사이 생략을 표현하는 점 3개. 시각만 표현하고 스크린리더에는 무시된다. */
150
+ export const PaginationEllipsis = React.forwardRef<
151
+ HTMLSpanElement,
152
+ React.HTMLAttributes<HTMLSpanElement>
153
+ >(function PaginationEllipsis({ className, ...props }, ref) {
154
+ return (
155
+ <span
156
+ ref={ref}
157
+ role="presentation"
158
+ aria-hidden="true"
159
+ className={cx("sh-ui-pagination__ellipsis", className)}
160
+ {...props}
161
+ >
162
+ <svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden>
163
+ <circle cx="3" cy="8" r="1.25" />
164
+ <circle cx="8" cy="8" r="1.25" />
165
+ <circle cx="13" cy="8" r="1.25" />
166
+ </svg>
167
+ <span className="sh-ui-pagination__sr">더 많은 페이지</span>
168
+ </span>
169
+ );
170
+ });
171
+
172
+ /* ───────── 페이지 범위 유틸 ─────────
173
+ * 현재 페이지 주변 siblings개 + 양 끝 1개 + 필요한 곳에 "dots"를 넣어
174
+ * 렌더할 토큰 배열을 돌려준다.
175
+ *
176
+ * 예: page=5, totalPages=10, siblings=1 → [1, "dots", 4, 5, 6, "dots", 10]
177
+ *
178
+ * page·totalPages는 1-based를 가정한다.
179
+ */
180
+
181
+ export type PaginationToken = number | "dots";
182
+
183
+ /**
184
+ * 1-based `page`/`totalPages`로부터 렌더할 토큰 배열을 만든다.
185
+ * 양 끝과 현재 주변 `siblings`개를 보여주고, 끊긴 구간엔 `"dots"`를 넣어준다.
186
+ *
187
+ * @param args.page - 1-based 현재 페이지.
188
+ * @param args.siblings - 현재 페이지 양옆에 보일 페이지 개수.
189
+ * @returns 렌더 토큰 배열. 숫자 또는 문자열 `"dots"`로 구성.
190
+ * @example
191
+ * getPaginationRange({ page: 5, totalPages: 10, siblings: 1 })
192
+ * // [1, "dots", 4, 5, 6, "dots", 10]
193
+ */
194
+ export function getPaginationRange({
195
+ page,
196
+ totalPages,
197
+ siblings = 1,
198
+ }: {
199
+ /** 1-based 현재 페이지. */
200
+ page: number;
201
+ /** 전체 페이지 수. */
202
+ totalPages: number;
203
+ /**
204
+ * 현재 페이지 양옆에 보일 페이지 개수.
205
+ * @default 1
206
+ */
207
+ siblings?: number;
208
+ }): PaginationToken[] {
209
+ if (totalPages <= 0) return [];
210
+
211
+ // 끝점 2개(첫/마지막) + 현재 주변 (2*siblings + 1) + dots 2개가 총 페이지 수보다 크거나 같으면
212
+ // 생략 없이 전부 보여준다.
213
+ const totalSlots = siblings * 2 + 5;
214
+ if (totalPages <= totalSlots) {
215
+ return range(1, totalPages);
216
+ }
217
+
218
+ const leftSibling = Math.max(page - siblings, 1);
219
+ const rightSibling = Math.min(page + siblings, totalPages);
220
+
221
+ const showLeftDots = leftSibling > 2;
222
+ const showRightDots = rightSibling < totalPages - 1;
223
+
224
+ // 왼쪽만 닫혀있음 → [1 ... right side]
225
+ if (!showLeftDots && showRightDots) {
226
+ const leftCount = 3 + 2 * siblings;
227
+ return [...range(1, leftCount), "dots", totalPages];
228
+ }
229
+
230
+ // 오른쪽만 닫혀있음 → [1 ... left side]
231
+ if (showLeftDots && !showRightDots) {
232
+ const rightCount = 3 + 2 * siblings;
233
+ return [1, "dots", ...range(totalPages - rightCount + 1, totalPages)];
234
+ }
235
+
236
+ // 양쪽 모두 생략
237
+ return [1, "dots", ...range(leftSibling, rightSibling), "dots", totalPages];
238
+ }
239
+
240
+ function range(start: number, end: number): number[] {
241
+ const length = end - start + 1;
242
+ return Array.from({ length }, (_, i) => start + i);
243
+ }
244
+
245
+ function ChevronLeftIcon() {
246
+ return (
247
+ <svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden>
248
+ <path
249
+ d="M10 4l-4 4 4 4"
250
+ stroke="currentColor"
251
+ strokeWidth="1.5"
252
+ strokeLinecap="round"
253
+ strokeLinejoin="round"
254
+ />
255
+ </svg>
256
+ );
257
+ }
258
+
259
+ function ChevronRightIcon() {
260
+ return (
261
+ <svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden>
262
+ <path
263
+ d="M6 4l4 4-4 4"
264
+ stroke="currentColor"
265
+ strokeWidth="1.5"
266
+ strokeLinecap="round"
267
+ strokeLinejoin="round"
268
+ />
269
+ </svg>
270
+ );
271
+ }