@ttt-productions/ui-core 0.11.33 → 0.11.35
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 +1 -1
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +1 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/reload-recovery-watch.d.ts +2 -6
- package/dist/browser/reload-recovery-watch.d.ts.map +1 -1
- package/dist/browser/reload-recovery-watch.js +5 -10
- package/dist/browser/reload-recovery-watch.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/format-numbers.d.ts +0 -6
- package/dist/lib/format-numbers.d.ts.map +1 -1
- package/dist/lib/format-numbers.js +2 -8
- package/dist/lib/format-numbers.js.map +1 -1
- package/dist/lib/reload-recovery.d.ts +1 -9
- package/dist/lib/reload-recovery.d.ts.map +1 -1
- package/dist/lib/reload-recovery.js +14 -24
- package/dist/lib/reload-recovery.js.map +1 -1
- package/dist/lib/utils.d.ts +0 -3
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +0 -3
- package/dist/lib/utils.js.map +1 -1
- package/dist/react/components/accordion.d.ts +2 -2
- package/dist/react/components/accordion.d.ts.map +1 -1
- package/dist/react/components/accordion.js +8 -8
- package/dist/react/components/accordion.js.map +1 -1
- package/dist/react/components/action-row.d.ts +2 -9
- package/dist/react/components/action-row.d.ts.map +1 -1
- package/dist/react/components/action-row.js +7 -11
- package/dist/react/components/action-row.js.map +1 -1
- package/dist/react/components/alert-dialog.d.ts +2 -2
- package/dist/react/components/alert-dialog.d.ts.map +1 -1
- package/dist/react/components/alert-dialog.js +15 -15
- package/dist/react/components/alert-dialog.js.map +1 -1
- package/dist/react/components/alert.d.ts +2 -2
- package/dist/react/components/alert.d.ts.map +1 -1
- package/dist/react/components/alert.js +12 -12
- package/dist/react/components/alert.js.map +1 -1
- package/dist/react/components/avatar.d.ts +2 -2
- package/dist/react/components/avatar.d.ts.map +1 -1
- package/dist/react/components/avatar.js +7 -7
- package/dist/react/components/avatar.js.map +1 -1
- package/dist/react/components/badge.d.ts +2 -2
- package/dist/react/components/badge.d.ts.map +1 -1
- package/dist/react/components/badge.js +9 -9
- package/dist/react/components/badge.js.map +1 -1
- package/dist/react/components/button.d.ts +2 -12
- package/dist/react/components/button.d.ts.map +1 -1
- package/dist/react/components/button.js +30 -35
- package/dist/react/components/button.js.map +1 -1
- package/dist/react/components/card.d.ts +1 -1
- package/dist/react/components/card.d.ts.map +1 -1
- package/dist/react/components/card.js +15 -15
- package/dist/react/components/card.js.map +1 -1
- package/dist/react/components/checkbox.d.ts +2 -2
- package/dist/react/components/checkbox.d.ts.map +1 -1
- package/dist/react/components/checkbox.js +6 -6
- package/dist/react/components/checkbox.js.map +1 -1
- package/dist/react/components/collapsible.d.ts +1 -1
- package/dist/react/components/collapsible.d.ts.map +1 -1
- package/dist/react/components/collapsible.js +2 -2
- package/dist/react/components/collapsible.js.map +1 -1
- package/dist/react/components/consequence-dialog.d.ts +1 -48
- package/dist/react/components/consequence-dialog.d.ts.map +1 -1
- package/dist/react/components/consequence-dialog.js +7 -23
- package/dist/react/components/consequence-dialog.js.map +1 -1
- package/dist/react/components/date-picker.d.ts +1 -18
- package/dist/react/components/date-picker.d.ts.map +1 -1
- package/dist/react/components/date-picker.js +102 -98
- package/dist/react/components/date-picker.js.map +1 -1
- package/dist/react/components/date-time-picker.d.ts +1 -24
- package/dist/react/components/date-time-picker.d.ts.map +1 -1
- package/dist/react/components/date-time-picker.js +20 -37
- package/dist/react/components/date-time-picker.js.map +1 -1
- package/dist/react/components/dialog.d.ts +2 -2
- package/dist/react/components/dialog.d.ts.map +1 -1
- package/dist/react/components/dialog.js +14 -14
- package/dist/react/components/dialog.js.map +1 -1
- package/dist/react/components/dropdown-menu.d.ts +2 -10
- package/dist/react/components/dropdown-menu.d.ts.map +1 -1
- package/dist/react/components/dropdown-menu.js +24 -20
- package/dist/react/components/dropdown-menu.js.map +1 -1
- package/dist/react/components/end-of-list-indicator.d.ts +1 -1
- package/dist/react/components/end-of-list-indicator.js +3 -3
- package/dist/react/components/end-of-list-indicator.js.map +1 -1
- package/dist/react/components/form.d.ts +3 -3
- package/dist/react/components/form.d.ts.map +1 -1
- package/dist/react/components/form.js +17 -17
- package/dist/react/components/form.js.map +1 -1
- package/dist/react/components/format-control.d.ts +7 -20
- package/dist/react/components/format-control.d.ts.map +1 -1
- package/dist/react/components/format-control.js +18 -22
- package/dist/react/components/format-control.js.map +1 -1
- package/dist/react/components/input.d.ts +10 -27
- package/dist/react/components/input.d.ts.map +1 -1
- package/dist/react/components/input.js +11 -9
- package/dist/react/components/input.js.map +1 -1
- package/dist/react/components/label.d.ts +3 -3
- package/dist/react/components/label.d.ts.map +1 -1
- package/dist/react/components/label.js +6 -6
- package/dist/react/components/label.js.map +1 -1
- package/dist/react/components/layout/screen-adaptive-view.d.ts +2 -9
- package/dist/react/components/layout/screen-adaptive-view.d.ts.map +1 -1
- package/dist/react/components/layout/screen-adaptive-view.js +40 -37
- package/dist/react/components/layout/screen-adaptive-view.js.map +1 -1
- package/dist/react/components/list-pagination.d.ts +1 -31
- package/dist/react/components/list-pagination.d.ts.map +1 -1
- package/dist/react/components/list-pagination.js +10 -37
- package/dist/react/components/list-pagination.js.map +1 -1
- package/dist/react/components/menubar.d.ts +2 -2
- package/dist/react/components/menubar.d.ts.map +1 -1
- package/dist/react/components/menubar.js +17 -17
- package/dist/react/components/menubar.js.map +1 -1
- package/dist/react/components/opener-focus.d.ts +2 -8
- package/dist/react/components/opener-focus.d.ts.map +1 -1
- package/dist/react/components/opener-focus.js +4 -10
- package/dist/react/components/opener-focus.js.map +1 -1
- package/dist/react/components/pending-guard.d.ts +1 -7
- package/dist/react/components/pending-guard.d.ts.map +1 -1
- package/dist/react/components/pending-guard.js +1 -7
- package/dist/react/components/pending-guard.js.map +1 -1
- package/dist/react/components/popover.d.ts +2 -2
- package/dist/react/components/popover.d.ts.map +1 -1
- package/dist/react/components/popover.js +5 -5
- package/dist/react/components/popover.js.map +1 -1
- package/dist/react/components/progress.d.ts +2 -2
- package/dist/react/components/progress.d.ts.map +1 -1
- package/dist/react/components/progress.js +5 -5
- package/dist/react/components/progress.js.map +1 -1
- package/dist/react/components/radio-group.d.ts +2 -2
- package/dist/react/components/radio-group.d.ts.map +1 -1
- package/dist/react/components/radio-group.js +7 -7
- package/dist/react/components/radio-group.js.map +1 -1
- package/dist/react/components/relative-time.d.ts +1 -9
- package/dist/react/components/relative-time.d.ts.map +1 -1
- package/dist/react/components/relative-time.js +8 -11
- package/dist/react/components/relative-time.js.map +1 -1
- package/dist/react/components/reload-recovery-notice.d.ts +3 -17
- package/dist/react/components/reload-recovery-notice.d.ts.map +1 -1
- package/dist/react/components/reload-recovery-notice.js +7 -12
- package/dist/react/components/reload-recovery-notice.js.map +1 -1
- package/dist/react/components/scroll-area.d.ts +2 -2
- package/dist/react/components/scroll-area.d.ts.map +1 -1
- package/dist/react/components/scroll-area.js +6 -8
- package/dist/react/components/scroll-area.js.map +1 -1
- package/dist/react/components/scroll-to-top-button.d.ts +6 -30
- package/dist/react/components/scroll-to-top-button.d.ts.map +1 -1
- package/dist/react/components/scroll-to-top-button.js +9 -9
- package/dist/react/components/scroll-to-top-button.js.map +1 -1
- package/dist/react/components/search-dropdown.d.ts +0 -53
- package/dist/react/components/search-dropdown.d.ts.map +1 -1
- package/dist/react/components/search-dropdown.js +10 -39
- package/dist/react/components/search-dropdown.js.map +1 -1
- package/dist/react/components/select.d.ts +2 -9
- package/dist/react/components/select.d.ts.map +1 -1
- package/dist/react/components/select.js +19 -21
- package/dist/react/components/select.js.map +1 -1
- package/dist/react/components/separator.d.ts +2 -2
- package/dist/react/components/separator.d.ts.map +1 -1
- package/dist/react/components/separator.js +5 -5
- package/dist/react/components/separator.js.map +1 -1
- package/dist/react/components/sheet.d.ts +3 -3
- package/dist/react/components/sheet.d.ts.map +1 -1
- package/dist/react/components/sheet.js +21 -21
- package/dist/react/components/sheet.js.map +1 -1
- package/dist/react/components/show-more-toggle.d.ts +2 -18
- package/dist/react/components/show-more-toggle.d.ts.map +1 -1
- package/dist/react/components/show-more-toggle.js +6 -11
- package/dist/react/components/show-more-toggle.js.map +1 -1
- package/dist/react/components/skeleton.d.ts +1 -1
- package/dist/react/components/skeleton.d.ts.map +1 -1
- package/dist/react/components/skeleton.js +3 -3
- package/dist/react/components/skeleton.js.map +1 -1
- package/dist/react/components/slider.d.ts +2 -2
- package/dist/react/components/slider.d.ts.map +1 -1
- package/dist/react/components/slider.js +5 -5
- package/dist/react/components/slider.js.map +1 -1
- package/dist/react/components/spinner.d.ts +1 -15
- package/dist/react/components/spinner.d.ts.map +1 -1
- package/dist/react/components/spinner.js +10 -18
- package/dist/react/components/spinner.js.map +1 -1
- package/dist/react/components/switch.d.ts +2 -9
- package/dist/react/components/switch.d.ts.map +1 -1
- package/dist/react/components/switch.js +13 -10
- package/dist/react/components/switch.js.map +1 -1
- package/dist/react/components/table.d.ts +2 -12
- package/dist/react/components/table.d.ts.map +1 -1
- package/dist/react/components/table.js +24 -30
- package/dist/react/components/table.js.map +1 -1
- package/dist/react/components/tabs.d.ts +2 -2
- package/dist/react/components/tabs.d.ts.map +1 -1
- package/dist/react/components/tabs.js +7 -7
- package/dist/react/components/tabs.js.map +1 -1
- package/dist/react/components/textarea.d.ts +5 -16
- package/dist/react/components/textarea.d.ts.map +1 -1
- package/dist/react/components/textarea.js +11 -9
- package/dist/react/components/textarea.js.map +1 -1
- package/dist/react/components/toast.d.ts +4 -8
- package/dist/react/components/toast.d.ts.map +1 -1
- package/dist/react/components/toast.js +26 -47
- package/dist/react/components/toast.js.map +1 -1
- package/dist/react/components/toaster.d.ts.map +1 -1
- package/dist/react/components/toaster.js +5 -5
- package/dist/react/components/toaster.js.map +1 -1
- package/dist/react/components/tooltip.d.ts +2 -2
- package/dist/react/components/tooltip.d.ts.map +1 -1
- package/dist/react/components/tooltip.js +5 -5
- package/dist/react/components/tooltip.js.map +1 -1
- package/dist/react/hooks/use-async-action.d.ts +1 -21
- package/dist/react/hooks/use-async-action.d.ts.map +1 -1
- package/dist/react/hooks/use-async-action.js +3 -11
- package/dist/react/hooks/use-async-action.js.map +1 -1
- package/dist/react/hooks/use-cursor-page.d.ts +1 -63
- package/dist/react/hooks/use-cursor-page.d.ts.map +1 -1
- package/dist/react/hooks/use-cursor-page.js +3 -39
- package/dist/react/hooks/use-cursor-page.js.map +1 -1
- package/dist/react/hooks/use-media-query.js +5 -5
- package/dist/react/hooks/use-media-query.js.map +1 -1
- package/dist/react/hooks/use-paged-list.d.ts +0 -43
- package/dist/react/hooks/use-paged-list.d.ts.map +1 -1
- package/dist/react/hooks/use-paged-list.js +2 -17
- package/dist/react/hooks/use-paged-list.js.map +1 -1
- package/dist/react/hooks/use-return-scroll.d.ts +1 -10
- package/dist/react/hooks/use-return-scroll.d.ts.map +1 -1
- package/dist/react/hooks/use-return-scroll.js +13 -45
- package/dist/react/hooks/use-return-scroll.js.map +1 -1
- package/dist/react/hooks/use-toast.d.ts +3 -11
- package/dist/react/hooks/use-toast.d.ts.map +1 -1
- package/dist/react/hooks/use-toast.js +18 -21
- package/dist/react/hooks/use-toast.js.map +1 -1
- package/dist/react/index.d.ts +74 -74
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +51 -57
- package/dist/react/index.js.map +1 -1
- package/package.json +8 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { CheckCircle2 } from
|
|
3
|
-
import { cn } from
|
|
2
|
+
import { CheckCircle2 } from 'lucide-react';
|
|
3
|
+
import { cn } from '../../lib/utils.js';
|
|
4
4
|
export function EndOfListIndicator({ message = "You've reached the end!", className, icon, }) {
|
|
5
|
-
return (_jsxs("div", { className: cn(
|
|
5
|
+
return (_jsxs("div", { className: cn('flex flex-col items-center gap-2 py-8 text-center text-muted-foreground', className), children: [icon ?? _jsx(CheckCircle2, { className: "h-6 w-6 text-[color:var(--success-icon)]" }), _jsx("p", { className: "text-sm", children: message })] }));
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=end-of-list-indicator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"end-of-list-indicator.js","sourceRoot":"","sources":["../../../src/react/components/end-of-list-indicator.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAQxC,MAAM,UAAU,kBAAkB,CAAC,EACjC,OAAO,GAAG,yBAAyB,EACnC,SAAS,EACT,IAAI,GACoB;IACxB,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,yEAAyE,EACzE,SAAS,CACV,aAEA,IAAI,IAAI,KAAC,YAAY,IAAC,SAAS,EAAC,0CAA0C,GAAG,EAC9E,YAAG,SAAS,EAAC,SAAS,YAAE,OAAO,GAAK,IAChC,CACP,CAAC;AACJ,CAAC","sourcesContent":["import * as React from
|
|
1
|
+
{"version":3,"file":"end-of-list-indicator.js","sourceRoot":"","sources":["../../../src/react/components/end-of-list-indicator.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAQxC,MAAM,UAAU,kBAAkB,CAAC,EACjC,OAAO,GAAG,yBAAyB,EACnC,SAAS,EACT,IAAI,GACoB;IACxB,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,yEAAyE,EACzE,SAAS,CACV,aAEA,IAAI,IAAI,KAAC,YAAY,IAAC,SAAS,EAAC,0CAA0C,GAAG,EAC9E,YAAG,SAAS,EAAC,SAAS,YAAE,OAAO,GAAK,IAChC,CACP,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { CheckCircle2 } from 'lucide-react';\nimport { cn } from '../../lib/utils.js';\n\nexport interface EndOfListIndicatorProps {\n message?: string;\n className?: string;\n icon?: React.ReactNode;\n}\n\nexport function EndOfListIndicator({\n message = \"You've reached the end!\",\n className,\n icon,\n}: EndOfListIndicatorProps) {\n return (\n <div\n className={cn(\n 'flex flex-col items-center gap-2 py-8 text-center text-muted-foreground',\n className,\n )}\n >\n {icon ?? <CheckCircle2 className=\"h-6 w-6 text-[color:var(--success-icon)]\" />}\n <p className=\"text-sm\">{message}</p>\n </div>\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import * as LabelPrimitive from
|
|
3
|
-
import { type ControllerProps, type FieldPath, type FieldValues } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
3
|
+
import { type ControllerProps, type FieldPath, type FieldValues } from 'react-hook-form';
|
|
4
4
|
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>({ children, watch, getValues, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, handleSubmit, unregister, control, register, setFocus, subscribe, }: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
5
5
|
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => React.JSX.Element;
|
|
6
6
|
declare const useFormField: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../src/react/components/form.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../src/react/components/form.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAKzB,QAAA,MAAM,IAAI,0YAAe,CAAC;AAW1B,QAAA,MAAM,SAAS,GACb,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,KAAK,SAAS,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,YAAY,CAAC,EAC/D,cAEC,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,sBAMtC,CAAC;AAEF,QAAA,MAAM,YAAY;;;;;;;;;;;CAqBjB,CAAC;AAQF,QAAA,MAAM,QAAQ,6GAUb,CAAC;AAGF,QAAA,MAAM,SAAS,yJAcb,CAAC;AAGH,QAAA,MAAM,WAAW,8JAef,CAAC;AAGH,QAAA,MAAM,eAAe,yHAcnB,CAAC;AAGH,QAAA,MAAM,WAAW,yHAmBf,CAAC;AAGH,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,eAAe,EACf,WAAW,EACX,SAAS,GACV,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import * as React from
|
|
4
|
-
import { Slot } from
|
|
5
|
-
import { Controller, FormProvider, useFormContext, } from
|
|
6
|
-
import { cn } from
|
|
7
|
-
import { Label } from
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
5
|
+
import { Controller, FormProvider, useFormContext, } from 'react-hook-form';
|
|
6
|
+
import { cn } from '../../lib/utils.js';
|
|
7
|
+
import { Label } from './label.js';
|
|
8
8
|
const Form = FormProvider;
|
|
9
9
|
const FormFieldContext = React.createContext({});
|
|
10
10
|
const FormField = ({ ...props }) => {
|
|
@@ -16,7 +16,7 @@ const useFormField = () => {
|
|
|
16
16
|
const { getFieldState, formState } = useFormContext();
|
|
17
17
|
const fieldState = getFieldState(fieldContext.name, formState);
|
|
18
18
|
if (!fieldContext) {
|
|
19
|
-
throw new Error(
|
|
19
|
+
throw new Error('useFormField should be used within <FormField>');
|
|
20
20
|
}
|
|
21
21
|
const { id } = itemContext;
|
|
22
22
|
return {
|
|
@@ -31,31 +31,31 @@ const useFormField = () => {
|
|
|
31
31
|
const FormItemContext = React.createContext({});
|
|
32
32
|
const FormItem = React.forwardRef(({ className, ...props }, ref) => {
|
|
33
33
|
const id = React.useId();
|
|
34
|
-
return (_jsx(FormItemContext.Provider, { value: { id }, children: _jsx("div", { ref: ref, className: cn(
|
|
34
|
+
return (_jsx(FormItemContext.Provider, { value: { id }, children: _jsx("div", { ref: ref, className: cn('space-y-2', className), ...props }) }));
|
|
35
35
|
});
|
|
36
|
-
FormItem.displayName =
|
|
36
|
+
FormItem.displayName = 'FormItem';
|
|
37
37
|
const FormLabel = React.forwardRef(({ className, ...props }, ref) => {
|
|
38
38
|
const { error, formItemId } = useFormField();
|
|
39
|
-
return (_jsx(Label, { ref: ref, className: cn(error &&
|
|
39
|
+
return (_jsx(Label, { ref: ref, className: cn(error && 'text-destructive', className), htmlFor: formItemId, ...props }));
|
|
40
40
|
});
|
|
41
|
-
FormLabel.displayName =
|
|
41
|
+
FormLabel.displayName = 'FormLabel';
|
|
42
42
|
const FormControl = React.forwardRef(({ ...props }, ref) => {
|
|
43
43
|
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
44
44
|
return (_jsx(Slot, { ref: ref, id: formItemId, "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`, "aria-invalid": !!error, ...props }));
|
|
45
45
|
});
|
|
46
|
-
FormControl.displayName =
|
|
46
|
+
FormControl.displayName = 'FormControl';
|
|
47
47
|
const FormDescription = React.forwardRef(({ className, ...props }, ref) => {
|
|
48
48
|
const { formDescriptionId } = useFormField();
|
|
49
|
-
return (_jsx("p", { ref: ref, id: formDescriptionId, className: cn(
|
|
49
|
+
return (_jsx("p", { ref: ref, id: formDescriptionId, className: cn('text-sm text-muted-foreground break-words', className), ...props }));
|
|
50
50
|
});
|
|
51
|
-
FormDescription.displayName =
|
|
51
|
+
FormDescription.displayName = 'FormDescription';
|
|
52
52
|
const FormMessage = React.forwardRef(({ className, children, ...props }, ref) => {
|
|
53
53
|
const { error, formMessageId } = useFormField();
|
|
54
|
-
const body = error ? String(error?.message ??
|
|
54
|
+
const body = error ? String(error?.message ?? '') : children;
|
|
55
55
|
if (!body)
|
|
56
56
|
return null;
|
|
57
|
-
return (_jsx("p", { ref: ref, id: formMessageId, className: cn(
|
|
57
|
+
return (_jsx("p", { ref: ref, id: formMessageId, className: cn('text-sm font-medium text-destructive break-words', className), ...props, children: body }));
|
|
58
58
|
});
|
|
59
|
-
FormMessage.displayName =
|
|
59
|
+
FormMessage.displayName = 'FormMessage';
|
|
60
60
|
export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, };
|
|
61
61
|
//# sourceMappingURL=form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.js","sourceRoot":"","sources":["../../../src/react/components/form.tsx"],"names":[],"mappings":"AAAA,YAAY,
|
|
1
|
+
{"version":3,"file":"form.js","sourceRoot":"","sources":["../../../src/react/components/form.tsx"],"names":[],"mappings":"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","sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport * as LabelPrimitive from '@radix-ui/react-label';\nimport { Slot } from '@radix-ui/react-slot';\nimport {\n Controller,\n FormProvider,\n useFormContext,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from 'react-hook-form';\n\nimport { cn } from '../../lib/utils.js';\nimport { Label } from './label.js';\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState, formState } = useFormContext();\n\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error('useFormField should be used within <FormField>');\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);\n\nconst FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn('space-y-2', className)} {...props} />\n </FormItemContext.Provider>\n );\n },\n);\nFormItem.displayName = 'FormItem';\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n ref={ref}\n className={cn(error && 'text-destructive', className)}\n htmlFor={formItemId}\n {...props}\n />\n );\n});\nFormLabel.displayName = 'FormLabel';\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField();\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n aria-invalid={!!error}\n {...props}\n />\n );\n});\nFormControl.displayName = 'FormControl';\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={cn('text-sm text-muted-foreground break-words', className)}\n {...props}\n />\n );\n});\nFormDescription.displayName = 'FormDescription';\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message ?? '') : children;\n\n if (!body) return null;\n\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={cn('text-sm font-medium text-destructive break-words', className)}\n {...props}\n >\n {body}\n </p>\n );\n});\nFormMessage.displayName = 'FormMessage';\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n};\n"]}
|
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
import { type InputFormatSpec } from
|
|
1
|
+
import { type InputFormatSpec } from '@ttt-productions/input-format-core';
|
|
2
2
|
interface CallerAttributes {
|
|
3
3
|
value?: unknown;
|
|
4
4
|
readOnly?: boolean;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
'aria-required'?: boolean | 'true' | 'false';
|
|
6
|
+
'aria-invalid'?: boolean | 'true' | 'false' | 'grammar' | 'spelling';
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
9
|
-
* What a free-text control derives from its field declaration: the native length cap, and the
|
|
10
|
-
* required/invalid state assistive technology announces. A caller's own `aria-required` or
|
|
11
|
-
* `aria-invalid` wins — a form field passes the state its whole schema decided.
|
|
12
|
-
*
|
|
13
|
-
* The native cap counts the text as typed while the check counts it trimmed. Every value the
|
|
14
|
-
* field keeps can still be typed, and surrounding whitespace is dropped by the check anyway.
|
|
15
|
-
*
|
|
16
|
-
* Only a controlled value is judged, and a text that is merely too short is not marked invalid
|
|
17
|
-
* while it is being typed: an empty or half-typed required field is not yet an error, so "too
|
|
18
|
-
* short" is left to the form's submit-time validation.
|
|
19
|
-
*
|
|
20
|
-
* A read-only control shows a stored value nobody can edit there, so it is never judged: it
|
|
21
|
-
* announces neither required nor invalid (a stored value may legitimately fail the typed format).
|
|
22
|
-
*/
|
|
23
8
|
export declare function formatControlAttributes(spec: InputFormatSpec, props: CallerAttributes): {
|
|
24
9
|
maxLength: number;
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
'aria-required': boolean | "true" | "false" | undefined;
|
|
11
|
+
'aria-invalid': boolean | "true" | "false" | "grammar" | "spelling" | undefined;
|
|
27
12
|
};
|
|
13
|
+
/** The native value setter plus an input event is what React hears as a typed change. */
|
|
14
|
+
export declare function tidyOnBlur(box: HTMLInputElement | HTMLTextAreaElement, spec: InputFormatSpec): void;
|
|
28
15
|
export {};
|
|
29
16
|
//# sourceMappingURL=format-control.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-control.d.ts","sourceRoot":"","sources":["../../../src/react/components/format-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,oCAAoC,
|
|
1
|
+
{"version":3,"file":"format-control.d.ts","sourceRoot":"","sources":["../../../src/react/components/format-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE5F,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;IAC7C,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAAC;CACtE;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB;;;;EAerF;AAED,yFAAyF;AACzF,wBAAgB,UAAU,CAAC,GAAG,EAAE,gBAAgB,GAAG,mBAAmB,EAAE,IAAI,EAAE,eAAe,QAQ5F"}
|
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
import { checkInputFormat } from
|
|
2
|
-
/**
|
|
3
|
-
* What a free-text control derives from its field declaration: the native length cap, and the
|
|
4
|
-
* required/invalid state assistive technology announces. A caller's own `aria-required` or
|
|
5
|
-
* `aria-invalid` wins — a form field passes the state its whole schema decided.
|
|
6
|
-
*
|
|
7
|
-
* The native cap counts the text as typed while the check counts it trimmed. Every value the
|
|
8
|
-
* field keeps can still be typed, and surrounding whitespace is dropped by the check anyway.
|
|
9
|
-
*
|
|
10
|
-
* Only a controlled value is judged, and a text that is merely too short is not marked invalid
|
|
11
|
-
* while it is being typed: an empty or half-typed required field is not yet an error, so "too
|
|
12
|
-
* short" is left to the form's submit-time validation.
|
|
13
|
-
*
|
|
14
|
-
* A read-only control shows a stored value nobody can edit there, so it is never judged: it
|
|
15
|
-
* announces neither required nor invalid (a stored value may legitimately fail the typed format).
|
|
16
|
-
*/
|
|
1
|
+
import { checkInputFormat } from '@ttt-productions/input-format-core';
|
|
17
2
|
export function formatControlAttributes(spec, props) {
|
|
18
3
|
if (props.readOnly) {
|
|
19
4
|
return {
|
|
20
5
|
maxLength: spec.max,
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
'aria-required': props['aria-required'],
|
|
7
|
+
'aria-invalid': props['aria-invalid'],
|
|
23
8
|
};
|
|
24
9
|
}
|
|
25
|
-
const result = typeof props.value ===
|
|
26
|
-
const malformed = result !== null && !result.ok && result.issue !==
|
|
10
|
+
const result = typeof props.value === 'string' ? checkInputFormat(props.value, spec) : null;
|
|
11
|
+
const malformed = result !== null && !result.ok && result.issue !== 'tooShort';
|
|
27
12
|
return {
|
|
28
13
|
maxLength: spec.max,
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
'aria-required': props['aria-required'] ?? (spec.min > 0 ? true : undefined),
|
|
15
|
+
'aria-invalid': props['aria-invalid'] ?? (malformed ? true : undefined),
|
|
31
16
|
};
|
|
32
17
|
}
|
|
18
|
+
/** The native value setter plus an input event is what React hears as a typed change. */
|
|
19
|
+
export function tidyOnBlur(box, spec) {
|
|
20
|
+
if (box.readOnly || box.disabled)
|
|
21
|
+
return;
|
|
22
|
+
const kept = checkInputFormat(box.value, spec).value;
|
|
23
|
+
if (kept === box.value)
|
|
24
|
+
return;
|
|
25
|
+
const prototype = box instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
26
|
+
Object.getOwnPropertyDescriptor(prototype, 'value')?.set?.call(box, kept);
|
|
27
|
+
box.dispatchEvent(new Event('input', { bubbles: true }));
|
|
28
|
+
}
|
|
33
29
|
//# sourceMappingURL=format-control.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-control.js","sourceRoot":"","sources":["../../../src/react/components/format-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,oCAAoC,
|
|
1
|
+
{"version":3,"file":"format-control.js","sourceRoot":"","sources":["../../../src/react/components/format-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,oCAAoC,CAAC;AAS5F,MAAM,UAAU,uBAAuB,CAAC,IAAqB,EAAE,KAAuB;IACpF,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,GAAG;YACnB,eAAe,EAAE,KAAK,CAAC,eAAe,CAAC;YACvC,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC;SACtC,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5F,MAAM,SAAS,GAAG,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,KAAK,KAAK,UAAU,CAAC;IAC/E,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,GAAG;QACnB,eAAe,EAAE,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5E,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;KACxE,CAAC;AACJ,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,UAAU,CAAC,GAA2C,EAAE,IAAqB;IAC3F,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ;QAAE,OAAO;IACzC,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC;IACrD,IAAI,IAAI,KAAK,GAAG,CAAC,KAAK;QAAE,OAAO;IAC/B,MAAM,SAAS,GACb,GAAG,YAAY,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,SAAS,CAAC;IAClG,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC1E,GAAG,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import { checkInputFormat, type InputFormatSpec } from '@ttt-productions/input-format-core';\n\ninterface CallerAttributes {\n value?: unknown;\n readOnly?: boolean;\n 'aria-required'?: boolean | 'true' | 'false';\n 'aria-invalid'?: boolean | 'true' | 'false' | 'grammar' | 'spelling';\n}\n\nexport function formatControlAttributes(spec: InputFormatSpec, props: CallerAttributes) {\n if (props.readOnly) {\n return {\n maxLength: spec.max,\n 'aria-required': props['aria-required'],\n 'aria-invalid': props['aria-invalid'],\n };\n }\n const result = typeof props.value === 'string' ? checkInputFormat(props.value, spec) : null;\n const malformed = result !== null && !result.ok && result.issue !== 'tooShort';\n return {\n maxLength: spec.max,\n 'aria-required': props['aria-required'] ?? (spec.min > 0 ? true : undefined),\n 'aria-invalid': props['aria-invalid'] ?? (malformed ? true : undefined),\n };\n}\n\n/** The native value setter plus an input event is what React hears as a typed change. */\nexport function tidyOnBlur(box: HTMLInputElement | HTMLTextAreaElement, spec: InputFormatSpec) {\n if (box.readOnly || box.disabled) return;\n const kept = checkInputFormat(box.value, spec).value;\n if (kept === box.value) return;\n const prototype =\n box instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;\n Object.getOwnPropertyDescriptor(prototype, 'value')?.set?.call(box, kept);\n box.dispatchEvent(new Event('input', { bubbles: true }));\n}\n"]}
|
|
@@ -1,36 +1,19 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import type { DeclaredInputFormat } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type BuiltInFormatInputType = "password" | "email" | "number" | "tel" | "url" | "search" | "file" | "color" | "date" | "datetime-local" | "month" | "week" | "time" | "range" | "checkbox" | "radio" | "hidden" | "button" | "submit" | "reset" | "image";
|
|
8
|
-
type NativeInputProps = React.ComponentPropsWithoutRef<"input">;
|
|
9
|
-
/**
|
|
10
|
-
* A free-text input: its declaration is required, and its bounds and its required state come only
|
|
11
|
-
* from that declaration (ENG-005), so `maxLength`, `minLength`, `pattern`, and `required` are not
|
|
12
|
-
* props.
|
|
13
|
-
*/
|
|
14
|
-
export type FreeTextInputProps = Omit<NativeInputProps, "type" | "maxLength" | "minLength" | "pattern" | "required"> & {
|
|
15
|
-
type?: "text";
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { DeclaredInputFormat } from '@ttt-productions/input-format-core';
|
|
3
|
+
export type BuiltInFormatInputType = 'password' | 'email' | 'number' | 'tel' | 'url' | 'search' | 'file' | 'color' | 'date' | 'datetime-local' | 'month' | 'week' | 'time' | 'range' | 'checkbox' | 'radio' | 'hidden' | 'button' | 'submit' | 'reset' | 'image';
|
|
4
|
+
type NativeInputProps = React.ComponentPropsWithoutRef<'input'>;
|
|
5
|
+
export type FreeTextInputProps = Omit<NativeInputProps, 'type' | 'maxLength' | 'minLength' | 'pattern' | 'required'> & {
|
|
6
|
+
type?: 'text';
|
|
16
7
|
inputFormat: DeclaredInputFormat;
|
|
17
8
|
textEntry?: never;
|
|
18
9
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* input format; each keeps its own native `maxLength`, `pattern`, and `inputMode`, and its value is
|
|
23
|
-
* checked by its own rule (a whole-input number parse, the one-segment id rule).
|
|
24
|
-
*/
|
|
25
|
-
export type NonFreeTextEntry = "numeric" | "identifier";
|
|
26
|
-
/** A text box that is not free text: no input format. */
|
|
27
|
-
export type NonFreeTextInputProps = Omit<NativeInputProps, "type"> & {
|
|
28
|
-
type?: "text";
|
|
10
|
+
export type NonFreeTextEntry = 'numeric' | 'identifier';
|
|
11
|
+
export type NonFreeTextInputProps = Omit<NativeInputProps, 'type'> & {
|
|
12
|
+
type?: 'text';
|
|
29
13
|
textEntry: NonFreeTextEntry;
|
|
30
14
|
inputFormat?: never;
|
|
31
15
|
};
|
|
32
|
-
|
|
33
|
-
export type BuiltInFormatInputProps = Omit<NativeInputProps, "type"> & {
|
|
16
|
+
export type BuiltInFormatInputProps = Omit<NativeInputProps, 'type'> & {
|
|
34
17
|
type: BuiltInFormatInputType;
|
|
35
18
|
inputFormat?: never;
|
|
36
19
|
textEntry?: never;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/react/components/input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/react/components/input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAI9E,MAAM,MAAM,sBAAsB,GAC9B,UAAU,GACV,OAAO,GACP,QAAQ,GACR,KAAK,GACL,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,GACP,MAAM,GACN,gBAAgB,GAChB,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,GACP,UAAU,GACV,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,OAAO,CAAC;AAEZ,KAAK,gBAAgB,GAAG,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,gBAAgB,EAChB,MAAM,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAC5D,GAAG;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,mBAAmB,CAAC;IACjC,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,YAAY,CAAC;AAExD,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,GAAG;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,gBAAgB,CAAC;IAC5B,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,GAAG;IACrE,IAAI,EAAE,sBAAsB,CAAC;IAC7B,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,kBAAkB,GAAG,qBAAqB,GAAG,uBAAuB,CAAC;AAE9F,QAAA,MAAM,KAAK,qFAmBV,CAAC;AAGF,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import * as React from
|
|
4
|
-
import { cn } from
|
|
5
|
-
import { formatControlAttributes } from
|
|
6
|
-
const Input = React.forwardRef(
|
|
7
|
-
|
|
8
|
-
(
|
|
9
|
-
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '../../lib/utils.js';
|
|
5
|
+
import { formatControlAttributes, tidyOnBlur } from './format-control.js';
|
|
6
|
+
const Input = React.forwardRef(({ className, type, inputFormat, textEntry: _textEntry, onBlur, ...props }, ref) => {
|
|
7
|
+
return (_jsx("input", { type: type, className: cn('flex h-10 w-full rounded-md border-2 border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', className), ref: ref, ...props, ...(inputFormat ? formatControlAttributes(inputFormat, props) : {}), onBlur: (event) => {
|
|
8
|
+
if (inputFormat)
|
|
9
|
+
tidyOnBlur(event.currentTarget, inputFormat);
|
|
10
|
+
onBlur?.(event);
|
|
11
|
+
} }));
|
|
10
12
|
});
|
|
11
|
-
Input.displayName =
|
|
13
|
+
Input.displayName = 'Input';
|
|
12
14
|
export { Input };
|
|
13
15
|
//# sourceMappingURL=input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/react/components/input.tsx"],"names":[],"mappings":"AAAA,YAAY,
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/react/components/input.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAoD1E,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAC5B,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IACjF,OAAO,CACL,gBACE,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,EAAE,CACX,oYAAoY,EACpY,SAAS,CACV,EACD,GAAG,EAAE,GAAG,KACJ,KAAK,KACL,CAAC,WAAW,CAAC,CAAC,CAAC,uBAAuB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EACpE,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChB,IAAI,WAAW;gBAAE,UAAU,CAAC,KAAK,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;YAC9D,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC,GACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AACF,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC;AAE5B,OAAO,EAAE,KAAK,EAAE,CAAC","sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { DeclaredInputFormat } from '@ttt-productions/input-format-core';\nimport { cn } from '../../lib/utils.js';\nimport { formatControlAttributes, tidyOnBlur } from './format-control.js';\n\nexport type BuiltInFormatInputType =\n | 'password'\n | 'email'\n | 'number'\n | 'tel'\n | 'url'\n | 'search'\n | 'file'\n | 'color'\n | 'date'\n | 'datetime-local'\n | 'month'\n | 'week'\n | 'time'\n | 'range'\n | 'checkbox'\n | 'radio'\n | 'hidden'\n | 'button'\n | 'submit'\n | 'reset'\n | 'image';\n\ntype NativeInputProps = React.ComponentPropsWithoutRef<'input'>;\n\nexport type FreeTextInputProps = Omit<\n NativeInputProps,\n 'type' | 'maxLength' | 'minLength' | 'pattern' | 'required'\n> & {\n type?: 'text';\n inputFormat: DeclaredInputFormat;\n textEntry?: never;\n};\n\nexport type NonFreeTextEntry = 'numeric' | 'identifier';\n\nexport type NonFreeTextInputProps = Omit<NativeInputProps, 'type'> & {\n type?: 'text';\n textEntry: NonFreeTextEntry;\n inputFormat?: never;\n};\n\nexport type BuiltInFormatInputProps = Omit<NativeInputProps, 'type'> & {\n type: BuiltInFormatInputType;\n inputFormat?: never;\n textEntry?: never;\n};\n\nexport type InputProps = FreeTextInputProps | NonFreeTextInputProps | BuiltInFormatInputProps;\n\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(\n ({ className, type, inputFormat, textEntry: _textEntry, onBlur, ...props }, ref) => {\n return (\n <input\n type={type}\n className={cn(\n 'flex h-10 w-full rounded-md border-2 border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',\n className,\n )}\n ref={ref}\n {...props}\n {...(inputFormat ? formatControlAttributes(inputFormat, props) : {})}\n onBlur={(event) => {\n if (inputFormat) tidyOnBlur(event.currentTarget, inputFormat);\n onBlur?.(event);\n }}\n />\n );\n },\n);\nInput.displayName = 'Input';\n\nexport { Input };\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import * as LabelPrimitive from
|
|
3
|
-
import { type VariantProps } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
3
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
4
4
|
declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & VariantProps<(props?: import("class-variance-authority/types").ClassProp | undefined) => string> & React.RefAttributes<HTMLLabelElement>>;
|
|
5
5
|
export { Label };
|
|
6
6
|
//# sourceMappingURL=label.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../../src/react/components/label.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../../src/react/components/label.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAQlE,QAAA,MAAM,KAAK,4PAKT,CAAC;AAGH,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import * as React from
|
|
4
|
-
import * as LabelPrimitive from
|
|
5
|
-
import { cva } from
|
|
6
|
-
import { cn } from
|
|
7
|
-
const labelVariants = cva(
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
5
|
+
import { cva } from 'class-variance-authority';
|
|
6
|
+
import { cn } from '../../lib/utils.js';
|
|
7
|
+
const labelVariants = cva('text-sm font-bold leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70');
|
|
8
8
|
const Label = React.forwardRef(({ className, ...props }, ref) => (_jsx(LabelPrimitive.Root, { ref: ref, className: cn(labelVariants(), className), ...props })));
|
|
9
9
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
10
10
|
export { Label };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../../src/react/components/label.tsx"],"names":[],"mappings":"AAAA,YAAY,
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../../src/react/components/label.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC,MAAM,aAAa,GAAG,GAAG,CACvB,0FAA0F,CAC3F,CAAC;AAEF,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAG5B,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAClC,KAAC,cAAc,CAAC,IAAI,IAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CACxF,CAAC,CAAC;AACH,KAAK,CAAC,WAAW,GAAG,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,CAAC","sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport * as LabelPrimitive from '@radix-ui/react-label';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '../../lib/utils.js';\n\nconst labelVariants = cva(\n 'text-sm font-bold leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n);\n\nconst Label = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n"]}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
export type MaxWidthOption =
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type MaxWidthOption = 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | '7xl' | 'full';
|
|
3
3
|
export interface ScreenAdaptiveViewProps {
|
|
4
|
-
/** Default content (mobile + base) */
|
|
5
4
|
children: React.ReactNode;
|
|
6
|
-
/** Optional content to use on lg and up */
|
|
7
5
|
lgContent?: React.ReactNode;
|
|
8
|
-
/** Optional content to use on xl and up */
|
|
9
6
|
xlContent?: React.ReactNode;
|
|
10
|
-
/** Max width applied at lg (>=1024px) */
|
|
11
7
|
lgMaxWidth?: MaxWidthOption;
|
|
12
|
-
/** Max width applied at xl (>=1280px) */
|
|
13
8
|
xlMaxWidth?: MaxWidthOption;
|
|
14
|
-
/** App-only escape hatch (try to avoid) */
|
|
15
9
|
className?: string;
|
|
16
|
-
/** App-only escape hatch (try to avoid) */
|
|
17
10
|
innerClassName?: string;
|
|
18
11
|
}
|
|
19
12
|
export declare function ScreenAdaptiveView({ children, lgContent, xlContent, lgMaxWidth, xlMaxWidth, className, innerClassName, }: ScreenAdaptiveViewProps): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen-adaptive-view.d.ts","sourceRoot":"","sources":["../../../../src/react/components/layout/screen-adaptive-view.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"screen-adaptive-view.d.ts","sourceRoot":"","sources":["../../../../src/react/components/layout/screen-adaptive-view.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,MAAM,cAAc,GACxB,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAE9F,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE5B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE5B,UAAU,CAAC,EAAE,cAAc,CAAC;IAE5B,UAAU,CAAC,EAAE,cAAc,CAAC;IAE5B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAiCD,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAkB,EAClB,UAAkB,EAClB,SAAS,EACT,cAAc,GACf,EAAE,uBAAuB,qBAuBzB"}
|
|
@@ -1,48 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { cn } from
|
|
4
|
-
import { useMediaQuery } from
|
|
3
|
+
import { cn } from '../../../lib/utils.js';
|
|
4
|
+
import { useMediaQuery } from '../../hooks/use-media-query.js';
|
|
5
5
|
function widthClass(opt) {
|
|
6
6
|
switch (opt) {
|
|
7
|
-
case
|
|
8
|
-
return
|
|
9
|
-
case
|
|
10
|
-
return
|
|
11
|
-
case
|
|
12
|
-
return
|
|
13
|
-
case
|
|
14
|
-
return
|
|
15
|
-
case
|
|
16
|
-
return
|
|
17
|
-
case
|
|
18
|
-
return
|
|
19
|
-
case
|
|
20
|
-
return
|
|
21
|
-
case
|
|
22
|
-
return
|
|
23
|
-
case
|
|
24
|
-
return
|
|
25
|
-
case
|
|
26
|
-
return
|
|
27
|
-
case
|
|
28
|
-
return
|
|
29
|
-
case
|
|
30
|
-
return
|
|
7
|
+
case 'none':
|
|
8
|
+
return 'screen-max-w-none';
|
|
9
|
+
case 'sm':
|
|
10
|
+
return 'screen-max-w-sm';
|
|
11
|
+
case 'md':
|
|
12
|
+
return 'screen-max-w-md';
|
|
13
|
+
case 'lg':
|
|
14
|
+
return 'screen-max-w-lg';
|
|
15
|
+
case 'xl':
|
|
16
|
+
return 'screen-max-w-xl';
|
|
17
|
+
case '2xl':
|
|
18
|
+
return 'screen-max-w-2xl';
|
|
19
|
+
case '3xl':
|
|
20
|
+
return 'screen-max-w-3xl';
|
|
21
|
+
case '4xl':
|
|
22
|
+
return 'screen-max-w-4xl';
|
|
23
|
+
case '5xl':
|
|
24
|
+
return 'screen-max-w-5xl';
|
|
25
|
+
case '6xl':
|
|
26
|
+
return 'screen-max-w-6xl';
|
|
27
|
+
case '7xl':
|
|
28
|
+
return 'screen-max-w-7xl';
|
|
29
|
+
case 'full':
|
|
30
|
+
return 'screen-max-w-full';
|
|
31
31
|
default:
|
|
32
|
-
return
|
|
32
|
+
return 'screen-max-w-6xl';
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
export function ScreenAdaptiveView({ children, lgContent, xlContent, lgMaxWidth =
|
|
36
|
-
const isLg = useMediaQuery(
|
|
37
|
-
const isXl = useMediaQuery(
|
|
38
|
-
// SSR-safe
|
|
39
|
-
|
|
40
|
-
const contentToShow = (isXl && xlContent !== undefined && xlContent !== null)
|
|
35
|
+
export function ScreenAdaptiveView({ children, lgContent, xlContent, lgMaxWidth = '4xl', xlMaxWidth = '6xl', className, innerClassName, }) {
|
|
36
|
+
const isLg = useMediaQuery('(min-width: 1024px)');
|
|
37
|
+
const isXl = useMediaQuery('(min-width: 1280px)');
|
|
38
|
+
// SSR-safe: base children render until hydration, then lg/xl content swaps in.
|
|
39
|
+
const contentToShow = isXl && xlContent !== undefined && xlContent !== null
|
|
41
40
|
? xlContent
|
|
42
|
-
:
|
|
41
|
+
: isLg && lgContent !== undefined && lgContent !== null
|
|
43
42
|
? lgContent
|
|
44
43
|
: children;
|
|
45
|
-
const sizeClass = isXl
|
|
46
|
-
|
|
44
|
+
const sizeClass = isXl
|
|
45
|
+
? widthClass(xlMaxWidth)
|
|
46
|
+
: isLg
|
|
47
|
+
? widthClass(lgMaxWidth)
|
|
48
|
+
: 'screen-max-w-full';
|
|
49
|
+
return (_jsx("div", { className: cn('screen-adaptive-root', className), children: _jsx("div", { className: cn('screen-adaptive-inner', sizeClass, innerClassName), children: contentToShow }) }));
|
|
47
50
|
}
|
|
48
51
|
//# sourceMappingURL=screen-adaptive-view.js.map
|