@akira-io/ui 1.3.1 → 2.0.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/README.md +2 -2
- package/dist/blocks.d.ts +100 -10
- package/dist/blocks.js +547 -270
- package/dist/blocks.js.map +1 -1
- package/dist/chunk-2V6HUWST.js +18 -5
- package/dist/chunk-2V6HUWST.js.map +1 -1
- package/dist/chunk-3Z2VGVPI.js +16 -6
- package/dist/chunk-3Z2VGVPI.js.map +1 -1
- package/dist/chunk-B3L6PRLX.js +207 -99
- package/dist/chunk-B3L6PRLX.js.map +1 -1
- package/dist/chunk-DE2AJ54R.js +458 -0
- package/dist/chunk-DE2AJ54R.js.map +1 -0
- package/dist/{chunk-QNF4LJVT.js → chunk-E26KKMGS.js} +8 -6
- package/dist/chunk-E26KKMGS.js.map +1 -0
- package/dist/{chunk-N2KIFFI7.js → chunk-EYPM6IMS.js} +30 -34
- package/dist/chunk-EYPM6IMS.js.map +1 -0
- package/dist/chunk-IQMRJXEO.js +5 -4
- package/dist/chunk-IQMRJXEO.js.map +1 -1
- package/dist/chunk-KHOA4TEI.js +53 -24
- package/dist/chunk-KHOA4TEI.js.map +1 -1
- package/dist/chunk-L2H5GIF7.js +5 -4
- package/dist/chunk-L2H5GIF7.js.map +1 -1
- package/dist/chunk-SZUXATOF.js +169 -75
- package/dist/chunk-SZUXATOF.js.map +1 -1
- package/dist/chunk-TM5MN3MI.js +29 -0
- package/dist/chunk-TM5MN3MI.js.map +1 -0
- package/dist/{chunk-I6VVCFZ2.js → chunk-UCJTM3UM.js} +254 -243
- package/dist/chunk-UCJTM3UM.js.map +1 -0
- package/dist/{chunk-IDNOI4OK.js → chunk-UXVI326F.js} +15 -8
- package/dist/chunk-UXVI326F.js.map +1 -0
- package/dist/chunk-VA6A4HZ2.js +394 -0
- package/dist/chunk-VA6A4HZ2.js.map +1 -0
- package/dist/chunk-YBXRJSR3.js +14 -6
- package/dist/chunk-YBXRJSR3.js.map +1 -1
- package/dist/code.d.ts +2 -2
- package/dist/code.js +96 -52
- package/dist/code.js.map +1 -1
- package/dist/{context-OwSoVEri.d.ts → context-Soro3B1I.d.ts} +5 -4
- package/dist/editor.d.ts +1 -1
- package/dist/editor.js +135 -52
- package/dist/editor.js.map +1 -1
- package/dist/{field-DWm5NXeV.d.ts → field-C1TdmC2t.d.ts} +1 -1
- package/dist/index.d.ts +14 -11
- package/dist/index.js +1105 -633
- package/dist/index.js.map +1 -1
- package/dist/inertia.d.ts +11 -3
- package/dist/inertia.js +66 -12
- package/dist/inertia.js.map +1 -1
- package/dist/{input-Dxnsxi-f.d.ts → input-B4uEClxB.d.ts} +1 -1
- package/dist/{json-viewer-BARA2RCW.d.ts → json-viewer-Bssv9mTD.d.ts} +1 -1
- package/dist/locales/pt.d.ts +9 -8
- package/dist/locales/pt.js +40 -3
- package/dist/locales/pt.js.map +1 -1
- package/dist/shells.d.ts +46 -5
- package/dist/shells.js +211 -71
- package/dist/shells.js.map +1 -1
- package/dist/{sidebar-Bp6Q46j-.d.ts → sidebar-BLL2tgTt.d.ts} +2 -2
- package/dist/types-1LUmNJf_.d.ts +41 -0
- package/dist/{types-cmBL8zOc.d.ts → types-CMZRvMV5.d.ts} +1 -1
- package/dist/{types-B-eGPoFD.d.ts → types-CfAUvz--.d.ts} +1 -1
- package/package.json +4 -2
- package/dist/chunk-I6VVCFZ2.js.map +0 -1
- package/dist/chunk-IDNOI4OK.js.map +0 -1
- package/dist/chunk-N2KIFFI7.js.map +0 -1
- package/dist/chunk-NGMG2UWX.js +0 -172
- package/dist/chunk-NGMG2UWX.js.map +0 -1
- package/dist/chunk-QNF4LJVT.js.map +0 -1
- package/dist/types-u1qfmJQi.d.ts +0 -28
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/ui/alert.tsx","../src/components/ui/checkbox.tsx","../src/components/ui/field-context.ts","../src/components/ui/field-error.tsx","../src/components/ui/field.tsx","../src/components/ui/password-input.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport * as React from 'react';\n\nimport { elevatedSurface } from '@/lib/language';\nimport { cn } from '@/lib/utils';\nimport { useUiLabels } from '@/locales/context';\nimport type { SlotNameProps } from '@/types';\n\nconst alertVariants = cva(\n `${elevatedSurface} relative w-full px-5 py-4 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,\n {\n variants: {\n variant: {\n default: 'bg-card text-card-foreground',\n destructive:\n 'border-destructive/30 bg-destructive/10 text-destructive [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/80',\n warning:\n 'ring-warning/20 bg-warning/10 text-warning *:data-[slot=alert-description]:text-warning/80',\n info: 'ring-info/20 bg-info/10 text-info *:data-[slot=alert-description]:text-info/80',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n },\n);\n\nexport interface AlertLabels {\n warningLabel: string;\n infoLabel: string;\n}\n\nexport const alertDefaultLabels: AlertLabels = {\n warningLabel: 'Warning',\n infoLabel: 'Information',\n};\n\ntype AlertVariant = VariantProps<typeof alertVariants>['variant'];\n\nconst SEVERITY_LABELS: Partial<\n Record<NonNullable<AlertVariant>, keyof AlertLabels>\n> = {\n warning: 'warningLabel',\n info: 'infoLabel',\n};\n\nfunction Alert({\n className,\n variant,\n labels,\n slotName = 'alert',\n ...props\n}: React.ComponentProps<'div'> &\n VariantProps<typeof alertVariants> &\n SlotNameProps & { labels?: Partial<AlertLabels> }) {\n const resolved = useUiLabels('alert', alertDefaultLabels, labels);\n const severity = variant ? SEVERITY_LABELS[variant] : undefined;\n\n return (\n <div\n role=\"alert\"\n aria-label={severity ? resolved[severity] : undefined}\n className={cn(alertVariants({ variant }), className)}\n {...props}\n data-slot={slotName}\n />\n );\n}\n\nfunction AlertTitle({\n className,\n slotName = 'alert-title',\n ...props\n}: React.ComponentProps<'div'> & SlotNameProps) {\n return (\n <div\n className={cn(\n 'min-h-4 font-medium tracking-tight col-start-2 line-clamp-1',\n className,\n )}\n {...props}\n data-slot={slotName}\n />\n );\n}\n\nfunction AlertDescription({\n className,\n slotName = 'alert-description',\n ...props\n}: React.ComponentProps<'div'> & SlotNameProps) {\n return (\n <div\n className={cn(\n 'gap-1 text-sm [&_p]:leading-relaxed col-start-2 grid justify-items-start text-muted-foreground',\n className,\n )}\n {...props}\n data-slot={slotName}\n />\n );\n}\n\nexport { Alert, AlertDescription, AlertTitle };\n","import * as CheckboxPrimitive from '@radix-ui/react-checkbox';\nimport { CheckIcon } from 'lucide-react';\nimport * as React from 'react';\n\nimport { focusRing } from '@/lib/language';\nimport { cn } from '@/lib/utils';\nimport type { SlotNameProps } from '@/types';\n\nfunction Checkbox({\n className,\n slotName = 'checkbox',\n ...props\n}: React.ComponentProps<typeof CheckboxPrimitive.Root> & SlotNameProps) {\n return (\n <CheckboxPrimitive.Root\n className={cn(\n `peer size-5 shadow-xs shrink-0 rounded-md border border-border transition-all disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground ${focusRing}`,\n className,\n )}\n {...props}\n data-slot={slotName}\n >\n <CheckboxPrimitive.Indicator\n data-slot=\"checkbox-indicator\"\n className=\"flex items-center justify-center text-current transition-none\"\n >\n <CheckIcon className=\"size-3.5\" />\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n );\n}\n\nexport { Checkbox };\n","import * as React from 'react';\n\nexport type FieldOrientation = 'vertical' | 'horizontal';\n\nexport interface FieldContextValue {\n controlId: string;\n descriptionId: string;\n errorId: string;\n orientation: FieldOrientation;\n invalid: boolean;\n required: boolean;\n hasDescription: boolean;\n setHasDescription: (present: boolean) => void;\n}\n\nexport const FieldContext = React.createContext<FieldContextValue | null>(null);\n\nexport function useOptionalField(): FieldContextValue | null {\n return React.useContext(FieldContext);\n}\n\nexport function useField(): FieldContextValue {\n const field = useOptionalField();\n\n if (!field) {\n throw new Error('Field parts must be rendered inside a Field.');\n }\n\n return field;\n}\n","import * as React from 'react';\n\nimport { useOptionalField } from '@/components/ui/field-context';\nimport { cn } from '@/lib/utils';\nimport type { SlotNameProps } from '@/types';\n\ninterface FieldErrorProps extends React.ComponentProps<'p'> {\n message?: string;\n}\n\nexport function FieldError({\n message,\n className,\n slotName = 'field-error',\n ...props\n}: FieldErrorProps & SlotNameProps) {\n const field = useOptionalField();\n\n if (!message) {\n return null;\n }\n\n return (\n <p\n id={field?.errorId}\n className={cn(\n 'ml-1 text-xs font-medium text-destructive group-data-[orientation=horizontal]/field:col-span-2 group-data-[orientation=horizontal]/field:row-start-3',\n className,\n )}\n {...props}\n data-slot={slotName}\n >\n {message}\n </p>\n );\n}\n","import { Slot } from '@radix-ui/react-slot';\nimport * as React from 'react';\n\nimport {\n FieldContext,\n useField,\n type FieldContextValue,\n type FieldOrientation,\n} from '@/components/ui/field-context';\nimport { FieldError } from '@/components/ui/field-error';\nimport { Label } from '@/components/ui/label';\nimport { cn } from '@/lib/utils';\nimport type { SlotNameProps } from '@/types';\n\nexport interface FieldLabels {\n requiredLabel: string;\n}\n\ninterface FieldProps extends React.ComponentProps<'div'> {\n orientation?: FieldOrientation;\n error?: string;\n invalid?: boolean;\n required?: boolean;\n}\n\nexport function Field({\n className,\n children,\n id,\n orientation = 'vertical',\n error,\n invalid,\n required = false,\n slotName = 'field',\n ...props\n}: FieldProps & SlotNameProps) {\n const generatedId = React.useId();\n const fieldId = id ?? generatedId;\n const [hasDescription, setHasDescription] = React.useState(false);\n const isInvalid = invalid ?? Boolean(error);\n\n const field = React.useMemo<FieldContextValue>(\n () => ({\n controlId: fieldId,\n descriptionId: `${fieldId}-description`,\n errorId: `${fieldId}-error`,\n orientation,\n invalid: isInvalid,\n required,\n hasDescription,\n setHasDescription,\n }),\n [fieldId, orientation, isInvalid, required, hasDescription],\n );\n\n return (\n <FieldContext.Provider value={field}>\n <div\n data-orientation={orientation}\n data-invalid={isInvalid ? 'true' : undefined}\n className={cn(\n 'group/field',\n orientation === 'horizontal'\n ? 'gap-x-4 gap-y-1 grid grid-cols-[1fr_auto] items-center'\n : 'gap-2 flex flex-col',\n className,\n )}\n {...props}\n data-slot={slotName}\n >\n {children}\n <FieldError message={error} />\n </div>\n </FieldContext.Provider>\n );\n}\n\nexport function FieldGroup({\n className,\n slotName = 'field-group',\n ...props\n}: React.ComponentProps<'div'> & SlotNameProps) {\n return (\n <div\n className={cn('gap-6 flex w-full flex-col', className)}\n {...props}\n data-slot={slotName}\n />\n );\n}\n\ninterface FieldLabelProps extends React.ComponentProps<typeof Label> {\n requiredLabel?: FieldLabels['requiredLabel'];\n}\n\nexport function FieldLabel({\n className,\n children,\n requiredLabel = 'Required',\n slotName = 'field-label',\n ...props\n}: FieldLabelProps & SlotNameProps) {\n const { controlId, invalid, required } = useField();\n\n return (\n <Label\n htmlFor={controlId}\n className={cn(\n 'gap-1 flex items-center group-data-[orientation=horizontal]/field:col-start-1 group-data-[orientation=horizontal]/field:row-start-1',\n invalid && 'text-destructive',\n className,\n )}\n {...props}\n slotName={slotName}\n >\n {children}\n {required ? (\n <>\n <span\n data-slot=\"field-required\"\n aria-hidden=\"true\"\n className=\"text-destructive\"\n >\n *\n </span>\n <span className=\"sr-only\">{requiredLabel}</span>\n </>\n ) : null}\n </Label>\n );\n}\n\nexport function FieldDescription({\n className,\n slotName = 'field-description',\n ...props\n}: React.ComponentProps<'p'> & SlotNameProps) {\n const { descriptionId, setHasDescription } = useField();\n\n React.useEffect(() => {\n setHasDescription(true);\n\n return () => setHasDescription(false);\n }, [setHasDescription]);\n\n return (\n <p\n id={descriptionId}\n className={cn(\n 'ml-1 text-xs font-medium text-muted-foreground group-data-[orientation=horizontal]/field:col-start-1 group-data-[orientation=horizontal]/field:row-start-2',\n className,\n )}\n {...props}\n data-slot={slotName}\n />\n );\n}\n\nexport function FieldControl({\n className,\n ...props\n}: React.ComponentProps<typeof Slot>) {\n const {\n controlId,\n descriptionId,\n errorId,\n invalid,\n required,\n hasDescription,\n } = useField();\n\n const requiredProps: React.InputHTMLAttributes<HTMLElement> = required\n ? { required: true }\n : {};\n\n const describedBy = [\n hasDescription ? descriptionId : null,\n invalid ? errorId : null,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <Slot\n data-field-control=\"true\"\n id={controlId}\n aria-describedby={describedBy || undefined}\n aria-invalid={invalid ? true : undefined}\n {...requiredProps}\n className={cn(\n 'group-data-[orientation=horizontal]/field:col-start-2 group-data-[orientation=horizontal]/field:row-span-2 group-data-[orientation=horizontal]/field:row-start-1 group-data-[orientation=horizontal]/field:justify-self-end',\n className,\n )}\n {...props}\n />\n );\n}\n","import { Eye, EyeOff } from 'lucide-react';\nimport * as React from 'react';\n\nimport { Button } from '@/components/ui/button';\nimport { Input } from '@/components/ui/input';\nimport { cn } from '@/lib/utils';\nimport { useUiLabels } from '@/locales/context';\nimport type { SlotNameProps } from '@/types';\n\nexport interface PasswordInputLabels {\n showLabel: string;\n hideLabel: string;\n}\n\nexport const passwordInputDefaultLabels: PasswordInputLabels = {\n showLabel: 'Show password',\n hideLabel: 'Hide password',\n};\n\ninterface PasswordInputProps extends Omit<\n React.ComponentProps<typeof Input>,\n 'type'\n> {\n revealable?: boolean;\n showLabel?: PasswordInputLabels['showLabel'];\n hideLabel?: PasswordInputLabels['hideLabel'];\n}\n\nexport function PasswordInput({\n className,\n revealable = true,\n showLabel,\n hideLabel,\n slotName = 'password-input',\n ...props\n}: PasswordInputProps & SlotNameProps) {\n const labels = useUiLabels('passwordInput', passwordInputDefaultLabels, {\n showLabel,\n hideLabel,\n });\n const [visible, setVisible] = React.useState(false);\n\n return (\n <div className=\"relative w-full\" data-slot={slotName}>\n <Input\n type={visible ? 'text' : 'password'}\n className={cn(revealable && 'pr-12', className)}\n {...props}\n />\n {revealable ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n slotName=\"password-input-toggle\"\n aria-label={visible ? labels.hideLabel : labels.showLabel}\n aria-pressed={visible}\n disabled={props.disabled}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => setVisible((current) => !current)}\n className=\"right-1 absolute top-1/2 -translate-y-1/2\"\n >\n {visible ? (\n <EyeOff aria-hidden=\"true\" />\n ) : (\n <Eye aria-hidden=\"true\" />\n )}\n </Button>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,WAA8B;AA2D/B;AAnDR,IAAM,gBAAgB;AAAA,EAClB,GAAG,eAAe;AAAA,EAClB;AAAA,IACI,UAAU;AAAA,MACN,SAAS;AAAA,QACL,SAAS;AAAA,QACT,aACI;AAAA,QACJ,SACI;AAAA,QACJ,MAAM;AAAA,MACV;AAAA,IACJ;AAAA,IACA,iBAAiB;AAAA,MACb,SAAS;AAAA,IACb;AAAA,EACJ;AACJ;AAOO,IAAM,qBAAkC;AAAA,EAC3C,cAAc;AAAA,EACd,WAAW;AACf;AAIA,IAAM,kBAEF;AAAA,EACA,SAAS;AAAA,EACT,MAAM;AACV;AAEA,SAAS,MAAM;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,GAAG;AACP,GAEuD;AACnD,QAAM,WAAW,YAAY,SAAS,oBAAoB,MAAM;AAChE,QAAM,WAAW,UAAU,gBAAgB,OAAO,IAAI;AAEtD,SACI;AAAA,IAAC;AAAA;AAAA,MACG,MAAK;AAAA,MACL,cAAY,WAAW,SAAS,QAAQ,IAAI;AAAA,MAC5C,WAAW,GAAG,cAAc,EAAE,QAAQ,CAAC,GAAG,SAAS;AAAA,MAClD,GAAG;AAAA,MACJ,aAAW;AAAA;AAAA,EACf;AAER;AAEA,SAAS,WAAW;AAAA,EAChB;AAAA,EACA,WAAW;AAAA,EACX,GAAG;AACP,GAAgD;AAC5C,SACI;AAAA,IAAC;AAAA;AAAA,MACG,WAAW;AAAA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AAY,CAAC,OAAO;AAAA,QAC/C,WAAU;AAAA,QAET,oBACG,gBAAAA,KAAC,UAAO,eAAY,QAAO,IAE3B,gBAAAA,KAAC,OAAI,eAAY,QAAO;AAAA;AAAA,IAEhC,IACA;AAAA,KACR;AAER;","names":["jsx","jsx","React","jsx","React","jsx","jsxs"]}
|
package/dist/chunk-YBXRJSR3.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
cn,
|
|
3
|
+
controlFill,
|
|
4
|
+
focusRing,
|
|
5
|
+
glassControl
|
|
6
|
+
} from "./chunk-KHOA4TEI.js";
|
|
5
7
|
|
|
8
|
+
// src/components/ui/toggle.tsx
|
|
9
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
10
|
+
import { cva } from "class-variance-authority";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
12
|
var toggleVariants = cva(
|
|
7
13
|
`inline-flex items-center justify-center gap-2 rounded-xl text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:font-semibold data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 transition-[color,box-shadow] aria-invalid:ring-destructive/20 aria-invalid:border-destructive ${focusRing}`,
|
|
8
14
|
{
|
|
@@ -40,6 +46,8 @@ function Toggle({
|
|
|
40
46
|
);
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
export {
|
|
44
|
-
|
|
49
|
+
export {
|
|
50
|
+
toggleVariants,
|
|
51
|
+
Toggle
|
|
52
|
+
};
|
|
45
53
|
//# sourceMappingURL=chunk-YBXRJSR3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/ui/toggle.tsx"],"
|
|
1
|
+
{"version":3,"sources":["../src/components/ui/toggle.tsx"],"sourcesContent":["import * as TogglePrimitive from '@radix-ui/react-toggle';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport * as React from 'react';\n\nimport { controlFill, focusRing, glassControl } from '@/lib/language';\nimport { cn } from '@/lib/utils';\nimport type { SlotNameProps } from '@/types';\n\nconst toggleVariants = cva(\n `inline-flex items-center justify-center gap-2 rounded-xl text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:font-semibold data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 transition-[color,box-shadow] aria-invalid:ring-destructive/20 aria-invalid:border-destructive ${focusRing}`,\n {\n variants: {\n variant: {\n default: 'bg-transparent',\n outline: `${glassControl} ${controlFill} hover:bg-accent hover:text-accent-foreground`,\n },\n size: {\n default: 'h-11 px-4 min-w-11',\n sm: 'h-9 px-3 min-w-9',\n lg: 'h-12 px-6 min-w-12',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n },\n);\n\nfunction Toggle({\n className,\n variant,\n size,\n slotName = 'toggle',\n ...props\n}: React.ComponentProps<typeof TogglePrimitive.Root> &\n VariantProps<typeof toggleVariants> &\n SlotNameProps) {\n return (\n <TogglePrimitive.Root\n className={cn(toggleVariants({ variant, size, className }))}\n {...props}\n data-slot={slotName}\n />\n );\n}\n\nexport { Toggle, toggleVariants };\n"],"mappings":";;;;;;;;AAAA,YAAY,qBAAqB;AACjC,SAAS,WAA8B;AAsC/B;AA/BR,IAAM,iBAAiB;AAAA,EACnB,4bAA4b,SAAS;AAAA,EACrc;AAAA,IACI,UAAU;AAAA,MACN,SAAS;AAAA,QACL,SAAS;AAAA,QACT,SAAS,GAAG,YAAY,IAAI,WAAW;AAAA,MAC3C;AAAA,MACA,MAAM;AAAA,QACF,SAAS;AAAA,QACT,IAAI;AAAA,QACJ,IAAI;AAAA,MACR;AAAA,IACJ;AAAA,IACA,iBAAiB;AAAA,MACb,SAAS;AAAA,MACT,MAAM;AAAA,IACV;AAAA,EACJ;AACJ;AAEA,SAAS,OAAO;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,GAAG;AACP,GAEmB;AACf,SACI;AAAA,IAAiB;AAAA,IAAhB;AAAA,MACG,WAAW,GAAG,eAAe,EAAE,SAAS,MAAM,UAAU,CAAC,CAAC;AAAA,MACzD,GAAG;AAAA,MACJ,aAAW;AAAA;AAAA,EACf;AAER;","names":[]}
|
package/dist/code.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { S as SlotNameProps } from './types-
|
|
3
|
-
export { C as CodeBlock, a as CodeBlockLabels, b as CodeBlockProps, J as JsonViewer, c as JsonViewerLabels, d as JsonViewerProps, e as codeBlockLabels, j as jsonViewerLabels } from './json-viewer-
|
|
2
|
+
import { S as SlotNameProps } from './types-CMZRvMV5.js';
|
|
3
|
+
export { C as CodeBlock, a as CodeBlockLabels, b as CodeBlockProps, J as JsonViewer, c as JsonViewerLabels, d as JsonViewerProps, e as codeBlockLabels, j as jsonViewerLabels } from './json-viewer-Bssv9mTD.js';
|
|
4
4
|
import '@tanstack/react-table';
|
|
5
5
|
import 'lucide-react';
|
|
6
6
|
|
package/dist/code.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
import { useUiLabels } from './chunk-QNF4LJVT.js';
|
|
3
|
-
import { cn, compactRadius, controlFill, elevatedSurface, nestedSurfaceReset, Button, focusRing } from './chunk-KHOA4TEI.js';
|
|
4
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import * as React2 from 'react';
|
|
6
|
-
import { FileCode, ChevronRight } from 'lucide-react';
|
|
1
|
+
'use client';
|
|
7
2
|
|
|
3
|
+
"use client";
|
|
4
|
+
import {
|
|
5
|
+
CopyButton
|
|
6
|
+
} from "./chunk-UXVI326F.js";
|
|
7
|
+
import {
|
|
8
|
+
useUiLabels
|
|
9
|
+
} from "./chunk-E26KKMGS.js";
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
cn,
|
|
13
|
+
compactRadius,
|
|
14
|
+
controlFill,
|
|
15
|
+
elevatedSurface,
|
|
16
|
+
focusRing,
|
|
17
|
+
nestedSurfaceReset
|
|
18
|
+
} from "./chunk-KHOA4TEI.js";
|
|
19
|
+
|
|
20
|
+
// src/components/ui/code.tsx
|
|
21
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
22
|
function Code({
|
|
9
23
|
className,
|
|
10
24
|
slotName = "code",
|
|
@@ -24,6 +38,13 @@ function Code({
|
|
|
24
38
|
}
|
|
25
39
|
);
|
|
26
40
|
}
|
|
41
|
+
|
|
42
|
+
// src/components/ui/code-block.tsx
|
|
43
|
+
import * as React2 from "react";
|
|
44
|
+
|
|
45
|
+
// src/components/ui/code-block-header.tsx
|
|
46
|
+
import { FileCode } from "lucide-react";
|
|
47
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
27
48
|
function CodeBlockHeader({
|
|
28
49
|
filename,
|
|
29
50
|
language,
|
|
@@ -38,8 +59,8 @@ function CodeBlockHeader({
|
|
|
38
59
|
className: "gap-2 px-4 py-2 flex items-center border-b border-border",
|
|
39
60
|
"data-slot": slotName,
|
|
40
61
|
children: [
|
|
41
|
-
/* @__PURE__ */
|
|
42
|
-
/* @__PURE__ */
|
|
62
|
+
/* @__PURE__ */ jsx2(FileCode, { className: "size-4 shrink-0 text-muted-foreground" }),
|
|
63
|
+
/* @__PURE__ */ jsx2(
|
|
43
64
|
"span",
|
|
44
65
|
{
|
|
45
66
|
"data-slot": "code-block-filename",
|
|
@@ -47,7 +68,7 @@ function CodeBlockHeader({
|
|
|
47
68
|
children: filename
|
|
48
69
|
}
|
|
49
70
|
),
|
|
50
|
-
language !== void 0 && /* @__PURE__ */
|
|
71
|
+
language !== void 0 && /* @__PURE__ */ jsx2(
|
|
51
72
|
"span",
|
|
52
73
|
{
|
|
53
74
|
"data-slot": "code-block-language",
|
|
@@ -55,7 +76,7 @@ function CodeBlockHeader({
|
|
|
55
76
|
children: language
|
|
56
77
|
}
|
|
57
78
|
),
|
|
58
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ jsx2(
|
|
59
80
|
CopyButton,
|
|
60
81
|
{
|
|
61
82
|
value: code,
|
|
@@ -69,12 +90,15 @@ function CodeBlockHeader({
|
|
|
69
90
|
);
|
|
70
91
|
}
|
|
71
92
|
|
|
93
|
+
// src/hooks/use-highlighted-code.ts
|
|
94
|
+
import * as React from "react";
|
|
95
|
+
|
|
72
96
|
// src/lib/shiki.ts
|
|
73
97
|
var LIGHT_THEME = "github-light";
|
|
74
98
|
var DARK_THEME = "github-dark";
|
|
75
99
|
var pending = null;
|
|
76
100
|
function loadCodeToHtml() {
|
|
77
|
-
pending ??= import(
|
|
101
|
+
pending ??= import("shiki").then((module) => module.codeToHtml).catch(() => null);
|
|
78
102
|
return pending;
|
|
79
103
|
}
|
|
80
104
|
async function highlightCode(code, language) {
|
|
@@ -95,10 +119,10 @@ async function highlightCode(code, language) {
|
|
|
95
119
|
|
|
96
120
|
// src/hooks/use-highlighted-code.ts
|
|
97
121
|
function useHighlightedCode(code, language, html) {
|
|
98
|
-
const [highlighted, setHighlighted] =
|
|
122
|
+
const [highlighted, setHighlighted] = React.useState(
|
|
99
123
|
html ?? null
|
|
100
124
|
);
|
|
101
|
-
|
|
125
|
+
React.useEffect(() => {
|
|
102
126
|
if (html !== void 0) {
|
|
103
127
|
setHighlighted(html);
|
|
104
128
|
return;
|
|
@@ -185,6 +209,9 @@ function splitHighlightedLines(html) {
|
|
|
185
209
|
}
|
|
186
210
|
return lines.length > 0 ? lines : null;
|
|
187
211
|
}
|
|
212
|
+
|
|
213
|
+
// src/components/ui/code-block.tsx
|
|
214
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
188
215
|
var codeBlockLabels = {
|
|
189
216
|
copyLabel: "Copy",
|
|
190
217
|
copiedLabel: "Copied",
|
|
@@ -233,7 +260,7 @@ function CodeBlock({
|
|
|
233
260
|
}
|
|
234
261
|
setClipped(body.scrollHeight > body.clientHeight + 1);
|
|
235
262
|
}, [maxHeight, expanded, lines, markup]);
|
|
236
|
-
return /* @__PURE__ */
|
|
263
|
+
return /* @__PURE__ */ jsxs2(
|
|
237
264
|
"div",
|
|
238
265
|
{
|
|
239
266
|
className: cn(
|
|
@@ -245,7 +272,7 @@ function CodeBlock({
|
|
|
245
272
|
...props,
|
|
246
273
|
"data-slot": slotName,
|
|
247
274
|
children: [
|
|
248
|
-
filename === void 0 ? /* @__PURE__ */
|
|
275
|
+
filename === void 0 ? /* @__PURE__ */ jsx3(
|
|
249
276
|
CopyButton,
|
|
250
277
|
{
|
|
251
278
|
value: code,
|
|
@@ -253,7 +280,7 @@ function CodeBlock({
|
|
|
253
280
|
copiedLabel: labels.copiedLabel,
|
|
254
281
|
className: "top-2 right-2 absolute z-10 text-muted-foreground"
|
|
255
282
|
}
|
|
256
|
-
) : /* @__PURE__ */
|
|
283
|
+
) : /* @__PURE__ */ jsx3(
|
|
257
284
|
CodeBlockHeader,
|
|
258
285
|
{
|
|
259
286
|
filename,
|
|
@@ -263,14 +290,14 @@ function CodeBlock({
|
|
|
263
290
|
copiedLabel: labels.copiedLabel
|
|
264
291
|
}
|
|
265
292
|
),
|
|
266
|
-
/* @__PURE__ */
|
|
293
|
+
/* @__PURE__ */ jsx3(
|
|
267
294
|
"div",
|
|
268
295
|
{
|
|
269
296
|
ref: bodyRef,
|
|
270
297
|
"data-slot": "code-block-body",
|
|
271
298
|
style: { maxHeight: expanded ? void 0 : maxHeight },
|
|
272
299
|
className: "py-4 font-mono text-sm leading-6 overflow-auto rounded-[inherit]",
|
|
273
|
-
children: /* @__PURE__ */
|
|
300
|
+
children: /* @__PURE__ */ jsx3("pre", { className: "w-max min-w-full", children: /* @__PURE__ */ jsx3("code", { "data-slot": "code-block-code", children: lines.map((line, index) => /* @__PURE__ */ jsx3(
|
|
274
301
|
CodeBlockLine,
|
|
275
302
|
{
|
|
276
303
|
number: index + 1,
|
|
@@ -283,7 +310,7 @@ function CodeBlock({
|
|
|
283
310
|
)) }) })
|
|
284
311
|
}
|
|
285
312
|
),
|
|
286
|
-
clipped && /* @__PURE__ */
|
|
313
|
+
clipped && /* @__PURE__ */ jsx3(
|
|
287
314
|
CodeBlockExpander,
|
|
288
315
|
{
|
|
289
316
|
expanded,
|
|
@@ -304,7 +331,7 @@ function CodeBlockLine({
|
|
|
304
331
|
emphasised,
|
|
305
332
|
slotName = "code-block-line"
|
|
306
333
|
}) {
|
|
307
|
-
return /* @__PURE__ */
|
|
334
|
+
return /* @__PURE__ */ jsxs2(
|
|
308
335
|
"span",
|
|
309
336
|
{
|
|
310
337
|
"data-highlighted": emphasised ? "" : void 0,
|
|
@@ -314,7 +341,7 @@ function CodeBlockLine({
|
|
|
314
341
|
),
|
|
315
342
|
"data-slot": slotName,
|
|
316
343
|
children: [
|
|
317
|
-
lineNumbers && /* @__PURE__ */
|
|
344
|
+
lineNumbers && /* @__PURE__ */ jsx3(
|
|
318
345
|
"span",
|
|
319
346
|
{
|
|
320
347
|
"data-slot": "code-block-gutter",
|
|
@@ -323,7 +350,7 @@ function CodeBlockLine({
|
|
|
323
350
|
children: number
|
|
324
351
|
}
|
|
325
352
|
),
|
|
326
|
-
markup === void 0 ? /* @__PURE__ */
|
|
353
|
+
markup === void 0 ? /* @__PURE__ */ jsx3("span", { "data-slot": "code-block-source", children: line }) : /* @__PURE__ */ jsx3(
|
|
327
354
|
"span",
|
|
328
355
|
{
|
|
329
356
|
"data-slot": "code-block-source",
|
|
@@ -341,20 +368,20 @@ function CodeBlockExpander({
|
|
|
341
368
|
onToggle,
|
|
342
369
|
slotName = "code-block-expander"
|
|
343
370
|
}) {
|
|
344
|
-
return /* @__PURE__ */
|
|
371
|
+
return /* @__PURE__ */ jsxs2(
|
|
345
372
|
"div",
|
|
346
373
|
{
|
|
347
374
|
className: "inset-x-0 bottom-0 pt-10 pb-2 absolute flex justify-center",
|
|
348
375
|
"data-slot": slotName,
|
|
349
376
|
children: [
|
|
350
|
-
!expanded && /* @__PURE__ */
|
|
377
|
+
!expanded && /* @__PURE__ */ jsx3(
|
|
351
378
|
"span",
|
|
352
379
|
{
|
|
353
380
|
"aria-hidden": "true",
|
|
354
381
|
className: "inset-0 pointer-events-none absolute bg-gradient-to-t from-card to-transparent"
|
|
355
382
|
}
|
|
356
383
|
),
|
|
357
|
-
/* @__PURE__ */
|
|
384
|
+
/* @__PURE__ */ jsx3(
|
|
358
385
|
Button,
|
|
359
386
|
{
|
|
360
387
|
type: "button",
|
|
@@ -369,6 +396,13 @@ function CodeBlockExpander({
|
|
|
369
396
|
);
|
|
370
397
|
}
|
|
371
398
|
|
|
399
|
+
// src/components/ui/json-viewer.tsx
|
|
400
|
+
import * as React4 from "react";
|
|
401
|
+
|
|
402
|
+
// src/components/ui/json-node.tsx
|
|
403
|
+
import { ChevronRight } from "lucide-react";
|
|
404
|
+
import * as React3 from "react";
|
|
405
|
+
|
|
372
406
|
// src/lib/json-value.ts
|
|
373
407
|
var CIRCULAR_MARKER = "[Circular]";
|
|
374
408
|
function jsonKind(value) {
|
|
@@ -427,6 +461,9 @@ function serialisable(value, ancestors) {
|
|
|
427
461
|
function stringifyJson(value) {
|
|
428
462
|
return JSON.stringify(serialisable(value, []), null, 2) ?? "null";
|
|
429
463
|
}
|
|
464
|
+
|
|
465
|
+
// src/components/ui/json-node.tsx
|
|
466
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
430
467
|
var LEAF_CLASS = {
|
|
431
468
|
string: "text-success",
|
|
432
469
|
number: "text-primary",
|
|
@@ -453,7 +490,7 @@ function JsonKey({
|
|
|
453
490
|
name,
|
|
454
491
|
slotName = "json-viewer-key"
|
|
455
492
|
}) {
|
|
456
|
-
return /* @__PURE__ */
|
|
493
|
+
return /* @__PURE__ */ jsxs3("span", { className: "font-medium text-foreground", "data-slot": slotName, children: [
|
|
457
494
|
name,
|
|
458
495
|
":"
|
|
459
496
|
] });
|
|
@@ -470,26 +507,26 @@ function JsonNode({
|
|
|
470
507
|
const kind = jsonKind(value);
|
|
471
508
|
const branch = isBranch(kind);
|
|
472
509
|
const circular = branch && ancestors.includes(value);
|
|
473
|
-
const [open, setOpen] =
|
|
474
|
-
const entries =
|
|
510
|
+
const [open, setOpen] = React3.useState(depth < initialDepth);
|
|
511
|
+
const entries = React3.useMemo(
|
|
475
512
|
() => branch && !circular ? entriesOf(value) : [],
|
|
476
513
|
[branch, circular, value]
|
|
477
514
|
);
|
|
478
|
-
const trail =
|
|
515
|
+
const trail = React3.useMemo(
|
|
479
516
|
() => branch ? [...ancestors, value] : ancestors,
|
|
480
517
|
[branch, ancestors, value]
|
|
481
518
|
);
|
|
482
519
|
if (!branch || circular) {
|
|
483
|
-
return /* @__PURE__ */
|
|
484
|
-
name !== void 0 && /* @__PURE__ */
|
|
485
|
-
circular ? /* @__PURE__ */
|
|
520
|
+
return /* @__PURE__ */ jsxs3("div", { className: "gap-2 py-0.5 pl-5 flex", "data-slot": slotName, children: [
|
|
521
|
+
name !== void 0 && /* @__PURE__ */ jsx4(JsonKey, { name }),
|
|
522
|
+
circular ? /* @__PURE__ */ jsx4(
|
|
486
523
|
"span",
|
|
487
524
|
{
|
|
488
525
|
"data-slot": "json-viewer-circular",
|
|
489
526
|
className: "text-muted-foreground italic",
|
|
490
527
|
children: labels.circularLabel
|
|
491
528
|
}
|
|
492
|
-
) : /* @__PURE__ */
|
|
529
|
+
) : /* @__PURE__ */ jsx4(
|
|
493
530
|
"span",
|
|
494
531
|
{
|
|
495
532
|
"data-slot": "json-viewer-value",
|
|
@@ -500,8 +537,8 @@ function JsonNode({
|
|
|
500
537
|
] });
|
|
501
538
|
}
|
|
502
539
|
const [opening, closing] = BRACKETS[kind === "array" ? "array" : "object"];
|
|
503
|
-
return /* @__PURE__ */
|
|
504
|
-
/* @__PURE__ */
|
|
540
|
+
return /* @__PURE__ */ jsxs3("div", { "data-slot": slotName, children: [
|
|
541
|
+
/* @__PURE__ */ jsxs3(
|
|
505
542
|
"button",
|
|
506
543
|
{
|
|
507
544
|
type: "button",
|
|
@@ -514,7 +551,7 @@ function JsonNode({
|
|
|
514
551
|
focusRing
|
|
515
552
|
),
|
|
516
553
|
children: [
|
|
517
|
-
/* @__PURE__ */
|
|
554
|
+
/* @__PURE__ */ jsx4(
|
|
518
555
|
ChevronRight,
|
|
519
556
|
{
|
|
520
557
|
"aria-hidden": "true",
|
|
@@ -524,10 +561,10 @@ function JsonNode({
|
|
|
524
561
|
)
|
|
525
562
|
}
|
|
526
563
|
),
|
|
527
|
-
name !== void 0 && /* @__PURE__ */
|
|
528
|
-
/* @__PURE__ */
|
|
529
|
-
!open && /* @__PURE__ */
|
|
530
|
-
/* @__PURE__ */
|
|
564
|
+
name !== void 0 && /* @__PURE__ */ jsx4(JsonKey, { name }),
|
|
565
|
+
/* @__PURE__ */ jsx4("span", { className: "text-muted-foreground", children: opening }),
|
|
566
|
+
!open && /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
567
|
+
/* @__PURE__ */ jsx4(
|
|
531
568
|
"span",
|
|
532
569
|
{
|
|
533
570
|
"data-slot": "json-viewer-summary",
|
|
@@ -535,13 +572,13 @@ function JsonNode({
|
|
|
535
572
|
children: labels.entriesLabel(entries.length)
|
|
536
573
|
}
|
|
537
574
|
),
|
|
538
|
-
/* @__PURE__ */
|
|
575
|
+
/* @__PURE__ */ jsx4("span", { className: "text-muted-foreground", children: closing })
|
|
539
576
|
] })
|
|
540
577
|
]
|
|
541
578
|
}
|
|
542
579
|
),
|
|
543
|
-
open && /* @__PURE__ */
|
|
544
|
-
entries.map(([key, item]) => /* @__PURE__ */
|
|
580
|
+
open && /* @__PURE__ */ jsxs3("div", { className: "ml-1.5 pl-3 border-l border-border", children: [
|
|
581
|
+
entries.map(([key, item]) => /* @__PURE__ */ jsx4(
|
|
545
582
|
JsonNode,
|
|
546
583
|
{
|
|
547
584
|
name: key,
|
|
@@ -553,10 +590,13 @@ function JsonNode({
|
|
|
553
590
|
},
|
|
554
591
|
key
|
|
555
592
|
)),
|
|
556
|
-
/* @__PURE__ */
|
|
593
|
+
/* @__PURE__ */ jsx4("div", { className: "pl-5 text-muted-foreground", children: closing })
|
|
557
594
|
] })
|
|
558
595
|
] });
|
|
559
596
|
}
|
|
597
|
+
|
|
598
|
+
// src/components/ui/json-viewer.tsx
|
|
599
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
560
600
|
var jsonViewerLabels = {
|
|
561
601
|
copyLabel: "Copy",
|
|
562
602
|
copiedLabel: "Copied",
|
|
@@ -587,7 +627,7 @@ function JsonViewer({
|
|
|
587
627
|
circularLabel,
|
|
588
628
|
entriesLabel
|
|
589
629
|
});
|
|
590
|
-
const labels =
|
|
630
|
+
const labels = React4.useMemo(
|
|
591
631
|
() => ({
|
|
592
632
|
expandLabel: text.expandLabel,
|
|
593
633
|
collapseLabel: text.collapseLabel,
|
|
@@ -601,7 +641,7 @@ function JsonViewer({
|
|
|
601
641
|
text.entriesLabel
|
|
602
642
|
]
|
|
603
643
|
);
|
|
604
|
-
return /* @__PURE__ */
|
|
644
|
+
return /* @__PURE__ */ jsxs4(
|
|
605
645
|
"div",
|
|
606
646
|
{
|
|
607
647
|
className: cn(
|
|
@@ -613,7 +653,7 @@ function JsonViewer({
|
|
|
613
653
|
...props,
|
|
614
654
|
"data-slot": slotName,
|
|
615
655
|
children: [
|
|
616
|
-
/* @__PURE__ */
|
|
656
|
+
/* @__PURE__ */ jsx5(
|
|
617
657
|
CopyButton,
|
|
618
658
|
{
|
|
619
659
|
value: stringifyJson(value),
|
|
@@ -622,13 +662,13 @@ function JsonViewer({
|
|
|
622
662
|
className: "top-2 right-2 absolute z-10 text-muted-foreground"
|
|
623
663
|
}
|
|
624
664
|
),
|
|
625
|
-
/* @__PURE__ */
|
|
665
|
+
/* @__PURE__ */ jsx5(
|
|
626
666
|
"div",
|
|
627
667
|
{
|
|
628
668
|
"data-slot": "json-viewer-body",
|
|
629
669
|
style: { maxHeight },
|
|
630
670
|
className: "p-4 pr-12 font-mono text-sm leading-6 overflow-auto rounded-[inherit]",
|
|
631
|
-
children: /* @__PURE__ */
|
|
671
|
+
children: /* @__PURE__ */ jsx5(
|
|
632
672
|
JsonNode,
|
|
633
673
|
{
|
|
634
674
|
value,
|
|
@@ -644,7 +684,11 @@ function JsonViewer({
|
|
|
644
684
|
}
|
|
645
685
|
);
|
|
646
686
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
687
|
+
export {
|
|
688
|
+
Code,
|
|
689
|
+
CodeBlock,
|
|
690
|
+
JsonViewer,
|
|
691
|
+
codeBlockLabels,
|
|
692
|
+
jsonViewerLabels
|
|
693
|
+
};
|
|
650
694
|
//# sourceMappingURL=code.js.map
|