@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.
- package/README.md +166 -0
- package/package.json +67 -0
- package/src/components/actions/Button.tsx +612 -0
- package/src/components/actions/ButtonGroup.tsx +728 -0
- package/src/components/actions/Copy.tsx +98 -0
- package/src/components/actions/DarkModeToggle.tsx +80 -0
- package/src/components/actions/Link.tsx +37 -0
- package/src/components/actions/index.ts +19 -0
- package/src/components/actions/useCopyToClipboard.ts +90 -0
- package/src/components/charts/Chart.tsx +331 -0
- package/src/components/charts/Sparkline.tsx +156 -0
- package/src/components/charts/index.ts +13 -0
- package/src/components/data-display/Avatar.tsx +208 -0
- package/src/components/data-display/AvatarGroup.tsx +228 -0
- package/src/components/data-display/Badge.tsx +70 -0
- package/src/components/data-display/Carousel.tsx +214 -0
- package/src/components/data-display/ColorSwatch.tsx +56 -0
- package/src/components/data-display/DataTable.tsx +886 -0
- package/src/components/data-display/EmptyState.tsx +61 -0
- package/src/components/data-display/Image.tsx +277 -0
- package/src/components/data-display/Kbd.tsx +114 -0
- package/src/components/data-display/Persona.tsx +78 -0
- package/src/components/data-display/StatCard.tsx +338 -0
- package/src/components/data-display/Table.tsx +147 -0
- package/src/components/data-display/Tag.tsx +91 -0
- package/src/components/data-display/Timeline.tsx +200 -0
- package/src/components/data-display/TreeView.tsx +172 -0
- package/src/components/data-display/Video.tsx +95 -0
- package/src/components/data-display/avatar-utils.ts +32 -0
- package/src/components/data-display/index.ts +81 -0
- package/src/components/feedback/Loading.tsx +159 -0
- package/src/components/feedback/Progress.tsx +321 -0
- package/src/components/feedback/Skeleton.tsx +62 -0
- package/src/components/feedback/SkeletonBlocks.tsx +222 -0
- package/src/components/feedback/Toast.tsx +648 -0
- package/src/components/feedback/index.ts +44 -0
- package/src/components/feedback/password/PasswordStrengthIndicator.tsx +232 -0
- package/src/components/feedback/password/password-strength.ts +115 -0
- package/src/components/feedback/password/password-validation-data.ts +66 -0
- package/src/components/feedback/password/password-validation.ts +93 -0
- package/src/components/forms/Autocomplete.tsx +268 -0
- package/src/components/forms/Checkbox.tsx +155 -0
- package/src/components/forms/CodeInput.tsx +237 -0
- package/src/components/forms/ColorPicker/ColorPicker.tsx +469 -0
- package/src/components/forms/ColorPicker/color-utils.ts +75 -0
- package/src/components/forms/ColorPicker/index.ts +2 -0
- package/src/components/forms/DatePicker.tsx +516 -0
- package/src/components/forms/DateRangePicker.tsx +464 -0
- package/src/components/forms/FieldPicker.tsx +64 -0
- package/src/components/forms/FileUpload.tsx +614 -0
- package/src/components/forms/FilterBuilder/FilterGroupBlock.ts +6 -0
- package/src/components/forms/FilterBuilder.tsx +16 -0
- package/src/components/forms/FilterRuleRow.tsx +68 -0
- package/src/components/forms/Input.tsx +200 -0
- package/src/components/forms/MultiSelect.tsx +361 -0
- package/src/components/forms/NumberField.tsx +145 -0
- package/src/components/forms/RadioGroup.tsx +135 -0
- package/src/components/forms/RelativeDateDefaultInput.tsx +62 -0
- package/src/components/forms/ReorderableList.tsx +163 -0
- package/src/components/forms/Select.tsx +268 -0
- package/src/components/forms/Slider.tsx +260 -0
- package/src/components/forms/Switch.tsx +135 -0
- package/src/components/forms/TextArea.tsx +202 -0
- package/src/components/forms/ViewCustomizer.tsx +44 -0
- package/src/components/forms/index.ts +43 -0
- package/src/components/layout/Accordion.tsx +110 -0
- package/src/components/layout/Alert.tsx +156 -0
- package/src/components/layout/BlockQuote.tsx +70 -0
- package/src/components/layout/Card.tsx +166 -0
- package/src/components/layout/CodeBlock/CodeBlock.tsx +477 -0
- package/src/components/layout/CodeBlock/code-block-tokens.css +104 -0
- package/src/components/layout/CodeBlock/prism.ts +81 -0
- package/src/components/layout/Collapsible.tsx +84 -0
- package/src/components/layout/Container.tsx +55 -0
- package/src/components/layout/Divider.tsx +64 -0
- package/src/components/layout/Form.tsx +39 -0
- package/src/components/layout/FormActions.tsx +50 -0
- package/src/components/layout/Grid.tsx +53 -0
- package/src/components/layout/PageHeading.tsx +46 -0
- package/src/components/layout/PromptWithAction.tsx +49 -0
- package/src/components/layout/Section.tsx +60 -0
- package/src/components/layout/TablePanel.tsx +24 -0
- package/src/components/layout/TableView/TableView.tsx +1018 -0
- package/src/components/layout/TableView/index.ts +3 -0
- package/src/components/layout/TableView/types.ts +51 -0
- package/src/components/layout/WizardStep.tsx +40 -0
- package/src/components/layout/WizardStepper.tsx +173 -0
- package/src/components/layout/index.ts +96 -0
- package/src/components/navigation/Breadcrumbs.tsx +66 -0
- package/src/components/navigation/DropdownMenu.tsx +86 -0
- package/src/components/navigation/MegaMenu.tsx +480 -0
- package/src/components/navigation/NavigationMenu.tsx +305 -0
- package/src/components/navigation/Pagination.tsx +298 -0
- package/src/components/navigation/Sidebar.tsx +280 -0
- package/src/components/navigation/Tabs.tsx +122 -0
- package/src/components/navigation/ViewSwitcher.tsx +314 -0
- package/src/components/navigation/index.ts +66 -0
- package/src/components/overlays/AlertDialog.tsx +174 -0
- package/src/components/overlays/ContextMenu.tsx +65 -0
- package/src/components/overlays/Dialog.tsx +279 -0
- package/src/components/overlays/Drawer.tsx +370 -0
- package/src/components/overlays/HoverCard.tsx +107 -0
- package/src/components/overlays/Popover.tsx +73 -0
- package/src/components/overlays/Tooltip.tsx +31 -0
- package/src/components/overlays/index.ts +71 -0
- package/src/components/typography/Code.tsx +72 -0
- package/src/components/typography/Icon.tsx +36 -0
- package/src/components/typography/index.ts +10 -0
- package/src/env.d.ts +9 -0
- package/src/index.ts +13 -0
- package/src/styles/theme.css +226 -0
- package/src/types/avatar-types.ts +11 -0
- package/src/types/filter-types.ts +35 -0
- package/src/utilities/classNames.ts +6 -0
- package/src/utilities/componentSize.ts +46 -0
- package/src/utilities/i18n.tsx +60 -0
- package/src/utilities/mergeRefs.ts +12 -0
- 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,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
|
+
}
|