@jogak/ui 0.1.0-alpha.10.3 → 0.1.0-alpha.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jogak/ui",
3
- "version": "0.1.0-alpha.10.3",
3
+ "version": "0.1.0-alpha.12",
4
4
  "description": "Showcase viewer UI for Jogak — Sidebar / Preview / Controls / Actions and the JogakApp shell.",
5
5
  "keywords": [
6
6
  "jogak",
@@ -65,7 +65,7 @@
65
65
  "prism-react-renderer": "^2.4.1",
66
66
  "tailwindcss": "^4.0.0",
67
67
  "@tailwindcss/vite": "^4.0.0",
68
- "@jogak/core": "0.1.0-alpha.10.3"
68
+ "@jogak/core": "0.1.0-alpha.12"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/node": "^20.14.0",
@@ -137,6 +137,12 @@ export function Controls({ args, argTypes, onArgChange }: ControlsProps): ReactE
137
137
  const keys = Array.from(new Set([...Object.keys(args), ...Object.keys(argTypes)]))
138
138
  const entries = keys.map((k) => [k, args[k]] as const)
139
139
 
140
+ // 알파.12: defaultValue를 가진 prop이 하나라도 있으면 Default 컬럼 노출.
141
+ // 모두 비어 있으면 컬럼 자체를 숨겨 테이블 가독성을 유지.
142
+ const hasAnyDefault = entries.some(
143
+ ([key]) => argTypes[key]?.defaultValue !== undefined,
144
+ )
145
+
140
146
  return (
141
147
  <div className="jogak:border-t-2 jogak:border-[var(--jogak-color-border)]">
142
148
  <div className="jogak:px-5 jogak:py-1.5 jogak:text-[11px] jogak:font-bold jogak:text-[var(--jogak-color-fg-subtle)] jogak:uppercase jogak:tracking-[0.08em] jogak:border-b jogak:border-[var(--jogak-color-border)] jogak:bg-[var(--jogak-color-bg-subtle)]">
@@ -152,6 +158,7 @@ export function Controls({ args, argTypes, onArgChange }: ControlsProps): ReactE
152
158
  <tr>
153
159
  <th className={thClass}>Name</th>
154
160
  <th className={thClass}>Control</th>
161
+ {hasAnyDefault && <th className={thClass}>Default</th>}
155
162
  <th className={thClass}>Description</th>
156
163
  </tr>
157
164
  </thead>
@@ -176,6 +183,18 @@ export function Controls({ args, argTypes, onArgChange }: ControlsProps): ReactE
176
183
  onArgChange={onArgChange}
177
184
  />
178
185
  </td>
186
+ {hasAnyDefault && (
187
+ <td
188
+ className={clsx(
189
+ tdClass,
190
+ 'jogak:font-[family-name:var(--jogak-font-mono)] jogak:text-[12px] jogak:text-[var(--jogak-color-fg-muted)] jogak:whitespace-nowrap',
191
+ )}
192
+ >
193
+ {argType?.defaultValue !== undefined
194
+ ? formatDefaultValue(argType.defaultValue)
195
+ : ''}
196
+ </td>
197
+ )}
179
198
  <td className={clsx(tdClass, 'jogak:text-[var(--jogak-color-fg-subtle)]')}>
180
199
  {argType?.description ?? ''}
181
200
  </td>
@@ -188,3 +207,20 @@ export function Controls({ args, argTypes, onArgChange }: ControlsProps): ReactE
188
207
  </div>
189
208
  )
190
209
  }
210
+
211
+ /**
212
+ * 알파.12: defaultValue를 Controls 패널에 표시할 때 사용. JSON-safe 값은 작은
213
+ * 인용부호로 string, 그 외 literal은 그대로 직렬화. 의도: 사용자가 코드에 쓸 수
214
+ * 있는 형태로 보여주기.
215
+ */
216
+ function formatDefaultValue(v: unknown): string {
217
+ if (typeof v === 'string') return `'${v}'`
218
+ if (typeof v === 'number' || typeof v === 'boolean' || v === null) {
219
+ return String(v)
220
+ }
221
+ try {
222
+ return JSON.stringify(v)
223
+ } catch {
224
+ return String(v)
225
+ }
226
+ }