@torch-ui/solid 0.1.3

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 (118) hide show
  1. package/README.md +166 -0
  2. package/package.json +67 -0
  3. package/src/components/actions/Button.tsx +612 -0
  4. package/src/components/actions/ButtonGroup.tsx +728 -0
  5. package/src/components/actions/Copy.tsx +98 -0
  6. package/src/components/actions/DarkModeToggle.tsx +80 -0
  7. package/src/components/actions/Link.tsx +37 -0
  8. package/src/components/actions/index.ts +19 -0
  9. package/src/components/actions/useCopyToClipboard.ts +90 -0
  10. package/src/components/charts/Chart.tsx +331 -0
  11. package/src/components/charts/Sparkline.tsx +156 -0
  12. package/src/components/charts/index.ts +13 -0
  13. package/src/components/data-display/Avatar.tsx +208 -0
  14. package/src/components/data-display/AvatarGroup.tsx +228 -0
  15. package/src/components/data-display/Badge.tsx +70 -0
  16. package/src/components/data-display/Carousel.tsx +214 -0
  17. package/src/components/data-display/ColorSwatch.tsx +56 -0
  18. package/src/components/data-display/DataTable.tsx +886 -0
  19. package/src/components/data-display/EmptyState.tsx +61 -0
  20. package/src/components/data-display/Image.tsx +277 -0
  21. package/src/components/data-display/Kbd.tsx +114 -0
  22. package/src/components/data-display/Persona.tsx +78 -0
  23. package/src/components/data-display/StatCard.tsx +338 -0
  24. package/src/components/data-display/Table.tsx +147 -0
  25. package/src/components/data-display/Tag.tsx +91 -0
  26. package/src/components/data-display/Timeline.tsx +200 -0
  27. package/src/components/data-display/TreeView.tsx +172 -0
  28. package/src/components/data-display/Video.tsx +95 -0
  29. package/src/components/data-display/avatar-utils.ts +32 -0
  30. package/src/components/data-display/index.ts +81 -0
  31. package/src/components/feedback/Loading.tsx +159 -0
  32. package/src/components/feedback/Progress.tsx +321 -0
  33. package/src/components/feedback/Skeleton.tsx +62 -0
  34. package/src/components/feedback/SkeletonBlocks.tsx +222 -0
  35. package/src/components/feedback/Toast.tsx +648 -0
  36. package/src/components/feedback/index.ts +44 -0
  37. package/src/components/feedback/password/PasswordStrengthIndicator.tsx +232 -0
  38. package/src/components/feedback/password/password-strength.ts +115 -0
  39. package/src/components/feedback/password/password-validation-data.ts +66 -0
  40. package/src/components/feedback/password/password-validation.ts +93 -0
  41. package/src/components/forms/Autocomplete.tsx +268 -0
  42. package/src/components/forms/Checkbox.tsx +155 -0
  43. package/src/components/forms/CodeInput.tsx +237 -0
  44. package/src/components/forms/ColorPicker/ColorPicker.tsx +469 -0
  45. package/src/components/forms/ColorPicker/color-utils.ts +75 -0
  46. package/src/components/forms/ColorPicker/index.ts +2 -0
  47. package/src/components/forms/DatePicker.tsx +516 -0
  48. package/src/components/forms/DateRangePicker.tsx +464 -0
  49. package/src/components/forms/FieldPicker.tsx +64 -0
  50. package/src/components/forms/FileUpload.tsx +614 -0
  51. package/src/components/forms/FilterBuilder/FilterGroupBlock.ts +6 -0
  52. package/src/components/forms/FilterBuilder.tsx +16 -0
  53. package/src/components/forms/FilterRuleRow.tsx +68 -0
  54. package/src/components/forms/Input.tsx +200 -0
  55. package/src/components/forms/MultiSelect.tsx +361 -0
  56. package/src/components/forms/NumberField.tsx +145 -0
  57. package/src/components/forms/RadioGroup.tsx +135 -0
  58. package/src/components/forms/RelativeDateDefaultInput.tsx +62 -0
  59. package/src/components/forms/ReorderableList.tsx +163 -0
  60. package/src/components/forms/Select.tsx +268 -0
  61. package/src/components/forms/Slider.tsx +260 -0
  62. package/src/components/forms/Switch.tsx +135 -0
  63. package/src/components/forms/TextArea.tsx +202 -0
  64. package/src/components/forms/ViewCustomizer.tsx +44 -0
  65. package/src/components/forms/index.ts +43 -0
  66. package/src/components/layout/Accordion.tsx +110 -0
  67. package/src/components/layout/Alert.tsx +156 -0
  68. package/src/components/layout/BlockQuote.tsx +70 -0
  69. package/src/components/layout/Card.tsx +166 -0
  70. package/src/components/layout/CodeBlock/CodeBlock.tsx +477 -0
  71. package/src/components/layout/CodeBlock/code-block-tokens.css +104 -0
  72. package/src/components/layout/CodeBlock/prism.ts +81 -0
  73. package/src/components/layout/Collapsible.tsx +84 -0
  74. package/src/components/layout/Container.tsx +55 -0
  75. package/src/components/layout/Divider.tsx +64 -0
  76. package/src/components/layout/Form.tsx +39 -0
  77. package/src/components/layout/FormActions.tsx +50 -0
  78. package/src/components/layout/Grid.tsx +53 -0
  79. package/src/components/layout/PageHeading.tsx +46 -0
  80. package/src/components/layout/PromptWithAction.tsx +49 -0
  81. package/src/components/layout/Section.tsx +60 -0
  82. package/src/components/layout/TablePanel.tsx +24 -0
  83. package/src/components/layout/TableView/TableView.tsx +1018 -0
  84. package/src/components/layout/TableView/index.ts +3 -0
  85. package/src/components/layout/TableView/types.ts +51 -0
  86. package/src/components/layout/WizardStep.tsx +40 -0
  87. package/src/components/layout/WizardStepper.tsx +173 -0
  88. package/src/components/layout/index.ts +96 -0
  89. package/src/components/navigation/Breadcrumbs.tsx +66 -0
  90. package/src/components/navigation/DropdownMenu.tsx +86 -0
  91. package/src/components/navigation/MegaMenu.tsx +480 -0
  92. package/src/components/navigation/NavigationMenu.tsx +305 -0
  93. package/src/components/navigation/Pagination.tsx +298 -0
  94. package/src/components/navigation/Sidebar.tsx +280 -0
  95. package/src/components/navigation/Tabs.tsx +122 -0
  96. package/src/components/navigation/ViewSwitcher.tsx +314 -0
  97. package/src/components/navigation/index.ts +66 -0
  98. package/src/components/overlays/AlertDialog.tsx +174 -0
  99. package/src/components/overlays/ContextMenu.tsx +65 -0
  100. package/src/components/overlays/Dialog.tsx +279 -0
  101. package/src/components/overlays/Drawer.tsx +370 -0
  102. package/src/components/overlays/HoverCard.tsx +107 -0
  103. package/src/components/overlays/Popover.tsx +73 -0
  104. package/src/components/overlays/Tooltip.tsx +31 -0
  105. package/src/components/overlays/index.ts +71 -0
  106. package/src/components/typography/Code.tsx +72 -0
  107. package/src/components/typography/Icon.tsx +36 -0
  108. package/src/components/typography/index.ts +10 -0
  109. package/src/env.d.ts +9 -0
  110. package/src/index.ts +13 -0
  111. package/src/styles/theme.css +226 -0
  112. package/src/types/avatar-types.ts +11 -0
  113. package/src/types/filter-types.ts +35 -0
  114. package/src/utilities/classNames.ts +6 -0
  115. package/src/utilities/componentSize.ts +46 -0
  116. package/src/utilities/i18n.tsx +60 -0
  117. package/src/utilities/mergeRefs.ts +12 -0
  118. package/src/utilities/relativeDateDefault.ts +14 -0
@@ -0,0 +1,35 @@
1
+ export interface FilterGroup {
2
+ id: string
3
+ type: 'and' | 'or'
4
+ logic: 'and' | 'or'
5
+ children: FilterRule[]
6
+ }
7
+
8
+ export interface FilterRule {
9
+ id: string
10
+ field: string
11
+ operator: string
12
+ value: any
13
+ }
14
+
15
+ export interface FilterField {
16
+ id: string
17
+ label: string
18
+ type: string
19
+ }
20
+
21
+ export function formatFilterSummary(group: FilterGroup, options: { fields: FilterField[]; getOperators: (type: string) => any[] }): string {
22
+ return 'Filter summary'
23
+ }
24
+
25
+ export function formatFilterCode(group: FilterGroup, ruleNumbers: Map<string, string>): string {
26
+ return 'Filter code'
27
+ }
28
+
29
+ export function assignRuleNumbers(group: FilterGroup): Map<string, string> {
30
+ return new Map()
31
+ }
32
+
33
+ export function hasRulesWithEmptyField(group: FilterGroup): boolean {
34
+ return false
35
+ }
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from 'clsx'
2
+ import { twMerge } from 'tailwind-merge'
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Canonical interactive-component size scale.
3
+ * All TorchUI interactive components use this type so xs/sm/md/lg/xl produce
4
+ * identical rendered heights, enabling mixed-component toolbars to align naturally.
5
+ *
6
+ * Heights (border-box):
7
+ * xs → h-7 (28px)
8
+ * sm → h-8 (32px)
9
+ * md → h-9 (36px) ← standard default
10
+ * lg → h-10 (40px)
11
+ * xl → h-11 (44px)
12
+ */
13
+ export type ComponentSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
14
+
15
+ export interface InputSizeConfig {
16
+ /** Height + min-height Tailwind classes. */
17
+ h: string
18
+ /** Vertical padding class. */
19
+ py: string
20
+ /** Font-size class. */
21
+ text: string
22
+ /** Left padding when no start adornment. */
23
+ pl: string
24
+ /** Right padding when no end adornment. */
25
+ pr: string
26
+ /** Left padding when a start adornment is present. */
27
+ plAdorn: string
28
+ /** Right padding when an end adornment is present. */
29
+ prAdorn: string
30
+ /** CSS `left` value for the start adornment element. */
31
+ adornStart: string
32
+ /** CSS `right` value for the end adornment element. */
33
+ adornEnd: string
34
+ }
35
+
36
+ /**
37
+ * Per-size layout config for form-input trigger elements
38
+ * (Input, NumberField, Select, MultiSelect, Autocomplete).
39
+ */
40
+ export const inputSizeConfig: Record<ComponentSize, InputSizeConfig> = {
41
+ xs: { h: 'h-7 min-h-7', py: 'py-1', text: 'text-xs', pl: 'pl-2', pr: 'pr-2', plAdorn: 'pl-7', prAdorn: 'pr-7', adornStart: 'left-2', adornEnd: 'right-2' },
42
+ sm: { h: 'h-8 min-h-8', py: 'py-1.5', text: 'text-xs', pl: 'pl-2.5', pr: 'pr-2.5', plAdorn: 'pl-8', prAdorn: 'pr-8', adornStart: 'left-2', adornEnd: 'right-2' },
43
+ md: { h: 'h-9 min-h-9', py: 'py-2', text: 'text-sm', pl: 'pl-3', pr: 'pr-3', plAdorn: 'pl-9', prAdorn: 'pr-9', adornStart: 'left-2.5', adornEnd: 'right-2.5' },
44
+ lg: { h: 'h-10 min-h-10', py: 'py-2', text: 'text-sm', pl: 'pl-3.5', pr: 'pr-3.5', plAdorn: 'pl-10', prAdorn: 'pr-10', adornStart: 'left-3', adornEnd: 'right-3' },
45
+ xl: { h: 'h-11 min-h-11', py: 'py-2.5', text: 'text-base', pl: 'pl-4', pr: 'pr-4', plAdorn: 'pl-11', prAdorn: 'pr-11', adornStart: 'left-3.5', adornEnd: 'right-3.5' },
46
+ }
@@ -0,0 +1,60 @@
1
+ import { I18nProvider, useLocale } from '@kobalte/core/i18n'
2
+ import type { JSX } from 'solid-js'
3
+
4
+ export interface AppI18nProviderProps {
5
+ children: JSX.Element
6
+ /** Override locale (e.g. "fr-FR", "ar-SA"). If not provided, uses browser/system locale. */
7
+ locale?: string
8
+ }
9
+
10
+ /**
11
+ * Provides internationalization context for the app.
12
+ * Wraps Kobalte's I18nProvider to override browser/system locale with app settings.
13
+ *
14
+ * This enables:
15
+ * - Proper lang and dir HTML attributes for accessibility
16
+ * - RTL language support (Arabic, Hebrew, Persian, etc.)
17
+ * - Locale-aware behavior in Kobalte components
18
+ * - Foundation for future i18n features
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * function App() {
23
+ * return (
24
+ * <AppI18nProvider locale="fr-FR">
25
+ * <MyApp />
26
+ * </AppI18nProvider>
27
+ * )
28
+ * }
29
+ * ```
30
+ */
31
+ export function AppI18nProvider(props: AppI18nProviderProps) {
32
+ return (
33
+ <I18nProvider locale={props.locale}>
34
+ {props.children}
35
+ </I18nProvider>
36
+ )
37
+ }
38
+
39
+ /**
40
+ * Hook to access the current locale and direction.
41
+ * Returns reactive locale and direction values from Kobalte's useLocale.
42
+ *
43
+ * Use this in your app root to set proper HTML attributes:
44
+ *
45
+ * @example
46
+ * ```tsx
47
+ * function MyApp() {
48
+ * const { locale, direction } = useAppLocale()
49
+ * return (
50
+ * <div lang={locale()} dir={direction()}>
51
+ * Your app content
52
+ * </div>
53
+ * )
54
+ * }
55
+ * ```
56
+ */
57
+ export function useAppLocale() {
58
+ const { locale, direction } = useLocale()
59
+ return { locale, direction }
60
+ }
@@ -0,0 +1,12 @@
1
+ /** Merge multiple refs (callback or object form) so the same element is forwarded to each. */
2
+ export function mergeRefs<T>(...refs: unknown[]): (el: T) => void {
3
+ return (el: T) => {
4
+ for (const ref of refs) {
5
+ if (ref == null) continue
6
+ if (typeof ref === 'function') (ref as (el: T) => void)(el)
7
+ else if (typeof ref === 'object' && 'current' in (ref as { current?: T })) {
8
+ (ref as { current: T }).current = el
9
+ }
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,14 @@
1
+ const RELATIVE_REGEX = /^today([+-])(\d+)$/
2
+
3
+ /** Parse stored relative date (e.g. "today+0", "today-7") to sign and days. Defaults to +0. */
4
+ export function parseRelativeDateDefault(stored: string): { sign: '+' | '-'; days: number } {
5
+ const m = stored.trim().match(RELATIVE_REGEX)
6
+ if (m) return { sign: m[1] as '+' | '-', days: Math.max(0, parseInt(m[2], 10)) }
7
+ return { sign: '+', days: 0 }
8
+ }
9
+
10
+ /** Format sign + days to stored value. Normalizes to "today+0" when days is 0. */
11
+ export function formatRelativeDateDefault(sign: '+' | '-', days: number): string {
12
+ const d = Math.max(0, Math.floor(days))
13
+ return `today${d === 0 ? '+' : sign}${d}`
14
+ }