@suphark/ui 0.6.1 → 0.8.0

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/src/index.ts CHANGED
@@ -15,7 +15,22 @@ export type { DateRange } from "react-day-picker";
15
15
  export { toast } from "sonner";
16
16
  export { ActionForm } from "./components/shared/action-form";
17
17
  export * from "./components/shared/button";
18
+ export {
19
+ type CalendarDayContext,
20
+ type CalendarDayState,
21
+ CalendarMonthGrid,
22
+ type CalendarMonthGridProps,
23
+ WEEKDAYS_EN,
24
+ WEEKDAYS_TH,
25
+ } from "./components/shared/calendar-month-grid";
18
26
  export { ClientRedirect } from "./components/shared/client-redirect";
27
+ export {
28
+ ColorPicker,
29
+ type ColorPickerItem,
30
+ type ColorPickerProps,
31
+ type ColorPickerText,
32
+ ColorSwatch,
33
+ } from "./components/shared/color-picker";
19
34
  export { Combobox } from "./components/shared/combobox";
20
35
  export {
21
36
  ConfirmDialog,
@@ -36,9 +51,17 @@ export {
36
51
  type PromptSpec,
37
52
  useDialogs,
38
53
  } from "./components/shared/dialogs-provider";
54
+ export {
55
+ Dropzone,
56
+ type DropzoneProps,
57
+ type DropzoneRejectReason,
58
+ type DropzoneText,
59
+ matchesAccept,
60
+ } from "./components/shared/dropzone";
39
61
  export { EmptyRow } from "./components/shared/empty-row";
40
62
  export { EmptyState } from "./components/shared/empty-state";
41
63
  export { EnvSnippet, randomSecret } from "./components/shared/env-snippet";
64
+ export { type FileKind, FileTypeIcon, getFileKind } from "./components/shared/file-type-icon";
42
65
  export { FormFieldBoolean } from "./components/shared/form/form-field-boolean";
43
66
  export { FormFieldColorSelect } from "./components/shared/form/form-field-color-select";
44
67
  export { FormFieldCombobox } from "./components/shared/form/form-field-combobox";
@@ -60,7 +83,18 @@ export {
60
83
  type SimpleSelectOptions,
61
84
  type SimpleSelectProps,
62
85
  } from "./components/shared/form/simple-select";
63
- export { type FormAction, FormMessage, type FormState } from "./components/shared/form-message";
86
+ export {
87
+ type FormAction,
88
+ FormMessage,
89
+ type FormRenderContext,
90
+ type FormState,
91
+ } from "./components/shared/form-message";
92
+ export {
93
+ IconPicker,
94
+ type IconPickerItem,
95
+ type IconPickerProps,
96
+ type IconPickerText,
97
+ } from "./components/shared/icon-picker";
64
98
  export { Initials, initialsOf } from "./components/shared/initials";
65
99
  export { ErrorState, type RouteError } from "./components/shared/layout/error-state";
66
100
  export {
@@ -77,8 +111,10 @@ export { Notice, type NoticeTone } from "./components/shared/notice";
77
111
  export { type DecimalLike, FormattedNumber } from "./components/shared/number/formatted-number";
78
112
  export { PageHeader } from "./components/shared/page-header";
79
113
  export { PageSkeleton } from "./components/shared/page-skeleton";
114
+ export { ProgressBar, type ProgressTone } from "./components/shared/progress-bar";
80
115
  export { SecretReveal } from "./components/shared/secret-reveal";
81
116
  export { SectionCard } from "./components/shared/section-card";
117
+ export { SelectionButton } from "./components/shared/selection-button";
82
118
  export { Stat } from "./components/shared/stat";
83
119
  export { StatusBadge, statusTone, type Tone } from "./components/shared/status-badge";
84
120
  export { SwitcherChevron } from "./components/shared/switcher-chevron";
@@ -88,6 +124,7 @@ export {
88
124
  } from "./components/shared/text/primary-secondary-text";
89
125
  export * from "./components/shared/theme";
90
126
  export { ClientDateFormatter } from "./components/shared/time/client-date-formatter";
127
+ export { type TreeNode, TreeView, type TreeViewProps } from "./components/shared/tree-view";
91
128
  export {
92
129
  UI_TEXT_EN,
93
130
  UI_TEXT_TH,
@@ -95,6 +132,13 @@ export {
95
132
  UiTextProvider,
96
133
  useUiText,
97
134
  } from "./components/shared/ui-text";
135
+ export {
136
+ type UploadItem,
137
+ UploadList,
138
+ type UploadListProps,
139
+ type UploadListText,
140
+ type UploadStatus,
141
+ } from "./components/shared/upload-list";
98
142
  // ---------- shadcn/ui primitives ----------
99
143
  export * from "./components/ui/accordion";
100
144
  export * from "./components/ui/alert";
@@ -162,7 +206,7 @@ export { useMounted } from "./hooks/use-mounted";
162
206
  export { useTicker } from "./hooks/use-ticker";
163
207
  export { useTrackedState } from "./hooks/use-tracked-state";
164
208
  export { copyText, selectContents } from "./lib/copy-text";
165
- export { formatRelativeThaiDate, formatThaiFullDate } from "./lib/formatters";
209
+ export { formatBytes, formatRelativeThaiDate, formatThaiFullDate } from "./lib/formatters";
166
210
  export { getDateTimeFormat, getNumberFormat } from "./lib/intl-cache";
167
211
  export {
168
212
  type AtomicPermissionRequirement,
@@ -44,3 +44,20 @@ export function formatThaiFullDate(date: Date | string | number | null | undefin
44
44
 
45
45
  return `${d.getDate()} ${THAI_MONTH_SHORT[d.getMonth()]} ${d.getFullYear() + 543}`;
46
46
  }
47
+
48
+ /**
49
+ * ขนาดไฟล์อ่านง่าย (ฐาน 1024): 0 B, 1.5 KB, 12.3 MB, 1.2 GB — ตัวเลขทศนิยม 1 ตำแหน่งเมื่อ < 10
50
+ * formatBytes(1536) → "1.5 KB"
51
+ */
52
+ export function formatBytes(bytes: number | null | undefined, locale = "th-TH"): string {
53
+ if (bytes == null || !Number.isFinite(bytes) || bytes < 0) return "—";
54
+ const units = ["B", "KB", "MB", "GB", "TB"] as const;
55
+ let value = bytes;
56
+ let i = 0;
57
+ while (value >= 1024 && i < units.length - 1) {
58
+ value /= 1024;
59
+ i += 1;
60
+ }
61
+ const digits = i === 0 ? 0 : value < 10 ? 1 : 0;
62
+ return `${value.toLocaleString(locale, { maximumFractionDigits: digits })} ${units[i]}`;
63
+ }