@keboola/design 12.0.0 → 13.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/AGENTS.md +12 -7
- package/CHANGELOG.md +91 -0
- package/COMPONENT-API.md +15 -5
- package/dist/{AIKit-BD4r7ff-.js → AIKit-DcOlHIBr.js} +22 -10
- package/dist/AIKit-DcOlHIBr.js.map +1 -0
- package/dist/{AlertModal-Th2khjPi.js → AlertModal-mbSnuuka.js} +5 -5
- package/dist/AlertModal-mbSnuuka.js.map +1 -0
- package/dist/{BrandEditor-BU23Vl8V.js → BrandEditor-Bkd6dhb8.js} +6 -6
- package/dist/{BrandEditor-BU23Vl8V.js.map → BrandEditor-Bkd6dhb8.js.map} +1 -1
- package/dist/{Breadcrumb-p9HtMLCc.js → Breadcrumb-BUoAZyhO.js} +2 -2
- package/dist/{Breadcrumb-p9HtMLCc.js.map → Breadcrumb-BUoAZyhO.js.map} +1 -1
- package/dist/{Button-Ca4Q3VJU.js → Button-B21oVcPU.js} +3 -4
- package/dist/Button-B21oVcPU.js.map +1 -0
- package/dist/{Card-Cr9MBNHu.js → Card-BQmBWHXl.js} +32 -4
- package/dist/Card-BQmBWHXl.js.map +1 -0
- package/dist/{ClipboardButton-DHa1trtI.js → ClipboardButton-srUgWgwH.js} +2 -2
- package/dist/{ClipboardButton-DHa1trtI.js.map → ClipboardButton-srUgWgwH.js.map} +1 -1
- package/dist/{CodeEditor-BSo-oLFG.js → CodeEditor-jZMw1ioj.js} +2 -2
- package/dist/{CodeEditor-BSo-oLFG.js.map → CodeEditor-jZMw1ioj.js.map} +1 -1
- package/dist/{ColorInput-DSMqrs2-.js → ColorInput-B3gBZ8Ya.js} +2 -2
- package/dist/{ColorInput-DSMqrs2-.js.map → ColorInput-B3gBZ8Ya.js.map} +1 -1
- package/dist/{ColorModeSwitch-D7EuWyJz.js → ColorModeSwitch-Bw9wMyoL.js} +2 -2
- package/dist/{ColorModeSwitch-D7EuWyJz.js.map → ColorModeSwitch-Bw9wMyoL.js.map} +1 -1
- package/dist/{Combobox-CxRAYOBt.js → Combobox-C_MTpQ1l.js} +21 -9
- package/dist/Combobox-C_MTpQ1l.js.map +1 -0
- package/dist/{Command-BU_cVurn.js → Command-BQPiZCNz.js} +2 -2
- package/dist/{Command-BU_cVurn.js.map → Command-BQPiZCNz.js.map} +1 -1
- package/dist/{CopyField-6_c-NdLO.js → CopyField-Ba7h8MqZ.js} +3 -3
- package/dist/CopyField-Ba7h8MqZ.js.map +1 -0
- package/dist/{DateInput-DyEErfJf.js → DateInput-D0nWUasV.js} +2 -2
- package/dist/{DateInput-DyEErfJf.js.map → DateInput-D0nWUasV.js.map} +1 -1
- package/dist/{DateRangeInput-Dg7-VUd9.js → DateRangeInput-i6wE45-V.js} +2 -2
- package/dist/{DateRangeInput-Dg7-VUd9.js.map → DateRangeInput-i6wE45-V.js.map} +1 -1
- package/dist/{DateRangePicker-BoPnh4aH.js → DateRangePicker-BAnuz6vO.js} +2 -2
- package/dist/{DateRangePicker-BoPnh4aH.js.map → DateRangePicker-BAnuz6vO.js.map} +1 -1
- package/dist/{FieldItem-2wMXQ0Qw.js → FieldItem-BHViBJS3.js} +2 -2
- package/dist/{FieldItem-2wMXQ0Qw.js.map → FieldItem-BHViBJS3.js.map} +1 -1
- package/dist/{FileUpload-C83tXuE2.js → FileUpload-Ch2hrIWq.js} +2 -2
- package/dist/{FileUpload-C83tXuE2.js.map → FileUpload-Ch2hrIWq.js.map} +1 -1
- package/dist/{Form-95rVLfX8.js → Form-VkzfVPyT.js} +5 -5
- package/dist/{Form-95rVLfX8.js.map → Form-VkzfVPyT.js.map} +1 -1
- package/dist/{FormGroup-CmNiAtU6.js → FormGroup-CmCppxOn.js} +3 -3
- package/dist/{FormGroup-CmNiAtU6.js.map → FormGroup-CmCppxOn.js.map} +1 -1
- package/dist/{FullScreenModal-CD7mYeTz.js → FullScreenModal-Cwnm8WdM.js} +2 -2
- package/dist/{FullScreenModal-CD7mYeTz.js.map → FullScreenModal-Cwnm8WdM.js.map} +1 -1
- package/dist/{InputGroup-B4QOPxHl.js → InputGroup-CrlMRz4X.js} +2 -2
- package/dist/{InputGroup-B4QOPxHl.js.map → InputGroup-CrlMRz4X.js.map} +1 -1
- package/dist/{MermaidDiagram-BQvz6bhv.js → MermaidDiagram-B30x2yV7.js} +2 -2
- package/dist/{MermaidDiagram-BQvz6bhv.js.map → MermaidDiagram-B30x2yV7.js.map} +1 -1
- package/dist/{Modal-Driyqs_N.js → Modal-BkSuS9Yz.js} +2 -2
- package/dist/{Modal-Driyqs_N.js.map → Modal-BkSuS9Yz.js.map} +1 -1
- package/dist/{MultiActionButtonGroup-BPnmzBtw.js → MultiActionButtonGroup-AWLj1Tg7.js} +2 -2
- package/dist/{MultiActionButtonGroup-BPnmzBtw.js.map → MultiActionButtonGroup-AWLj1Tg7.js.map} +1 -1
- package/dist/{PageToolbar-DOAtAnfL.js → PageToolbar-CIW0VmKe.js} +2 -2
- package/dist/{PageToolbar-DOAtAnfL.js.map → PageToolbar-CIW0VmKe.js.map} +1 -1
- package/dist/{Pagination-LaSg-5cl.js → Pagination-DH3f6LN0.js} +2 -2
- package/dist/{Pagination-LaSg-5cl.js.map → Pagination-DH3f6LN0.js.map} +1 -1
- package/dist/{Popconfirm-SLz0zodk.js → Popconfirm-Dhzn7sy6.js} +2 -2
- package/dist/{Popconfirm-SLz0zodk.js.map → Popconfirm-Dhzn7sy6.js.map} +1 -1
- package/dist/{SearchInput-CEfQDNl3.js → SearchInput-D3qMkHaW.js} +2 -2
- package/dist/{SearchInput-CEfQDNl3.js.map → SearchInput-D3qMkHaW.js.map} +1 -1
- package/dist/{SectionNav-B_qf0AXi.js → SectionNav-TU5i3JeM.js} +2 -2
- package/dist/{SectionNav-B_qf0AXi.js.map → SectionNav-TU5i3JeM.js.map} +1 -1
- package/dist/{Select-ByRvkZ3D.js → Select-B4uK0QVm.js} +4 -3
- package/dist/Select-B4uK0QVm.js.map +1 -0
- package/dist/{Sheet-C-yXk5Da.js → Sheet-D0fAE14T.js} +2 -2
- package/dist/{Sheet-C-yXk5Da.js.map → Sheet-D0fAE14T.js.map} +1 -1
- package/dist/{Sidebar-Ds0E6PbR.js → Sidebar-ZLMNIbg5.js} +3 -3
- package/dist/{Sidebar-Ds0E6PbR.js.map → Sidebar-ZLMNIbg5.js.map} +1 -1
- package/dist/{Slider-DWdu9NuM.js → Slider-B0ou9r0B.js} +2 -2
- package/dist/{Slider-DWdu9NuM.js.map → Slider-B0ou9r0B.js.map} +1 -1
- package/dist/{Tabs-Dt9oLYHC.js → Tabs-CTDmye1N.js} +2 -2
- package/dist/{Tabs-Dt9oLYHC.js.map → Tabs-CTDmye1N.js.map} +1 -1
- package/dist/{TextInput-CDG2XpBl.js → TextInput-BWYXbfs4.js} +2 -2
- package/dist/{TextInput-CDG2XpBl.js.map → TextInput-BWYXbfs4.js.map} +1 -1
- package/dist/{ThemeProvider-DXsxFg1U.js → ThemeProvider-VF38VfUa.js} +3 -3
- package/dist/{ThemeProvider-DXsxFg1U.js.map → ThemeProvider-VF38VfUa.js.map} +1 -1
- package/dist/{ZoomableSvg-BzXVfgnI.js → ZoomableSvg-C65nta_r.js} +3 -3
- package/dist/{ZoomableSvg-BzXVfgnI.js.map → ZoomableSvg-C65nta_r.js.map} +1 -1
- package/dist/editors.js +3 -3
- package/dist/flint.js +1 -1
- package/dist/index.d.ts +375 -375
- package/dist/index.js +37 -37
- package/dist/internal/blocks/AIKit.js +1 -1
- package/dist/internal/blocks/BrandEditor.js +1 -1
- package/dist/internal/blocks/ChartPanel.js +1 -1
- package/dist/internal/blocks/ChipEditor.js +1 -1
- package/dist/internal/blocks/ClipboardButton.js +1 -1
- package/dist/internal/blocks/ColorInput.js +1 -1
- package/dist/internal/blocks/ColorModeSwitch.js +1 -1
- package/dist/internal/blocks/Command.js +1 -1
- package/dist/internal/blocks/CopyField.js +1 -1
- package/dist/internal/blocks/DateInput.js +1 -1
- package/dist/internal/blocks/DateRangeInput.js +1 -1
- package/dist/internal/blocks/EmptyConfigurationActionCard.js +1 -1
- package/dist/internal/blocks/ExportMenu.js +1 -1
- package/dist/internal/blocks/Form/connectors/ComboboxField.js +2 -2
- package/dist/internal/blocks/Form/connectors/ComboboxField.js.map +1 -1
- package/dist/internal/blocks/Form/connectors/MultiComboboxField.js +1 -1
- package/dist/internal/blocks/Form/connectors/MultiComboboxField.js.map +1 -1
- package/dist/internal/blocks/Form.js +1 -1
- package/dist/internal/blocks/FormGroup.js +1 -1
- package/dist/internal/blocks/MultiActionButtonGroup.js +1 -1
- package/dist/internal/blocks/MultiCombobox.js +4 -5
- package/dist/internal/blocks/MultiCombobox.js.map +1 -1
- package/dist/internal/blocks/NumberInput.js +1 -1
- package/dist/internal/blocks/PageToolbar.js +1 -1
- package/dist/internal/blocks/PasswordInput.js +1 -1
- package/dist/internal/blocks/SearchInput.js +1 -1
- package/dist/internal/blocks/SearchInputWithNavigation.js +2 -2
- package/dist/internal/blocks/SectionNav.js +1 -1
- package/dist/internal/blocks/SplitButton.js +1 -1
- package/dist/internal/blocks/StatCard.js +1 -1
- package/dist/internal/blocks/TextInput.js +1 -1
- package/dist/internal/blocks/Textarea.js +1 -1
- package/dist/internal/blocks/TimeInput.js +1 -1
- package/dist/internal/components/AlertModal.js +1 -1
- package/dist/internal/components/Breadcrumb.js +1 -1
- package/dist/internal/components/Button.js +1 -1
- package/dist/internal/components/Card.js +1 -1
- package/dist/internal/components/CollapsiblePanel.js +1 -1
- package/dist/internal/components/CollapsiblePanel.js.map +1 -1
- package/dist/internal/components/Combobox.js +1 -1
- package/dist/internal/components/DateRangePicker.js +1 -1
- package/dist/internal/components/FileUpload.js +1 -1
- package/dist/internal/components/FullScreenModal.js +1 -1
- package/dist/internal/components/InputGroup.js +1 -1
- package/dist/internal/components/Modal.js +1 -1
- package/dist/internal/components/Pagination.js +1 -1
- package/dist/internal/components/Popconfirm.js +1 -1
- package/dist/internal/components/Select.js +1 -1
- package/dist/internal/components/Sheet.js +1 -1
- package/dist/internal/components/Sidebar.js +1 -1
- package/dist/internal/components/Slider.js +1 -1
- package/dist/internal/components/Tabs.js +1 -1
- package/dist/internal/components/ThemeProvider.js +2 -2
- package/dist/internal/components/ZoomableSvg.js +1 -1
- package/dist/internal/utils/accessibleName.js +11 -0
- package/dist/internal/utils/accessibleName.js.map +1 -0
- package/dist/markdown-editor.js +4 -4
- package/dist/mermaid.js +1 -1
- package/dist/rjsf.js +7 -7
- package/dist/styles.css +1 -1
- package/dist/testing.js +3 -4
- package/dist/testing.js.map +1 -1
- package/package.json +23 -23
- package/src/theme.css +6 -1
- package/dist/AIKit-BD4r7ff-.js.map +0 -1
- package/dist/AlertModal-Th2khjPi.js.map +0 -1
- package/dist/Button-Ca4Q3VJU.js.map +0 -1
- package/dist/Card-Cr9MBNHu.js.map +0 -1
- package/dist/Combobox-CxRAYOBt.js.map +0 -1
- package/dist/CopyField-6_c-NdLO.js.map +0 -1
- package/dist/Select-ByRvkZ3D.js.map +0 -1
- package/dist/internal/components/StatusDot.js +0 -60
- package/dist/internal/components/StatusDot.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { cn } from "./classNames-BzrkDnOD.js";
|
|
2
|
-
import { Button } from "./Button-
|
|
3
|
-
import { TextInput } from "./TextInput-
|
|
2
|
+
import { Button } from "./Button-B21oVcPU.js";
|
|
3
|
+
import { TextInput } from "./TextInput-BWYXbfs4.js";
|
|
4
4
|
import { Switch } from "./Switch-DZvNePOm.js";
|
|
5
|
-
import { Select } from "./Select-
|
|
5
|
+
import { Select } from "./Select-B4uK0QVm.js";
|
|
6
6
|
import { Checkbox } from "./Checkbox-8yIIgY7g.js";
|
|
7
|
-
import { FieldItem, fieldContext, formContext, useFieldContext, useFormContext } from "./FieldItem-
|
|
7
|
+
import { FieldItem, fieldContext, formContext, useFieldContext, useFormContext } from "./FieldItem-BHViBJS3.js";
|
|
8
8
|
import { NumberInput } from "./internal/blocks/NumberInput.js";
|
|
9
9
|
import { Textarea } from "./internal/blocks/Textarea.js";
|
|
10
10
|
import { PasswordInput } from "./internal/blocks/PasswordInput.js";
|
|
@@ -300,4 +300,4 @@ const setSubmitError = (form, message) => {
|
|
|
300
300
|
//#endregion
|
|
301
301
|
export { setServerFieldErrors, setSubmitError, useAppForm, withForm };
|
|
302
302
|
|
|
303
|
-
//# sourceMappingURL=Form-
|
|
303
|
+
//# sourceMappingURL=Form-VkzfVPyT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form-95rVLfX8.js","names":[],"sources":["../src/blocks/Form/components/FormBody.tsx","../src/blocks/Form/components/SubmitButton.tsx","../src/blocks/Form/components/SubmitErrorAlert.tsx","../src/blocks/Form/connectors/CheckboxField.tsx","../src/blocks/Form/connectors/NumberField.tsx","../src/blocks/Form/connectors/OtpInputField.tsx","../src/blocks/Form/connectors/PasswordField.tsx","../src/blocks/Form/connectors/SelectField.tsx","../src/blocks/Form/connectors/SwitchField.tsx","../src/blocks/Form/connectors/TextareaField.tsx","../src/blocks/Form/connectors/TextField.tsx","../src/blocks/Form/formHook.ts","../src/blocks/Form/setServerFieldErrors.ts","../src/blocks/Form/setSubmitError.ts"],"sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\n\nimport { cn } from '../../../utils';\nimport { useFormContext } from '../contexts';\n\ntype Props = {\n children: ReactNode;\n} & Omit<ComponentProps<'form'>, 'onSubmit'>;\n\nexport const FormBody = ({ children, className, ...formProps }: Props) => {\n const form = useFormContext();\n\n return (\n <form\n {...formProps}\n className={cn('tw:flex tw:flex-col tw:gap-4', className)}\n onSubmit={(e) => {\n e.preventDefault();\n e.stopPropagation();\n void form.handleSubmit();\n }}\n >\n {children}\n </form>\n );\n};\n","import type { ComponentProps, ReactNode } from 'react';\n\nimport { Button } from '../../../components/Button';\nimport { useFormContext } from '../contexts';\n\ntype Props = {\n children?: ReactNode;\n} & Omit<ComponentProps<typeof Button>, 'type' | 'isLoading' | 'disabled'>;\n\nexport const SubmitButton = ({ children = 'Submit', ...buttonProps }: Props) => {\n const form = useFormContext();\n\n return (\n <form.Subscribe\n selector={(state) => ({ isSubmitting: state.isSubmitting, canSubmit: state.canSubmit })}\n >\n {({ isSubmitting, canSubmit }) => (\n <Button\n {...buttonProps}\n type=\"submit\"\n isLoading={isSubmitting}\n disabled={!canSubmit || isSubmitting}\n >\n {children}\n </Button>\n )}\n </form.Subscribe>\n );\n};\n","import { Alert } from '../../../components/Alert';\nimport { useFormContext } from '../contexts';\n\n/**\n * Renders the form-level submit error (set via `setSubmitError` → `errorMap.onSubmit`) as an error\n * `Alert`. Place inside `form.FormBody`, typically just above the submit button. Renders nothing when\n * there is no submit error.\n */\nexport const SubmitErrorAlert = () => {\n const form = useFormContext();\n\n return (\n <form.Subscribe selector={(state) => state.errorMap.onSubmit}>\n {(submitError) =>\n typeof submitError === 'string' ? <Alert variant=\"error\" title={submitError} /> : null\n }\n </form.Subscribe>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport { Checkbox } from '../../../components/Checkbox';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\n// Checkbox owns its own label + description (via children), so only the wrapper className applies.\ntype Props = Pick<FieldItemProps, 'className'> &\n Omit<ComponentProps<typeof Checkbox>, 'id' | 'name' | 'checked' | 'onCheckedChange'>;\n\nexport const CheckboxField = ({ className, children, ...checkboxProps }: Props) => {\n // Strictly boolean: coerce Radix's `'indeterminate'` to `false` so a non-boolean never leaks into\n // form state (submit payloads / validators). `'indeterminate'` stays a purely visual state.\n const field = useFieldContext<boolean>();\n\n return (\n <FieldItem className={className}>\n {(control) => (\n <Checkbox\n {...checkboxProps}\n {...control}\n checked={field.state.value ?? false}\n onCheckedChange={(checked) => field.handleChange(checked === true)}\n onBlur={field.handleBlur}\n >\n {children}\n </Checkbox>\n )}\n </FieldItem>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport type { FormGroup } from '../../FormGroup';\nimport { NumberInput } from '../../NumberInput';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\ntype Props = FieldItemProps &\n Omit<\n ComponentProps<typeof FormGroup.NumberInput>,\n 'id' | 'name' | 'value' | 'onValueChange' | 'onBlur'\n >;\n\nexport const NumberField = ({\n label,\n action,\n required,\n requiredMark,\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n ...inputProps\n}: Props) => {\n const field = useFieldContext<number | null>();\n\n return (\n <FieldItem\n label={label}\n action={action}\n required={required}\n requiredMark={requiredMark}\n help={help}\n tooltip={tooltip}\n className={className}\n aria-describedby={ariaDescribedBy}\n >\n {(control) => (\n <NumberInput\n {...inputProps}\n {...control}\n value={field.state.value ?? null}\n onValueChange={field.handleChange}\n onBlur={field.handleBlur}\n />\n )}\n </FieldItem>\n );\n};\n","import { OtpInput, type OtpInputProps } from '../../OtpInput';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\ntype Props = FieldItemProps &\n Omit<\n OtpInputProps,\n | 'value'\n | 'onChange'\n | 'children'\n | 'id'\n | 'name'\n | 'aria-describedby'\n | 'aria-required'\n | 'aria-invalid'\n >;\n\nexport const OtpInputField = ({\n label,\n action,\n required,\n requiredMark,\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n maxLength,\n ...otpProps\n}: Props) => {\n const field = useFieldContext<string>();\n\n return (\n <FieldItem\n label={label}\n action={action}\n required={required}\n requiredMark={requiredMark}\n help={help}\n tooltip={tooltip}\n className={className}\n aria-describedby={ariaDescribedBy}\n >\n {(control) => (\n <OtpInput\n {...otpProps}\n {...control}\n maxLength={maxLength}\n value={field.state.value ?? ''}\n onChange={field.handleChange}\n onBlur={field.handleBlur}\n >\n <OtpInput.Group>\n {Array.from({ length: maxLength }, (_, index) => (\n <OtpInput.Slot key={index} index={index} />\n ))}\n </OtpInput.Group>\n </OtpInput>\n )}\n </FieldItem>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport { PasswordInput } from '../../PasswordInput';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\ntype Props = FieldItemProps &\n Omit<ComponentProps<typeof PasswordInput>, 'id' | 'name' | 'value' | 'onValueChange' | 'onBlur'>;\n\nexport const PasswordField = ({\n label,\n action,\n required,\n requiredMark,\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n ...inputProps\n}: Props) => {\n const field = useFieldContext<string>();\n\n return (\n <FieldItem\n label={label}\n action={action}\n required={required}\n requiredMark={requiredMark}\n help={help}\n tooltip={tooltip}\n className={className}\n aria-describedby={ariaDescribedBy}\n >\n {(control) => (\n <PasswordInput\n {...inputProps}\n {...control}\n value={field.state.value ?? ''}\n onValueChange={field.handleChange}\n onBlur={field.handleBlur}\n />\n )}\n </FieldItem>\n );\n};\n","import {\n Select,\n type SelectItem,\n type SelectItemGroup,\n type SelectProps,\n} from '../../../components/Select';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\ntype Props = FieldItemProps &\n Omit<\n SelectProps,\n // Owned by the field / `FieldItem` — see the connector rules in AGENTS.md. The naming props\n // are on that list too: `FieldItem` renders the label and hands the control its `id`, so a\n // name from the call site could only disagree with it.\n | 'id'\n | 'aria-label'\n | 'aria-labelledby'\n | 'name'\n | 'value'\n | 'defaultValue'\n | 'onValueChange'\n | 'onBlur'\n | 'aria-describedby'\n | 'aria-invalid'\n | 'aria-required'\n // `className` styles the field frame, so the trigger gets its own prop below.\n | 'className'\n | 'items'\n > & {\n items: readonly (SelectItem | SelectItemGroup)[];\n triggerClassName?: string;\n };\n\nexport const SelectField = ({\n label,\n action,\n required,\n requiredMark,\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n triggerClassName,\n ...selectProps\n}: Props) => {\n const field = useFieldContext<string>();\n\n return (\n <FieldItem\n label={label}\n action={action}\n required={required}\n requiredMark={requiredMark}\n help={help}\n tooltip={tooltip}\n className={className}\n aria-describedby={ariaDescribedBy}\n >\n {(control) => (\n // `required` deliberately stays on `FieldItem` (which turns it into `aria-required` via\n // `control`) and is not forwarded to the Radix root: a required hidden native select would\n // fail browser constraint validation and swallow the submit event before the form sees it.\n <Select\n {...selectProps}\n {...control}\n className={triggerClassName ?? 'tw:w-full'}\n value={field.state.value ?? ''}\n onValueChange={field.handleChange}\n onBlur={field.handleBlur}\n />\n )}\n </FieldItem>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport { Switch } from '../../../components/Switch';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\n// Switch owns its own label + description (via children), so only the wrapper className applies.\ntype Props = Pick<FieldItemProps, 'className'> &\n Omit<ComponentProps<typeof Switch>, 'id' | 'name' | 'checked' | 'onCheckedChange'>;\n\nexport const SwitchField = ({ className, children, ...switchProps }: Props) => {\n const field = useFieldContext<boolean>();\n\n return (\n <FieldItem className={className}>\n {(control) => (\n <Switch\n {...switchProps}\n {...control}\n checked={field.state.value ?? false}\n onCheckedChange={field.handleChange}\n onBlur={field.handleBlur}\n >\n {children}\n </Switch>\n )}\n </FieldItem>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport type { FormGroup } from '../../FormGroup';\nimport { Textarea } from '../../Textarea';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\ntype Props = FieldItemProps &\n Omit<\n ComponentProps<typeof FormGroup.Textarea>,\n 'id' | 'name' | 'value' | 'onValueChange' | 'onBlur'\n >;\n\nexport const TextareaField = ({\n label,\n action,\n required,\n requiredMark,\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n ...inputProps\n}: Props) => {\n const field = useFieldContext<string>();\n\n return (\n <FieldItem\n label={label}\n action={action}\n required={required}\n requiredMark={requiredMark}\n help={help}\n tooltip={tooltip}\n className={className}\n aria-describedby={ariaDescribedBy}\n >\n {(control) => (\n <Textarea\n {...inputProps}\n {...control}\n value={field.state.value ?? ''}\n onValueChange={field.handleChange}\n onBlur={field.handleBlur}\n />\n )}\n </FieldItem>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport type { FormGroup } from '../../FormGroup';\nimport { TextInput } from '../../TextInput';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\ntype Props = FieldItemProps &\n Omit<ComponentProps<typeof FormGroup.TextInput>, 'id' | 'name' | 'value' | 'onChange' | 'onBlur'>;\n\nexport const TextField = ({\n label,\n action,\n required,\n requiredMark,\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n ...inputProps\n}: Props) => {\n const field = useFieldContext<string>();\n\n return (\n <FieldItem\n label={label}\n action={action}\n required={required}\n requiredMark={requiredMark}\n help={help}\n tooltip={tooltip}\n className={className}\n aria-describedby={ariaDescribedBy}\n >\n {(control) => (\n <TextInput\n {...inputProps}\n {...control}\n value={field.state.value ?? ''}\n onValueChange={field.handleChange}\n onBlur={field.handleBlur}\n />\n )}\n </FieldItem>\n );\n};\n","import { createFormHook } from '@tanstack/react-form';\n\nimport { FormBody } from './components/FormBody';\nimport { SubmitButton } from './components/SubmitButton';\nimport { SubmitErrorAlert } from './components/SubmitErrorAlert';\nimport { CheckboxField } from './connectors/CheckboxField';\nimport { NumberField } from './connectors/NumberField';\nimport { OtpInputField } from './connectors/OtpInputField';\nimport { PasswordField } from './connectors/PasswordField';\nimport { SelectField } from './connectors/SelectField';\nimport { SwitchField } from './connectors/SwitchField';\nimport { TextareaField } from './connectors/TextareaField';\nimport { TextField } from './connectors/TextField';\nimport { fieldContext, formContext } from './contexts';\n\n/**\n * Typed form hook + `withForm` binding for forms with validation, server errors or a submit state.\n *\n * - Render `field.*` inside `form.AppForm` → `form.FormBody`; submit via `form.SubmitButton`.\n * - `ComboboxField`, `MultiComboboxField`, `CodeEditorField` are imported by name: no tree-shaking.\n * - Not for a lone `<input>` (`TextInput`) or an unvalidated label + input (`FormGroup`).\n * - Takes any [Standard Schema](https://standardschema.dev/) validator.\n *\n * @see RECIPES.md#modal-form\n */\nexport const { useAppForm, withForm } = createFormHook({\n fieldContext,\n formContext,\n fieldComponents: {\n TextField,\n NumberField,\n PasswordField,\n TextareaField,\n SelectField,\n CheckboxField,\n SwitchField,\n OtpInputField,\n },\n formComponents: {\n FormBody,\n SubmitButton,\n SubmitErrorAlert,\n },\n});\n","import type { AnyFormApi } from '@tanstack/react-form';\n\nexport type ServerFieldError = {\n field: string;\n message: string;\n};\n\n/**\n * Map a list of server-returned field errors onto a TanStack form instance.\n *\n * - Marks each field blurred — that is what `FieldItem` gates the error reveal on.\n * - `isTouched` alongside it, for anything reading TanStack's own meta (`canSubmit`, dirty checks).\n * - Both are needed. Called from a mutation's `onError` there is no submit attempt to fall back on, so\n * without `isBlurred` the message would sit in `errorMap` and render nowhere.\n */\nexport const setServerFieldErrors = (form: AnyFormApi, errors: readonly ServerFieldError[]) => {\n for (const { field, message } of errors) {\n form.setFieldMeta(field, (meta) => ({\n ...meta,\n isBlurred: true,\n isTouched: true,\n errors: [message],\n errorMap: { ...meta.errorMap, onServer: message },\n }));\n }\n};\n","import type { AnyFormApi } from '@tanstack/react-form';\n\n/**\n * Set a **form-level** submit error on a TanStack form instance — a failed submission that isn't tied\n * to a single field (bad credentials, 5xx, network). Stored on `errorMap.onSubmit` and rendered by\n * `SubmitErrorAlert`. For field-specific server errors use `setServerFieldErrors` instead.\n *\n * Note: any error entry makes the form \"invalid\", so pair this with `canSubmitWhenInvalid: true` on\n * the form to keep the submit button retryable (a resubmit re-runs the validators and clears it).\n */\nexport const setSubmitError = (form: AnyFormApi, message: string) => {\n form.setErrorMap({ onSubmit: { form: message, fields: {} } });\n};\n"],"mappings":";;;;;;;;;;;;;;;AASA,MAAa,YAAY,EAAE,UAAU,WAAW,GAAG,gBAAuB;CACxE,MAAM,OAAO,eAAe;CAE5B,OACE,oBAAC,QAAD;EACE,GAAI;EACJ,WAAW,GAAG,gCA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AK,MAAM,EAAE,OAAO,aAAa,QAC/B,KAAK,aAAa,QAAQ,UAAU;EAClC,GAAG;EACH,WAAW;EACX,WAAW;EACX,QAAQ,CAAC,OAAO;EAChB,UAAU;GAAE,GAAG,KAAK;GAAU,UAAU;EAAQ;CAClD,EAAE;AAEN;;;;;;;;;;;ACfA,MAAa,kBAAkB,MAAkB,YAAoB;CACnE,KAAK,YAAY,EAAE,UAAU;EAAE,MAAM;EAAS,QAAQ,CAAC;CAAE,EAAE,CAAC;AAC9D"}
|
|
1
|
+
{"version":3,"file":"Form-VkzfVPyT.js","names":[],"sources":["../src/blocks/Form/components/FormBody.tsx","../src/blocks/Form/components/SubmitButton.tsx","../src/blocks/Form/components/SubmitErrorAlert.tsx","../src/blocks/Form/connectors/CheckboxField.tsx","../src/blocks/Form/connectors/NumberField.tsx","../src/blocks/Form/connectors/OtpInputField.tsx","../src/blocks/Form/connectors/PasswordField.tsx","../src/blocks/Form/connectors/SelectField.tsx","../src/blocks/Form/connectors/SwitchField.tsx","../src/blocks/Form/connectors/TextareaField.tsx","../src/blocks/Form/connectors/TextField.tsx","../src/blocks/Form/formHook.ts","../src/blocks/Form/setServerFieldErrors.ts","../src/blocks/Form/setSubmitError.ts"],"sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\n\nimport { cn } from '../../../utils';\nimport { useFormContext } from '../contexts';\n\ntype Props = {\n children: ReactNode;\n} & Omit<ComponentProps<'form'>, 'onSubmit'>;\n\nexport const FormBody = ({ children, className, ...formProps }: Props) => {\n const form = useFormContext();\n\n return (\n <form\n {...formProps}\n className={cn('tw:flex tw:flex-col tw:gap-4', className)}\n onSubmit={(e) => {\n e.preventDefault();\n e.stopPropagation();\n void form.handleSubmit();\n }}\n >\n {children}\n </form>\n );\n};\n","import type { ComponentProps, ReactNode } from 'react';\n\nimport { Button } from '../../../components/Button';\nimport { useFormContext } from '../contexts';\n\ntype Props = {\n children?: ReactNode;\n} & Omit<ComponentProps<typeof Button>, 'type' | 'isLoading' | 'disabled'>;\n\nexport const SubmitButton = ({ children = 'Submit', ...buttonProps }: Props) => {\n const form = useFormContext();\n\n return (\n <form.Subscribe\n selector={(state) => ({ isSubmitting: state.isSubmitting, canSubmit: state.canSubmit })}\n >\n {({ isSubmitting, canSubmit }) => (\n <Button\n {...buttonProps}\n type=\"submit\"\n isLoading={isSubmitting}\n disabled={!canSubmit || isSubmitting}\n >\n {children}\n </Button>\n )}\n </form.Subscribe>\n );\n};\n","import { Alert } from '../../../components/Alert';\nimport { useFormContext } from '../contexts';\n\n/**\n * Renders the form-level submit error (set via `setSubmitError` → `errorMap.onSubmit`) as an error\n * `Alert`. Place inside `form.FormBody`, typically just above the submit button. Renders nothing when\n * there is no submit error.\n */\nexport const SubmitErrorAlert = () => {\n const form = useFormContext();\n\n return (\n <form.Subscribe selector={(state) => state.errorMap.onSubmit}>\n {(submitError) =>\n typeof submitError === 'string' ? <Alert variant=\"error\" title={submitError} /> : null\n }\n </form.Subscribe>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport { Checkbox } from '../../../components/Checkbox';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\n// Checkbox owns its own label + description (via children), so only the wrapper className applies.\ntype Props = Pick<FieldItemProps, 'className'> &\n Omit<ComponentProps<typeof Checkbox>, 'id' | 'name' | 'checked' | 'onCheckedChange'>;\n\nexport const CheckboxField = ({ className, children, ...checkboxProps }: Props) => {\n // Strictly boolean: coerce Radix's `'indeterminate'` to `false` so a non-boolean never leaks into\n // form state (submit payloads / validators). `'indeterminate'` stays a purely visual state.\n const field = useFieldContext<boolean>();\n\n return (\n <FieldItem className={className}>\n {(control) => (\n <Checkbox\n {...checkboxProps}\n {...control}\n checked={field.state.value ?? false}\n onCheckedChange={(checked) => field.handleChange(checked === true)}\n onBlur={field.handleBlur}\n >\n {children}\n </Checkbox>\n )}\n </FieldItem>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport type { FormGroup } from '../../FormGroup';\nimport { NumberInput } from '../../NumberInput';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\ntype Props = FieldItemProps &\n Omit<\n ComponentProps<typeof FormGroup.NumberInput>,\n 'id' | 'name' | 'value' | 'onValueChange' | 'onBlur'\n >;\n\nexport const NumberField = ({\n label,\n action,\n required,\n requiredMark,\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n ...inputProps\n}: Props) => {\n const field = useFieldContext<number | null>();\n\n return (\n <FieldItem\n label={label}\n action={action}\n required={required}\n requiredMark={requiredMark}\n help={help}\n tooltip={tooltip}\n className={className}\n aria-describedby={ariaDescribedBy}\n >\n {(control) => (\n <NumberInput\n {...inputProps}\n {...control}\n value={field.state.value ?? null}\n onValueChange={field.handleChange}\n onBlur={field.handleBlur}\n />\n )}\n </FieldItem>\n );\n};\n","import { OtpInput, type OtpInputProps } from '../../OtpInput';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\ntype Props = FieldItemProps &\n Omit<\n OtpInputProps,\n | 'value'\n | 'onChange'\n | 'children'\n | 'id'\n | 'name'\n | 'aria-describedby'\n | 'aria-required'\n | 'aria-invalid'\n >;\n\nexport const OtpInputField = ({\n label,\n action,\n required,\n requiredMark,\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n maxLength,\n ...otpProps\n}: Props) => {\n const field = useFieldContext<string>();\n\n return (\n <FieldItem\n label={label}\n action={action}\n required={required}\n requiredMark={requiredMark}\n help={help}\n tooltip={tooltip}\n className={className}\n aria-describedby={ariaDescribedBy}\n >\n {(control) => (\n <OtpInput\n {...otpProps}\n {...control}\n maxLength={maxLength}\n value={field.state.value ?? ''}\n onChange={field.handleChange}\n onBlur={field.handleBlur}\n >\n <OtpInput.Group>\n {Array.from({ length: maxLength }, (_, index) => (\n <OtpInput.Slot key={index} index={index} />\n ))}\n </OtpInput.Group>\n </OtpInput>\n )}\n </FieldItem>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport { PasswordInput } from '../../PasswordInput';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\ntype Props = FieldItemProps &\n Omit<ComponentProps<typeof PasswordInput>, 'id' | 'name' | 'value' | 'onValueChange' | 'onBlur'>;\n\nexport const PasswordField = ({\n label,\n action,\n required,\n requiredMark,\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n ...inputProps\n}: Props) => {\n const field = useFieldContext<string>();\n\n return (\n <FieldItem\n label={label}\n action={action}\n required={required}\n requiredMark={requiredMark}\n help={help}\n tooltip={tooltip}\n className={className}\n aria-describedby={ariaDescribedBy}\n >\n {(control) => (\n <PasswordInput\n {...inputProps}\n {...control}\n value={field.state.value ?? ''}\n onValueChange={field.handleChange}\n onBlur={field.handleBlur}\n />\n )}\n </FieldItem>\n );\n};\n","import {\n Select,\n type SelectItem,\n type SelectItemGroup,\n type SelectProps,\n} from '../../../components/Select';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\ntype Props = FieldItemProps &\n Omit<\n SelectProps,\n // Owned by the field / `FieldItem` — see the connector rules in AGENTS.md. The naming props\n // are on that list too: `FieldItem` renders the label and hands the control its `id`, so a\n // name from the call site could only disagree with it.\n | 'id'\n | 'aria-label'\n | 'aria-labelledby'\n | 'name'\n | 'value'\n | 'defaultValue'\n | 'onValueChange'\n | 'onBlur'\n | 'aria-describedby'\n | 'aria-invalid'\n | 'aria-required'\n // `className` styles the field frame, so the trigger gets its own prop below.\n | 'className'\n | 'items'\n > & {\n items: readonly (SelectItem | SelectItemGroup)[];\n triggerClassName?: string;\n };\n\nexport const SelectField = ({\n label,\n action,\n required,\n requiredMark,\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n triggerClassName,\n ...selectProps\n}: Props) => {\n const field = useFieldContext<string>();\n\n return (\n <FieldItem\n label={label}\n action={action}\n required={required}\n requiredMark={requiredMark}\n help={help}\n tooltip={tooltip}\n className={className}\n aria-describedby={ariaDescribedBy}\n >\n {(control) => (\n // `required` deliberately stays on `FieldItem` (which turns it into `aria-required` via\n // `control`) and is not forwarded to the Radix root: a required hidden native select would\n // fail browser constraint validation and swallow the submit event before the form sees it.\n <Select\n {...selectProps}\n {...control}\n className={triggerClassName ?? 'tw:w-full'}\n value={field.state.value ?? ''}\n onValueChange={field.handleChange}\n onBlur={field.handleBlur}\n />\n )}\n </FieldItem>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport { Switch } from '../../../components/Switch';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\n// Switch owns its own label + description (via children), so only the wrapper className applies.\ntype Props = Pick<FieldItemProps, 'className'> &\n Omit<ComponentProps<typeof Switch>, 'id' | 'name' | 'checked' | 'onCheckedChange'>;\n\nexport const SwitchField = ({ className, children, ...switchProps }: Props) => {\n const field = useFieldContext<boolean>();\n\n return (\n <FieldItem className={className}>\n {(control) => (\n <Switch\n {...switchProps}\n {...control}\n checked={field.state.value ?? false}\n onCheckedChange={field.handleChange}\n onBlur={field.handleBlur}\n >\n {children}\n </Switch>\n )}\n </FieldItem>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport type { FormGroup } from '../../FormGroup';\nimport { Textarea } from '../../Textarea';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\ntype Props = FieldItemProps &\n Omit<\n ComponentProps<typeof FormGroup.Textarea>,\n 'id' | 'name' | 'value' | 'onValueChange' | 'onBlur'\n >;\n\nexport const TextareaField = ({\n label,\n action,\n required,\n requiredMark,\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n ...inputProps\n}: Props) => {\n const field = useFieldContext<string>();\n\n return (\n <FieldItem\n label={label}\n action={action}\n required={required}\n requiredMark={requiredMark}\n help={help}\n tooltip={tooltip}\n className={className}\n aria-describedby={ariaDescribedBy}\n >\n {(control) => (\n <Textarea\n {...inputProps}\n {...control}\n value={field.state.value ?? ''}\n onValueChange={field.handleChange}\n onBlur={field.handleBlur}\n />\n )}\n </FieldItem>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport type { FormGroup } from '../../FormGroup';\nimport { TextInput } from '../../TextInput';\nimport { useFieldContext } from '../contexts';\n\nimport { FieldItem, type FieldItemProps } from './FieldItem';\n\ntype Props = FieldItemProps &\n Omit<ComponentProps<typeof FormGroup.TextInput>, 'id' | 'name' | 'value' | 'onChange' | 'onBlur'>;\n\nexport const TextField = ({\n label,\n action,\n required,\n requiredMark,\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n ...inputProps\n}: Props) => {\n const field = useFieldContext<string>();\n\n return (\n <FieldItem\n label={label}\n action={action}\n required={required}\n requiredMark={requiredMark}\n help={help}\n tooltip={tooltip}\n className={className}\n aria-describedby={ariaDescribedBy}\n >\n {(control) => (\n <TextInput\n {...inputProps}\n {...control}\n value={field.state.value ?? ''}\n onValueChange={field.handleChange}\n onBlur={field.handleBlur}\n />\n )}\n </FieldItem>\n );\n};\n","import { createFormHook } from '@tanstack/react-form';\n\nimport { FormBody } from './components/FormBody';\nimport { SubmitButton } from './components/SubmitButton';\nimport { SubmitErrorAlert } from './components/SubmitErrorAlert';\nimport { CheckboxField } from './connectors/CheckboxField';\nimport { NumberField } from './connectors/NumberField';\nimport { OtpInputField } from './connectors/OtpInputField';\nimport { PasswordField } from './connectors/PasswordField';\nimport { SelectField } from './connectors/SelectField';\nimport { SwitchField } from './connectors/SwitchField';\nimport { TextareaField } from './connectors/TextareaField';\nimport { TextField } from './connectors/TextField';\nimport { fieldContext, formContext } from './contexts';\n\n/**\n * Typed form hook + `withForm` binding for forms with validation, server errors or a submit state.\n *\n * - Render `field.*` inside `form.AppForm` → `form.FormBody`; submit via `form.SubmitButton`.\n * - `ComboboxField`, `MultiComboboxField`, `CodeEditorField` are imported by name: no tree-shaking.\n * - Not for a lone `<input>` (`TextInput`) or an unvalidated label + input (`FormGroup`).\n * - Takes any [Standard Schema](https://standardschema.dev/) validator.\n *\n * @see RECIPES.md#modal-form\n */\nexport const { useAppForm, withForm } = createFormHook({\n fieldContext,\n formContext,\n fieldComponents: {\n TextField,\n NumberField,\n PasswordField,\n TextareaField,\n SelectField,\n CheckboxField,\n SwitchField,\n OtpInputField,\n },\n formComponents: {\n FormBody,\n SubmitButton,\n SubmitErrorAlert,\n },\n});\n","import type { AnyFormApi } from '@tanstack/react-form';\n\nexport type ServerFieldError = {\n field: string;\n message: string;\n};\n\n/**\n * Map a list of server-returned field errors onto a TanStack form instance.\n *\n * - Marks each field blurred — that is what `FieldItem` gates the error reveal on.\n * - `isTouched` alongside it, for anything reading TanStack's own meta (`canSubmit`, dirty checks).\n * - Both are needed. Called from a mutation's `onError` there is no submit attempt to fall back on, so\n * without `isBlurred` the message would sit in `errorMap` and render nowhere.\n */\nexport const setServerFieldErrors = (form: AnyFormApi, errors: readonly ServerFieldError[]) => {\n for (const { field, message } of errors) {\n form.setFieldMeta(field, (meta) => ({\n ...meta,\n isBlurred: true,\n isTouched: true,\n errors: [message],\n errorMap: { ...meta.errorMap, onServer: message },\n }));\n }\n};\n","import type { AnyFormApi } from '@tanstack/react-form';\n\n/**\n * Set a **form-level** submit error on a TanStack form instance — a failed submission that isn't tied\n * to a single field (bad credentials, 5xx, network). Stored on `errorMap.onSubmit` and rendered by\n * `SubmitErrorAlert`. For field-specific server errors use `setServerFieldErrors` instead.\n *\n * Note: any error entry makes the form \"invalid\", so pair this with `canSubmitWhenInvalid: true` on\n * the form to keep the submit button retryable (a resubmit re-runs the validators and clears it).\n */\nexport const setSubmitError = (form: AnyFormApi, message: string) => {\n form.setErrorMap({ onSubmit: { form: message, fields: {} } });\n};\n"],"mappings":";;;;;;;;;;;;;;;AASA,MAAa,YAAY,EAAE,UAAU,WAAW,GAAG,gBAAuB;CACxE,MAAM,OAAO,eAAe;CAE5B,OACE,oBAAC,QAAD;EACE,GAAI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AAkB,WAAwC;CAC7F,KAAK,MAAM,EAAE,OAAO,aAAa,QAC/B,KAAK,aAAa,QAAQ,UAAU;EAClC,GAAG;EACH,WAAW;EACX,WAAW;EACX,QAAQ,CAAC,OAAO;EAChB,UAAU;GAAE,GAAG,KAAK;GAAU,UAAU;EAAQ;CAClD,EAAE;AAEN;;;;;;;;;;;ACfA,MAAa,kBAAkB,MAAkB,YAAoB;CACnE,KAAK,YAAY,EAAE,UAAU;EAAE,MAAM;EAAS,QAAQ,CAAC;CAAE,EAAE,CAAC;AAC9D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cn } from "./classNames-BzrkDnOD.js";
|
|
2
|
-
import { TextInput } from "./TextInput-
|
|
3
|
-
import { ColorInput } from "./ColorInput-
|
|
2
|
+
import { TextInput } from "./TextInput-BWYXbfs4.js";
|
|
3
|
+
import { ColorInput } from "./ColorInput-B3gBZ8Ya.js";
|
|
4
4
|
import { HelpBlock } from "./internal/components/HelpBlock.js";
|
|
5
5
|
import { NumberInput } from "./internal/blocks/NumberInput.js";
|
|
6
6
|
import { Textarea } from "./internal/blocks/Textarea.js";
|
|
@@ -115,4 +115,4 @@ FormGroup.Textarea = FormGroupTextarea;
|
|
|
115
115
|
//#endregion
|
|
116
116
|
export { FormGroup };
|
|
117
117
|
|
|
118
|
-
//# sourceMappingURL=FormGroup-
|
|
118
|
+
//# sourceMappingURL=FormGroup-CmCppxOn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormGroup-
|
|
1
|
+
{"version":3,"file":"FormGroup-CmCppxOn.js","names":[],"sources":["../src/blocks/FormGroup/context.ts","../src/blocks/FormGroup/FormGroupColorInput.tsx","../src/blocks/FormGroup/FormGroupError.tsx","../src/blocks/FormGroup/FormGroupHelp.tsx","../src/blocks/FormGroup/FormGroupNumberInput.tsx","../src/blocks/FormGroup/FormGroupTextarea.tsx","../src/blocks/FormGroup/FormGroupTextInput.tsx","../src/blocks/FormGroup/FormGroup.tsx"],"sourcesContent":["import { createContext, use } from 'react';\n\nimport type { FormGroupContext } from './types';\n\nconst FormGroupContext = createContext<FormGroupContext>({\n state: 'default',\n});\n\nexport const FormGroupProvider = FormGroupContext;\n\nexport const useFormGroupContext = () => use(FormGroupContext);\n","import type { ComponentProps } from 'react';\n\nimport { ColorInput } from '../ColorInput';\n\nimport { useFormGroupContext } from './context';\n\ntype Props = Omit<ComponentProps<typeof ColorInput>, 'state'>;\n\nexport const FormGroupColorInput = ({ ref, ...props }: Props) => {\n const { state } = useFormGroupContext();\n return <ColorInput state={state} {...props} ref={ref} />;\n};\n","import { useMemo } from 'react';\nimport type { ComponentPropsWithRef, ReactNode } from 'react';\n\nimport { cn } from '../../utils';\n\ntype Props = ComponentPropsWithRef<'div'> & {\n /**\n * TanStack Form errors: strings or `{ message }` objects; several render as a list.\n * Ignored when `children` is provided.\n */\n errors?: readonly (string | { message?: string } | undefined)[];\n};\n\nconst toMessage = (entry: string | { message?: string } | undefined): string | undefined =>\n typeof entry === 'string' ? entry : entry?.message;\n\n/**\n * Field validation error.\n *\n * - `role=\"alert\"` announces it even when focus is elsewhere (e.g. on submit).\n * - A `<div>`, not `<p>`, so several errors can render as a `<ul>`.\n */\nexport const FormGroupError = ({ children, className, errors, ...rest }: Props) => {\n const content = useMemo<ReactNode>(() => {\n if (children) return children;\n\n // Deduplicated: a schema on both `onChange` and `onBlur` yields the same message twice.\n const messages = [...new Set((errors ?? []).map(toMessage).filter((message) => !!message))];\n if (messages.length === 0) return null;\n if (messages.length === 1) return messages[0];\n\n return (\n <ul className=\"tw:m-0 tw:flex tw:list-disc tw:flex-col tw:gap-0 tw:pl-4\">\n {messages.map((message) => (\n // Unique after the dedupe above.\n <li key={message}>{message}</li>\n ))}\n </ul>\n );\n }, [children, errors]);\n\n if (!content) return null;\n\n return (\n <div {...rest} role=\"alert\" className={cn('tw:m-0 tw:text-xs tw:text-destructive', className)}>\n {content}\n </div>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport { HelpBlock } from '../../components/HelpBlock';\n\nimport { useFormGroupContext } from './context';\n\ntype Props = Omit<ComponentProps<typeof HelpBlock>, 'state'>;\n\nexport const FormGroupHelp = ({ children, ...rest }: Props) => {\n const formGroupContext = useFormGroupContext();\n\n // Help stays advisory; a group's error state surfaces via FormGroup.Error, not here.\n return (\n <HelpBlock state={formGroupContext.state === 'warning' ? 'warning' : 'default'} {...rest}>\n {children}\n </HelpBlock>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport { NumberInput } from '../NumberInput';\n\nimport { useFormGroupContext } from './context';\n\ntype Props = Omit<ComponentProps<typeof NumberInput>, 'state'>;\n\nexport const FormGroupNumberInput = ({ ref, ...props }: Props) => {\n const { state } = useFormGroupContext();\n return <NumberInput {...props} ref={ref} state={state} />;\n};\n","import type { ComponentProps } from 'react';\n\nimport { Textarea } from '../Textarea';\n\nimport { useFormGroupContext } from './context';\n\ntype Props = Omit<ComponentProps<typeof Textarea>, 'state'>;\n\nexport const FormGroupTextarea = (props: Props) => {\n const { state } = useFormGroupContext();\n return <Textarea state={state} {...props} />;\n};\n","import type { ComponentProps } from 'react';\n\nimport { TextInput } from '../TextInput';\n\nimport { useFormGroupContext } from './context';\n\ntype Props = Omit<ComponentProps<typeof TextInput>, 'state'>;\n\nexport const FormGroupTextInput = ({ ref, ...props }: Props) => {\n const { state } = useFormGroupContext();\n return <TextInput state={state} {...props} ref={ref} />;\n};\n","import type { ComponentPropsWithRef } from 'react';\n\nimport { cn } from '../../utils';\n\nimport { FormGroupProvider } from './context';\nimport { FormGroupColorInput } from './FormGroupColorInput';\nimport { FormGroupError } from './FormGroupError';\nimport { FormGroupHelp } from './FormGroupHelp';\nimport { FormGroupNumberInput } from './FormGroupNumberInput';\nimport { FormGroupTextarea } from './FormGroupTextarea';\nimport { FormGroupTextInput } from './FormGroupTextInput';\nimport type { FormGroupContext } from './types';\n\n/**\n * - `state` propagates via context to nested inputs.\n * - `FormGroup.Help` reacts only to \"warning\"; errors render through `FormGroup.Error`.\n */\ntype FormGroupProps = ComponentPropsWithRef<'div'> & FormGroupContext;\n\n/**\n * Label + input + help/error text for one field, with shared validation state.\n *\n * - **Use:** a single field outside `useAppForm`.\n * - **Don't use:** for a full form — `useAppForm` from `blocks/Form` composes `FormGroup` itself.\n * - **Composition:** `Label`, one `FormGroup.*Input` / `Textarea`, then optional `Help` or `Error`.\n */\nexport const FormGroup = ({ className, children, state, ...rest }: FormGroupProps) => {\n return (\n <FormGroupProvider value={{ state }}>\n <div {...rest} className={cn('tw:flex tw:flex-col tw:gap-1', className)}>\n {children}\n </div>\n </FormGroupProvider>\n );\n};\n\nFormGroup.Help = FormGroupHelp;\nFormGroup.Error = FormGroupError;\nFormGroup.TextInput = FormGroupTextInput;\nFormGroup.NumberInput = FormGroupNumberInput;\nFormGroup.ColorInput = FormGroupColorInput;\nFormGroup.Textarea = FormGroupTextarea;\n"],"mappings":";;;;;;;;;AAIA,MAAM,mBAAmB,cAAgC,EACvD,OAAO,UACT,CAAC;AAED,MAAa,oBAAoB;AAEjC,MAAa,4BAA4B,IAAI,gBAAgB;;;ACF7D,MAAa,uBAAuB,EAAE,KAAK,GAAG,YAAmB;CAC/D,MAAM,EAAE,UAAU,oBAAoB;CACtC,OAAO,oBAAC,YAAD;EAAmB;EAAO,GAAI;EAAY;CAAM,CAAA;AACzD;;;ACEA,MAAM,aAAa,UACjB,OAAO,UAAU,WAAW,QAAQ,OAAO;;;;;;;AAQ7C,MAAa,kBAAkB,EAAE,UAAU,WAAW,QAAQ,GAAG,WAAkB;CACjF,MAAM,UAAU,cAAyB;EACvC,IAAI,UAAU,OAAO;EAGrB,MAAM,WAAW,CAAC,GAAG,IAAI,KAAK,UAAU,CAAC,EAAA,CAAG,IAAI,SAAS,CAAC,CAAC,QAAQ,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC;EAC1F,IAAI,SAAS,WAAW,GAAG,OAAO;EAClC,IAAI,SAAS,WAAW,GAAG,OAAO,SAAS;EAE3C,OACE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}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cn } from "./classNames-BzrkDnOD.js";
|
|
2
2
|
import { useArgoDesign } from "./context-U293r3v-.js";
|
|
3
3
|
import { ChevronLeft } from "./icons-wcA70iQx.js";
|
|
4
|
-
import { Button } from "./Button-
|
|
4
|
+
import { Button } from "./Button-B21oVcPU.js";
|
|
5
5
|
import { Truncated } from "./internal/components/Truncated.js";
|
|
6
6
|
import { useEffect, useMemo, useRef } from "react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -127,4 +127,4 @@ const FullScreenModal = Object.assign(FullScreenModalRoot, {
|
|
|
127
127
|
//#endregion
|
|
128
128
|
export { FullScreenModal, FullScreenModalBody, FullScreenModalHeader };
|
|
129
129
|
|
|
130
|
-
//# sourceMappingURL=FullScreenModal-
|
|
130
|
+
//# sourceMappingURL=FullScreenModal-Cwnm8WdM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FullScreenModal-
|
|
1
|
+
{"version":3,"file":"FullScreenModal-Cwnm8WdM.js","names":[],"sources":["../src/components/FullScreenModal/FullScreenModalBody.tsx","../src/components/FullScreenModal/FullScreenModalHeader.tsx","../src/components/FullScreenModal/FullScreenModalRoot.tsx","../src/components/FullScreenModal/FullScreenModal.tsx"],"sourcesContent":["import type { HTMLAttributes, Ref } from 'react';\n\nimport { cn } from '../../utils';\n\ntype Props = HTMLAttributes<HTMLDivElement>;\n\nexport const FullScreenModalBody = ({\n ref,\n className,\n children,\n ...props\n}: Props & { ref?: Ref<HTMLDivElement> }) => (\n <div ref={ref} className={cn('tw:flex-1 tw:min-h-0 tw:overflow-auto', className)} {...props}>\n {children}\n </div>\n);\n","import { useMemo } from 'react';\nimport type { HTMLAttributes, PropsWithChildren, ReactNode } from 'react';\n\nimport { ChevronLeft } from '../../icons';\nimport { cn } from '../../utils';\nimport { Button } from '../Button';\nimport { Truncated } from '../Truncated';\n\nconst DEFAULT_TITLE_STYLES =\n 'tw:text-2xl tw:leading-8 tw:font-normal tw:text-foreground tw:overflow-hidden';\n\ntype Props = PropsWithChildren<\n Omit<HTMLAttributes<HTMLDivElement>, 'title'> & {\n title: ReactNode;\n titleClassName?: string;\n titleWrapperClassName?: string;\n defaultTitleStyles?: boolean;\n isTitleWithIcon?: boolean;\n onClose?: () => void;\n showPreviousTitle?: boolean;\n }\n>;\n\nexport const FullScreenModalHeader = ({\n title,\n titleClassName,\n titleWrapperClassName,\n defaultTitleStyles = true,\n isTitleWithIcon = false,\n children,\n onClose,\n className,\n showPreviousTitle = true,\n ...props\n}: Props) => {\n const previousTitle = useMemo(() => {\n const modals = Array.from(document.querySelectorAll('[data-fullscreen-modal]'));\n return (\n showPreviousTitle &&\n modals?.length > 0 &&\n modals.at(-1)?.querySelector('[data-modal-title]')?.textContent\n );\n }, [showPreviousTitle]);\n\n return (\n <div\n className={cn('tw:p-4 tw:flex tw:shrink-0 tw:items-center tw:justify-between', className)}\n {...props}\n >\n <div className={cn('tw:flex tw:flex-1 tw:items-center', titleWrapperClassName)}>\n {previousTitle && onClose && (\n <Button onClick={onClose} size=\"icon\" className=\"tw:mr-6\">\n <ChevronLeft className=\"tw:size-4\" />\n </Button>\n )}\n\n <div className=\"tw:w-full\">\n <div\n className={cn('tw:m-0', defaultTitleStyles && DEFAULT_TITLE_STYLES, titleClassName)}\n data-modal-title\n >\n {previousTitle && onClose && (\n <button\n type=\"button\"\n onClick={onClose}\n className=\"tailwindcss-preflight\"\n aria-label={`Go back to ${previousTitle}`}\n >\n <Truncated\n text={previousTitle}\n className={cn(\n 'tw:relative tw:top-0 tw:cursor-pointer tw:text-base tw:font-normal tw:text-muted-foreground tw:underline',\n 'tw:hover:text-foreground tw:hover:no-underline',\n isTitleWithIcon && 'tw:ml-14',\n )}\n />\n </button>\n )}\n <div\n className={cn('tw:flex tw:items-center', {\n 'tw:[&>img]:-mt-6': previousTitle,\n })}\n >\n {title}\n </div>\n </div>\n </div>\n </div>\n {children}\n </div>\n );\n};\n","import { useEffect, useRef } from 'react';\nimport type { HTMLAttributes, KeyboardEvent, ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { cn } from '../../utils';\nimport { useArgoDesign } from '../ThemeProvider/context';\n\ntype Props = HTMLAttributes<HTMLDivElement> & {\n children: ReactNode;\n /** Lock body scroll when modal is open. Default: true */\n lockBodyScroll?: boolean;\n /** Callback when ESC key is pressed */\n onEscapeKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;\n};\n\nconst BODY_LOCK_CLASS = 'full-screen-modal-open';\n\nexport const FullScreenModalRoot = ({\n children,\n className,\n lockBodyScroll = true,\n onEscapeKeyDown,\n onKeyDown,\n ...props\n}: Props) => {\n const modalRef = useRef<HTMLDivElement>(null);\n const renderArgo = useArgoDesign();\n\n useEffect(() => {\n const modalElement = modalRef.current;\n\n if (lockBodyScroll) {\n document.body.classList.add(BODY_LOCK_CLASS);\n }\n\n return () => {\n // Exclude this modal: it is still in the DOM when `lockBodyScroll` flips to false.\n const hasOtherModals = Array.from(document.querySelectorAll('[data-fullscreen-modal]')).some(\n (el) => el !== modalElement,\n );\n\n if (!hasOtherModals) {\n document.body.classList.remove(BODY_LOCK_CLASS);\n }\n };\n }, [lockBodyScroll]);\n\n /**\n * The element focused when this modal first rendered.\n *\n * - Read during render: a child's `autoFocus` lands at commit, before any effect (layout too).\n */\n const openerRef = useRef<Element | null>(null);\n openerRef.current ??= document.activeElement;\n\n /**\n * Moves focus into the modal on open and back to the opener on close.\n *\n * - Needed for Escape: `onEscapeKeyDown` only fires while focus is inside.\n * - Skipped when the content already autofocused its own field.\n * - Not a focus trap: trapping or `inert` would need this element to own the background.\n */\n useEffect(() => {\n const modal = modalRef.current;\n if (!modal) return;\n\n if (!modal.contains(document.activeElement)) modal.focus();\n\n return () => {\n const opener = openerRef.current;\n if (opener instanceof HTMLElement && opener.isConnected) opener.focus();\n };\n }, []);\n\n /**\n * Escape only dismisses the modal it was pressed in.\n *\n * - React bubbles a nested (portalled) modal's Escape up to the outer one too.\n * - The DOM target check filters it: the inner modal is the outer's sibling, not a descendant.\n * - Not `stopPropagation`: it would also stop the native event at `document.body`, cutting off\n * `document`-level `keydown` handlers (kbc-ui's wrapper closes from one).\n */\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n if (event.key !== 'Escape' || event.defaultPrevented) return;\n\n const target = event.target;\n if (!(target instanceof Node) || !modalRef.current?.contains(target)) return;\n\n onEscapeKeyDown?.(event);\n };\n\n return createPortal(\n <div\n {...props}\n ref={modalRef}\n role=\"dialog\"\n aria-modal=\"true\"\n tabIndex={-1}\n data-fullscreen-modal\n data-argo={renderArgo}\n onKeyDown={handleKeyDown}\n className={cn(\n 'tailwindcss-preflight',\n 'tw:fixed',\n 'tw:inset-0',\n 'tw:z-[1039]',\n 'tw:flex',\n 'tw:flex-col',\n // `text-foreground` travels with the background: portalled to `document.body`,\n // the modal inherits no app-level foreground.\n 'tw:bg-background',\n 'tw:text-foreground',\n 'tw:focus-visible:outline-hidden',\n className,\n )}\n >\n {children}\n </div>,\n document.body,\n );\n};\n","import { FullScreenModalBody } from './FullScreenModalBody';\nimport { FullScreenModalHeader } from './FullScreenModalHeader';\nimport { FullScreenModalRoot } from './FullScreenModalRoot';\n\nexport const FullScreenModal = Object.assign(FullScreenModalRoot, {\n Header: FullScreenModalHeader,\n Body: FullScreenModalBody,\n});\n"],"mappings":";;;;;;;;;AAMA,MAAa,uBAAuB,EAClC,KACA,WACA,UACA,GAAG,YAEH,oBAAC,OAAD;CAAU;CAAK,WAAW,GAAG,yCAAyC,SAAS;CAAG,GAAI;CACnF;AACE,CAAA;;;ACNP,MAAM,uBACJ;AAcF,MAAa,yBAAyB,EACpC,OACA,gBACA,uBACA,qBAAqB,MACrB,kBAAkB,OAClB,UACA,SACA,WACA,oBAAoB,MACpB,GAAG,YACQ;CACX,MAAM,gBAAgB,cAAc;EAClC,MAAM,SAAS,MAAM,KAAK,SAAS,iBAAi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ChB,SAAS,KAAK,UAAU,OAAO,eAAe;EAElD;CACF,GAAG,CAAC,cAAc,CAAC;;;;;;CAOnB,MAAM,YAAY,OAAuB,IAAI;CAC7C,UAAU,YAAY,SAAS;;;;;;;;CAS/B,gBAAgB;EACd,MAAM,QAAQ,SAAS;EACvB,IAAI,CAAC,OAAO;EAEZ,IAAI,CAAC,MAAM,SAAS,SAAS,aAAa,GAAG,MAAM,MAAM;EAEzD,aAAa;GACX,MAAM,SAAS,UAAU;GACzB,IAAI,kBAAkB,eAAe,OAAO,aAAa,OAAO,MAAM;EACxE;CACF,GAAG,CAAC,CAAC;;;;;;;;;CAUL,MAAM,iBAAiB,UAAyC;EAC9D,YAAY,KAAK;EACjB,IAAI,MAAM,QAAQ,YAAY,MAAM,kBAAkB;EAEtD,MAAM,SAAS,MAAM;EACrB,IAAI,EAAE,kBAAkB,SAAS,CAAC,SAAS,SAAS,SAAS,MAAM,GAAG;EAEtE,kBAAkB,KAAK;CACzB;CAEA,OAAO,aACL,oBAAC,OAAD;EACE,GAAI;EACJ,KAAK;EACL,MAAK;EACL,cAAW;EACX,UAAU;EACV,yBAAA;EACA,aAAW;EACX,WAAW;EACX,WAAW,GACT,yBACA,YACA,cACA,eACA,WACA,eAGA,oBACA,sBACA,mCACA,SACF;EAEC;CACE,CAAA,GACL,SAAS,IACX;AACF;;;ACrHA,MAAa,kBAAkB,OAAO,OAAO,qBAAqB;CAChE,QAAQ;CACR,MAAM;AACR,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cn } from "./classNames-BzrkDnOD.js";
|
|
2
2
|
import { useArgoDesign } from "./context-U293r3v-.js";
|
|
3
|
-
import { Button } from "./Button-
|
|
3
|
+
import { Button } from "./Button-B21oVcPU.js";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import TextareaAutosize from "react-textarea-autosize";
|
|
@@ -296,4 +296,4 @@ InputGroup.Text = InputGroupText;
|
|
|
296
296
|
//#endregion
|
|
297
297
|
export { InputGroup };
|
|
298
298
|
|
|
299
|
-
//# sourceMappingURL=InputGroup-
|
|
299
|
+
//# sourceMappingURL=InputGroup-CrlMRz4X.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputGroup-B4QOPxHl.js","names":[],"sources":["../src/components/InputGroup/InputGroupAddon.tsx","../src/components/InputGroup/InputGroupButton.tsx","../src/components/InputGroup/InputGroupInput.tsx","../src/components/InputGroup/InputGroupText.tsx","../src/components/InputGroup/InputGroupTextArea.tsx","../src/components/InputGroup/InputGroup.tsx"],"sourcesContent":["import type { ComponentProps } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '../../utils';\n\n// Padding only fires when the addon actually has content — keeps an empty\n// `<Addon>{maybeNull}</Addon>` from carving 16px out of the input row.\nconst addonVariants = cva(\n [\n 'tw:flex',\n 'tw:items-center',\n 'tw:gap-1',\n\n // Default size for nested Lucide icons in prefix/suffix slots; callers can override on the icon.\n \"tw:[&_svg.lucide:not([class*='tw:size-'])]:size-4\",\n 'tw:[&_svg]:shrink-0',\n ],\n {\n defaultVariants: {\n align: 'inline-start',\n },\n variants: {\n align: {\n 'inline-start': ['tw:order-first', 'tw:shrink-0', 'tw:[&:not(:empty)]:pl-4'],\n 'inline-end': ['tw:order-last', 'tw:shrink-0', 'tw:[&:not(:empty)]:pr-4'],\n 'block-start': [\n 'tw:order-first',\n // `tw:w-full` needs to be empty-conditional too — when the addon\n // has no content the root stays in flex-row, and a 100%-wide\n // empty addon would claim half of the input row beside the input.\n 'tw:[&:not(:empty)]:w-full',\n 'tw:[&:not(:empty)]:px-4',\n 'tw:[&:not(:empty)]:py-1.5',\n ],\n 'block-end': [\n 'tw:order-last',\n 'tw:[&:not(:empty)]:w-full',\n 'tw:[&:not(:empty)]:px-4',\n 'tw:[&:not(:empty)]:py-1.5',\n ],\n },\n },\n },\n);\n\ntype Props = ComponentProps<'div'> & VariantProps<typeof addonVariants>;\n\nexport const InputGroupAddon = ({\n children,\n align = 'inline-start',\n className,\n ...props\n}: Props) => (\n <div {...props} data-align={align} className={cn(addonVariants({ align, className }))}>\n {children}\n </div>\n);\n","import type { ComponentProps } from 'react';\n\nimport { cn } from '../../utils';\nimport { Button } from '../Button';\n\ntype ButtonProps = ComponentProps<typeof Button>;\n\ntype Props = Omit<ButtonProps, 'size' | 'block' | 'variant'>;\n\nexport const InputGroupButton = ({ ref, className, tabIndex = -1, ...props }: Props) => (\n <Button\n {...props}\n tabIndex={tabIndex}\n ref={ref}\n variant=\"invisible\"\n size=\"icon-sm\"\n className={cn('tw:size-5', 'tw:[&_svg]:text-muted-foreground', className)}\n />\n);\n","import type { ComponentProps } from 'react';\n\nimport { cn } from '../../utils';\n\ntype Props = ComponentProps<'input'>;\n\nexport const InputGroupInput = ({ ref, className, ...inputProps }: Props) => (\n <input\n {...inputProps}\n ref={ref}\n className={cn(\n 'tw:flex-1',\n 'tw:min-w-0',\n 'tw:bg-transparent',\n 'tw:outline-hidden',\n\n // font\n 'tw:font-sans',\n 'tw:text-sm',\n\n // placeholder\n 'tw:placeholder:text-neutral-400',\n 'tw:placeholder:font-normal',\n\n // disabled\n 'tw:disabled:cursor-not-allowed',\n\n className,\n )}\n />\n);\n","import type { ComponentProps } from 'react';\n\nimport { cn } from '../../utils';\n\ntype Props = ComponentProps<'span'>;\n\nexport const InputGroupText = ({ className, ...props }: Props) => (\n <span\n className={cn(\n 'tw:flex',\n 'tw:items-center',\n 'tw:gap-2',\n 'tw:text-sm',\n 'tw:text-muted-foreground',\n 'tw:[&_svg]:pointer-events-none',\n 'tw:[&_svg:not([class*=\"tw:size-\"])]:size-4',\n className,\n )}\n {...props}\n />\n);\n","import type { ChangeEventHandler, ComponentProps, FocusEventHandler } from 'react';\nimport TextareaAutosize from 'react-textarea-autosize';\n\nimport { cn } from '../../utils';\n\ntype TextareaNativeProps = Omit<\n ComponentProps<typeof TextareaAutosize>,\n 'value' | 'defaultValue' | 'rows' | 'maxRows'\n>;\n\ntype Props = TextareaNativeProps & {\n value?: string | null;\n defaultValue?: string | null;\n onValueChange?: (value: string) => void;\n onValueBlur?: (value: string) => void;\n maxRows?: number | 'unlimited';\n disableResize?: boolean;\n};\n\nexport const InputGroupTextArea = ({\n ref,\n className,\n onChange,\n onValueChange,\n value,\n defaultValue,\n onBlur,\n onValueBlur,\n disableResize = false,\n minRows = 1,\n maxRows = 4,\n ...props\n}: Props) => {\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (event) => {\n onValueChange?.(event.target.value);\n onChange?.(event);\n };\n\n const handleBlur: FocusEventHandler<HTMLTextAreaElement> = (event) => {\n onValueBlur?.(event.target.value);\n onBlur?.(event);\n };\n\n return (\n <TextareaAutosize\n {...props}\n ref={ref}\n value={value ?? undefined}\n defaultValue={defaultValue ?? undefined}\n onChange={handleChange}\n onBlur={handleBlur}\n minRows={minRows}\n maxRows={maxRows === 'unlimited' ? undefined : maxRows}\n className={cn(\n 'tw:w-full',\n 'tw:bg-transparent',\n 'tw:outline-hidden',\n 'tw:px-4',\n\n // font\n 'tw:font-sans',\n 'tw:text-sm',\n\n // placeholder\n 'tw:placeholder:text-neutral-400',\n 'tw:placeholder:font-normal',\n\n // disabled\n 'tw:disabled:cursor-not-allowed',\n {\n 'tw:resize-none': disableResize,\n },\n\n className,\n )}\n />\n );\n};\n","import type { ComponentPropsWithRef } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '../../utils';\nimport { useArgoDesign } from '../ThemeProvider/context';\n\nimport { InputGroupAddon } from './InputGroupAddon';\nimport { InputGroupButton } from './InputGroupButton';\nimport { InputGroupInput } from './InputGroupInput';\nimport { InputGroupText } from './InputGroupText';\nimport { InputGroupTextArea } from './InputGroupTextArea';\n\nconst inputGroupVariants = cva(\n [\n 'tailwindcss-preflight',\n 'tw:group',\n\n 'tw:overflow-hidden',\n 'tw:box-border',\n\n // positioning\n 'tw:flex',\n 'tw:items-center',\n // A flex item's default `min-width: auto` floors the group at its content's intrinsic width,\n // so a constrained row (several groups side by side) overflows rather than sharing the space.\n // The group clips its own content anyway, and the input inside already carries `min-w-0`.\n 'tw:min-w-0',\n\n // base — legacy (non-argo) chrome uses a fixed radius; argo overrides it with\n // the brand radius token in the `argo` variant below.\n 'tw:rounded',\n 'tw:border',\n 'tw:border-solid',\n // `border-input` and `text-foreground` follow the colour scheme.\n 'tw:border-input',\n 'tw:text-foreground',\n 'tw:transition',\n\n // focus\n 'tw:has-[:is(input,textarea):focus]:ring-4',\n\n // readonly\n 'tw:has-[:is(input,textarea)[readonly]]:bg-muted',\n 'tw:has-[:is(input,textarea)[readonly]]:focus-within:ring-0',\n 'tw:has-[:is(input,textarea)[readonly]]:border-input',\n\n // disabled cursor (opacity owned by variant)\n 'tw:has-[:is(input,textarea):disabled]:cursor-not-allowed',\n\n // textarea: top-align addons, allow vertical expansion, own its y-padding\n 'tw:has-[textarea]:items-start',\n\n 'tw:has-[[data-align=block-start]:not(:empty)]:flex-wrap',\n 'tw:has-[[data-align=block-end]:not(:empty)]:flex-wrap',\n 'tw:[&>input]:has-[[data-align=block-start]:not(:empty)]:w-auto',\n 'tw:[&>input]:has-[[data-align=block-start]:not(:empty)]:flex-1',\n 'tw:[&>input]:has-[[data-align=block-end]:not(:empty)]:w-auto',\n 'tw:[&>input]:has-[[data-align=block-end]:not(:empty)]:flex-1',\n\n 'tw:[&_input]:px-4',\n 'tw:[&>input]:has-[[data-align=inline-start]:not(:empty)]:pl-2',\n 'tw:[&>input]:has-[[data-align=inline-end]:not(:empty)]:pr-2',\n ],\n {\n defaultVariants: {\n variant: 'primary',\n state: 'default',\n sizing: 'medium',\n focusVariant: 'default',\n },\n compoundVariants: [\n {\n variant: 'secondary',\n state: 'error',\n // The fixed light fill needs pinned dark text — `foreground` is near-white in dark.\n className: ['tw:bg-error-100', 'tw:text-neutral-800'],\n },\n {\n variant: 'secondary',\n state: 'warning',\n // Same pin as `error` above.\n className: ['tw:bg-warning-100', 'tw:text-neutral-800'],\n },\n {\n variant: 'primary',\n state: 'default',\n focusVariant: 'off',\n className: ['tw:has-[:is(input,textarea):focus]:border-neutral-200'],\n },\n {\n variant: 'secondary',\n state: 'default',\n focusVariant: 'off',\n className: ['tw:has-[:is(input,textarea):focus]:border-secondary'],\n },\n {\n variant: ['primary', 'secondary'],\n state: 'error',\n focusVariant: 'on',\n className: ['tw:!border-error-500', 'tw:!ring-error-200'],\n },\n {\n variant: ['primary', 'secondary'],\n state: 'warning',\n focusVariant: 'on',\n className: ['tw:!border-warning-500', 'tw:!ring-warning-200'],\n },\n // --- argo ---\n {\n variant: 'argo',\n state: 'default',\n className: [\n 'tw:has-[:is(input,textarea):focus]:border-primary',\n 'tw:has-[:is(input,textarea):focus]:ring-ring/50',\n ],\n },\n {\n variant: 'argo',\n state: 'error',\n className: [\n 'tw:border-destructive',\n 'tw:has-[:is(input,textarea):focus]:border-destructive',\n 'tw:has-[:is(input,textarea):focus]:ring-destructive/20',\n ],\n },\n {\n variant: 'argo',\n focusVariant: 'on',\n className: ['tw:!border-primary', 'tw:!ring-ring/50'],\n },\n {\n variant: 'argo',\n state: 'error',\n focusVariant: 'on',\n className: ['tw:!border-destructive', 'tw:!ring-destructive/20'],\n },\n {\n variant: 'argo',\n state: 'default',\n focusVariant: 'off',\n className: ['tw:has-[:is(input,textarea):focus]:border-input'],\n },\n ],\n variants: {\n focusVariant: {\n default: [],\n on: ['tw:!border-ring', 'tw:!ring-ring/30', 'tw:!ring-4'],\n off: ['tw:has-[:is(input,textarea):focus]:!ring-0'],\n },\n variant: {\n primary: [\n // The field-surface token — white in the light scheme, so this is a\n // no-op there; the dark scheme gets a field fill, not a white slab.\n 'tw:bg-input-background',\n 'tw:text-foreground',\n 'tw:has-[:is(input,textarea):disabled]:opacity-40',\n // aria-invalid on the control surfaces the error chrome without a `state` prop — the\n // accessible path (mirrors the `state=\"error\"` legacy tokens). Higher specificity than\n // the default focus selector, so it wins without `!important`.\n 'tw:has-[:is(input,textarea)[aria-invalid=true]]:border-error-500',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]:focus]:border-error-500',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]:focus]:ring-error-200',\n ],\n secondary: [\n 'tw:bg-secondary',\n 'tw:border-secondary',\n 'tw:has-[:is(input,textarea):disabled]:opacity-40',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]]:border-error-500',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]:focus]:border-error-500',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]:focus]:ring-error-200',\n ],\n argo: [\n // argo follows the brand radius token (overrides the static base)\n 'tw:rounded-[var(--radius-lg,0.25rem)]',\n // muted filled input surface — gray, distinct from white containers; not the app-background token.\n // Deliberately `muted`, not the `input-background` field token legacy uses: argo's field is a\n // grey inset by design. Converging the two is a brand-value decision, not a component one.\n 'tw:bg-muted',\n 'tw:border-input',\n 'tw:text-foreground',\n 'tw:has-[:is(input,textarea):disabled]:opacity-50',\n // readonly: muted fill, input border — same pair as the editable argo field.\n 'tw:has-[:is(input,textarea)[readonly]]:bg-muted',\n 'tw:has-[:is(input,textarea)[readonly]]:border-input',\n // higher specificity than has-[:is(input,textarea):focus] — prevents focus border on readonly\n 'tw:has-[:is(input,textarea)[readonly]:focus]:border-input',\n // aria-invalid on the control surfaces the error chrome without a `state` prop — the\n // accessible path (uses the themeable `destructive` status token).\n 'tw:has-[:is(input,textarea)[aria-invalid=true]]:border-destructive',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]:focus]:border-destructive',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]:focus]:ring-destructive/20',\n ],\n },\n sizing: {\n default: [\n 'tw:[&_:is(input,textarea)]:py-2.5',\n 'tw:[&_:is(input,textarea)]:leading-[18px]',\n 'tw:[&_textarea]:!min-h-[calc(2.5rem-2px)]',\n ],\n small: [\n 'tw:[&_:is(input,textarea)]:py-2',\n 'tw:[&_:is(input,textarea)]:leading-[16px]',\n 'tw:[&_textarea]:!min-h-[calc(2rem-2px)]',\n ],\n medium: [\n 'tw:[&_:is(input,textarea)]:py-2',\n 'tw:[&_:is(input,textarea)]:leading-[18px]',\n 'tw:[&_textarea]:!min-h-[calc(2.25rem-2px)]',\n ],\n },\n state: {\n default: [\n 'tw:has-[:is(input,textarea):focus]:border-ring',\n 'tw:has-[:is(input,textarea):focus]:ring-ring/30',\n ],\n error: [\n 'tw:border-error-500',\n 'tw:has-[:is(input,textarea):focus]:border-error-500',\n 'tw:has-[:is(input,textarea):focus]:ring-error-200',\n ],\n warning: [\n 'tw:border-warning-500',\n 'tw:has-[:is(input,textarea):focus]:border-warning-500',\n 'tw:has-[:is(input,textarea):focus]:ring-warning-200',\n ],\n },\n },\n },\n);\n\ntype Props = ComponentPropsWithRef<'div'> &\n Omit<VariantProps<typeof inputGroupVariants>, 'variant'> & {\n variant?: Exclude<VariantProps<typeof inputGroupVariants>['variant'], 'argo'>;\n };\n\nconst InputGroupRoot = ({\n ref,\n children,\n state,\n variant,\n sizing,\n focusVariant,\n className,\n ...props\n}: Props) => {\n const isArgo = useArgoDesign();\n const effectiveVariant = isArgo ? 'argo' : variant;\n const effectiveSizing = effectiveVariant === 'argo' ? 'medium' : sizing;\n return (\n <div\n {...props}\n ref={ref}\n className={cn(\n inputGroupVariants({\n state,\n variant: effectiveVariant,\n sizing: effectiveSizing,\n focusVariant,\n className,\n }),\n )}\n >\n {children}\n </div>\n );\n};\n\nexport const InputGroup = InputGroupRoot as typeof InputGroupRoot & {\n Input: typeof InputGroupInput;\n Addon: typeof InputGroupAddon;\n Button: typeof InputGroupButton;\n TextArea: typeof InputGroupTextArea;\n Text: typeof InputGroupText;\n};\n\nInputGroup.Input = InputGroupInput;\nInputGroup.Addon = InputGroupAddon;\nInputGroup.Button = InputGroupButton;\nInputGroup.TextArea = InputGroupTextArea;\nInputGroup.Text = InputGroupText;\n"],"mappings":";;;;;;;AAOA,MAAM,gBAAgB,IACpB;CACE;CACA;CACA;CAGA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AO;GACP,cAAc;GACd,WAAW,CAAC,iDAAiD;EAC/D;CACF;CACA,UAAU;EACR,cAAc;GACZ,SAAS,CAAC;GACV,IAAI;IAAC;IAAmB;IAAoB;GAAY;GACxD,KAAK,CAAC,4CAA4C;EACpD;EACA,SAAS;GACP,SAAS;IAGP;IACA;IACA;IAIA;IACA;IACA;GACF;GACA,WAAW;IACT;IACA;IACA;IACA;IACA;IACA;GACF;GACA,MAAM;IAEJ;IAIA;IACA;IACA;IACA;IAEA;IACA;IAEA;IAGA;IACA;IACA;GACF;EACF;EACA,QAAQ;GACN,SAAS;IACP;IACA;IACA;GACF;GACA,OAAO;IACL;IACA;IACA;GACF;GACA,QAAQ;IACN;IACA;IACA;GACF;EACF;EACA,OAAO;GACL,SAAS,CACP,kDACA,iDACF;GACA,OAAO;IACL;IACA;IACA;GACF;GACA,SAAS;IACP;IACA;IACA;GACF;EACF;CACF;AACF,CACF;AAOA,MAAM,kBAAkB,EACtB,KACA,UACA,OACA,SACA,QACA,cACA,WACA,GAAG,YACQ;CAEX,MAAM,mBADS,cACe,IAAI,SAAS;CAC3C,MAAM,kBAAkB,qBAAqB,SAAS,WAAW;CACjE,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,WAAW,GACT,mBAAmB;GACjB;GACA,SAAS;GACT,QAAQ;GACR;GACA;EACF,CAAC,CACH;EAEC;CACE,CAAA;AAET;AAEA,MAAa,aAAa;AAQ1B,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,SAAS;AACpB,WAAW,WAAW;AACtB,WAAW,OAAO"}
|
|
1
|
+
{"version":3,"file":"InputGroup-CrlMRz4X.js","names":[],"sources":["../src/components/InputGroup/InputGroupAddon.tsx","../src/components/InputGroup/InputGroupButton.tsx","../src/components/InputGroup/InputGroupInput.tsx","../src/components/InputGroup/InputGroupText.tsx","../src/components/InputGroup/InputGroupTextArea.tsx","../src/components/InputGroup/InputGroup.tsx"],"sourcesContent":["import type { ComponentProps } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '../../utils';\n\n// Padding only fires when the addon actually has content — keeps an empty\n// `<Addon>{maybeNull}</Addon>` from carving 16px out of the input row.\nconst addonVariants = cva(\n [\n 'tw:flex',\n 'tw:items-center',\n 'tw:gap-1',\n\n // Default size for nested Lucide icons in prefix/suffix slots; callers can override on the icon.\n \"tw:[&_svg.lucide:not([class*='tw:size-'])]:size-4\",\n 'tw:[&_svg]:shrink-0',\n ],\n {\n defaultVariants: {\n align: 'inline-start',\n },\n variants: {\n align: {\n 'inline-start': ['tw:order-first', 'tw:shrink-0', 'tw:[&:not(:empty)]:pl-4'],\n 'inline-end': ['tw:order-last', 'tw:shrink-0', 'tw:[&:not(:empty)]:pr-4'],\n 'block-start': [\n 'tw:order-first',\n // `tw:w-full` needs to be empty-conditional too — when the addon\n // has no content the root stays in flex-row, and a 100%-wide\n // empty addon would claim half of the input row beside the input.\n 'tw:[&:not(:empty)]:w-full',\n 'tw:[&:not(:empty)]:px-4',\n 'tw:[&:not(:empty)]:py-1.5',\n ],\n 'block-end': [\n 'tw:order-last',\n 'tw:[&:not(:empty)]:w-full',\n 'tw:[&:not(:empty)]:px-4',\n 'tw:[&:not(:empty)]:py-1.5',\n ],\n },\n },\n },\n);\n\ntype Props = ComponentProps<'div'> & VariantProps<typeof addonVariants>;\n\nexport const InputGroupAddon = ({\n children,\n align = 'inline-start',\n className,\n ...props\n}: Props) => (\n <div {...props} data-align={align} className={cn(addonVariants({ align, className }))}>\n {children}\n </div>\n);\n","import type { ComponentProps } from 'react';\n\nimport { cn } from '../../utils';\nimport { Button } from '../Button';\n\ntype ButtonProps = ComponentProps<typeof Button>;\n\ntype Props = Omit<ButtonProps, 'size' | 'block' | 'variant'>;\n\nexport const InputGroupButton = ({ ref, className, tabIndex = -1, ...props }: Props) => (\n <Button\n {...props}\n tabIndex={tabIndex}\n ref={ref}\n variant=\"invisible\"\n size=\"icon-sm\"\n className={cn('tw:size-5', 'tw:[&_svg]:text-muted-foreground', className)}\n />\n);\n","import type { ComponentProps } from 'react';\n\nimport { cn } from '../../utils';\n\ntype Props = ComponentProps<'input'>;\n\nexport const InputGroupInput = ({ ref, className, ...inputProps }: Props) => (\n <input\n {...inputProps}\n ref={ref}\n className={cn(\n 'tw:flex-1',\n 'tw:min-w-0',\n 'tw:bg-transparent',\n 'tw:outline-hidden',\n\n // font\n 'tw:font-sans',\n 'tw:text-sm',\n\n // placeholder\n 'tw:placeholder:text-neutral-400',\n 'tw:placeholder:font-normal',\n\n // disabled\n 'tw:disabled:cursor-not-allowed',\n\n className,\n )}\n />\n);\n","import type { ComponentProps } from 'react';\n\nimport { cn } from '../../utils';\n\ntype Props = ComponentProps<'span'>;\n\nexport const InputGroupText = ({ className, ...props }: Props) => (\n <span\n className={cn(\n 'tw:flex',\n 'tw:items-center',\n 'tw:gap-2',\n 'tw:text-sm',\n 'tw:text-muted-foreground',\n 'tw:[&_svg]:pointer-events-none',\n 'tw:[&_svg:not([class*=\"tw:size-\"])]:size-4',\n className,\n )}\n {...props}\n />\n);\n","import type { ChangeEventHandler, ComponentProps, FocusEventHandler } from 'react';\nimport TextareaAutosize from 'react-textarea-autosize';\n\nimport { cn } from '../../utils';\n\ntype TextareaNativeProps = Omit<\n ComponentProps<typeof TextareaAutosize>,\n 'value' | 'defaultValue' | 'rows' | 'maxRows'\n>;\n\ntype Props = TextareaNativeProps & {\n value?: string | null;\n defaultValue?: string | null;\n onValueChange?: (value: string) => void;\n onValueBlur?: (value: string) => void;\n maxRows?: number | 'unlimited';\n disableResize?: boolean;\n};\n\nexport const InputGroupTextArea = ({\n ref,\n className,\n onChange,\n onValueChange,\n value,\n defaultValue,\n onBlur,\n onValueBlur,\n disableResize = false,\n minRows = 1,\n maxRows = 4,\n ...props\n}: Props) => {\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (event) => {\n onValueChange?.(event.target.value);\n onChange?.(event);\n };\n\n const handleBlur: FocusEventHandler<HTMLTextAreaElement> = (event) => {\n onValueBlur?.(event.target.value);\n onBlur?.(event);\n };\n\n return (\n <TextareaAutosize\n {...props}\n ref={ref}\n value={value ?? undefined}\n defaultValue={defaultValue ?? undefined}\n onChange={handleChange}\n onBlur={handleBlur}\n minRows={minRows}\n maxRows={maxRows === 'unlimited' ? undefined : maxRows}\n className={cn(\n 'tw:w-full',\n 'tw:bg-transparent',\n 'tw:outline-hidden',\n 'tw:px-4',\n\n // font\n 'tw:font-sans',\n 'tw:text-sm',\n\n // placeholder\n 'tw:placeholder:text-neutral-400',\n 'tw:placeholder:font-normal',\n\n // disabled\n 'tw:disabled:cursor-not-allowed',\n {\n 'tw:resize-none': disableResize,\n },\n\n className,\n )}\n />\n );\n};\n","import type { ComponentPropsWithRef } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '../../utils';\nimport { useArgoDesign } from '../ThemeProvider/context';\n\nimport { InputGroupAddon } from './InputGroupAddon';\nimport { InputGroupButton } from './InputGroupButton';\nimport { InputGroupInput } from './InputGroupInput';\nimport { InputGroupText } from './InputGroupText';\nimport { InputGroupTextArea } from './InputGroupTextArea';\n\nconst inputGroupVariants = cva(\n [\n 'tailwindcss-preflight',\n 'tw:group',\n\n 'tw:overflow-hidden',\n 'tw:box-border',\n\n // positioning\n 'tw:flex',\n 'tw:items-center',\n // A flex item's default `min-width: auto` floors the group at its content's intrinsic width,\n // so a constrained row (several groups side by side) overflows rather than sharing the space.\n // The group clips its own content anyway, and the input inside already carries `min-w-0`.\n 'tw:min-w-0',\n\n // base — legacy (non-argo) chrome uses a fixed radius; argo overrides it with\n // the brand radius token in the `argo` variant below.\n 'tw:rounded',\n 'tw:border',\n 'tw:border-solid',\n // `border-input` and `text-foreground` follow the colour scheme.\n 'tw:border-input',\n 'tw:text-foreground',\n 'tw:transition',\n\n // focus\n 'tw:has-[:is(input,textarea):focus]:ring-4',\n\n // readonly\n 'tw:has-[:is(input,textarea)[readonly]]:bg-muted',\n 'tw:has-[:is(input,textarea)[readonly]]:focus-within:ring-0',\n 'tw:has-[:is(input,textarea)[readonly]]:border-input',\n\n // disabled cursor (opacity owned by variant)\n 'tw:has-[:is(input,textarea):disabled]:cursor-not-allowed',\n\n // textarea: top-align addons, allow vertical expansion, own its y-padding\n 'tw:has-[textarea]:items-start',\n\n 'tw:has-[[data-align=block-start]:not(:empty)]:flex-wrap',\n 'tw:has-[[data-align=block-end]:not(:empty)]:flex-wrap',\n 'tw:[&>input]:has-[[data-align=block-start]:not(:empty)]:w-auto',\n 'tw:[&>input]:has-[[data-align=block-start]:not(:empty)]:flex-1',\n 'tw:[&>input]:has-[[data-align=block-end]:not(:empty)]:w-auto',\n 'tw:[&>input]:has-[[data-align=block-end]:not(:empty)]:flex-1',\n\n 'tw:[&_input]:px-4',\n 'tw:[&>input]:has-[[data-align=inline-start]:not(:empty)]:pl-2',\n 'tw:[&>input]:has-[[data-align=inline-end]:not(:empty)]:pr-2',\n ],\n {\n defaultVariants: {\n variant: 'primary',\n state: 'default',\n sizing: 'medium',\n focusVariant: 'default',\n },\n compoundVariants: [\n {\n variant: 'secondary',\n state: 'error',\n // The fixed light fill needs pinned dark text — `foreground` is near-white in dark.\n className: ['tw:bg-error-100', 'tw:text-neutral-800'],\n },\n {\n variant: 'secondary',\n state: 'warning',\n // Same pin as `error` above.\n className: ['tw:bg-warning-100', 'tw:text-neutral-800'],\n },\n {\n variant: 'primary',\n state: 'default',\n focusVariant: 'off',\n className: ['tw:has-[:is(input,textarea):focus]:border-neutral-200'],\n },\n {\n variant: 'secondary',\n state: 'default',\n focusVariant: 'off',\n className: ['tw:has-[:is(input,textarea):focus]:border-secondary'],\n },\n {\n variant: ['primary', 'secondary'],\n state: 'error',\n focusVariant: 'on',\n className: ['tw:!border-error-500', 'tw:!ring-error-200'],\n },\n {\n variant: ['primary', 'secondary'],\n state: 'warning',\n focusVariant: 'on',\n className: ['tw:!border-warning-500', 'tw:!ring-warning-200'],\n },\n // --- argo ---\n {\n variant: 'argo',\n state: 'default',\n className: [\n 'tw:has-[:is(input,textarea):focus]:border-primary',\n 'tw:has-[:is(input,textarea):focus]:ring-ring/50',\n ],\n },\n {\n variant: 'argo',\n state: 'error',\n className: [\n 'tw:border-destructive',\n 'tw:has-[:is(input,textarea):focus]:border-destructive',\n 'tw:has-[:is(input,textarea):focus]:ring-destructive/20',\n ],\n },\n {\n variant: 'argo',\n focusVariant: 'on',\n className: ['tw:!border-primary', 'tw:!ring-ring/50'],\n },\n {\n variant: 'argo',\n state: 'error',\n focusVariant: 'on',\n className: ['tw:!border-destructive', 'tw:!ring-destructive/20'],\n },\n {\n variant: 'argo',\n state: 'default',\n focusVariant: 'off',\n className: ['tw:has-[:is(input,textarea):focus]:border-input'],\n },\n ],\n variants: {\n focusVariant: {\n default: [],\n on: ['tw:!border-ring', 'tw:!ring-ring/30', 'tw:!ring-4'],\n off: ['tw:has-[:is(input,textarea):focus]:!ring-0'],\n },\n variant: {\n primary: [\n // The field-surface token — white in the light scheme, so this is a\n // no-op there; the dark scheme gets a field fill, not a white slab.\n 'tw:bg-input-background',\n 'tw:text-foreground',\n 'tw:has-[:is(input,textarea):disabled]:opacity-40',\n // aria-invalid on the control surfaces the error chrome without a `state` prop — the\n // accessible path (mirrors the `state=\"error\"` legacy tokens). Higher specificity than\n // the default focus selector, so it wins without `!important`.\n 'tw:has-[:is(input,textarea)[aria-invalid=true]]:border-error-500',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]:focus]:border-error-500',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]:focus]:ring-error-200',\n ],\n secondary: [\n 'tw:bg-secondary',\n 'tw:border-secondary',\n 'tw:has-[:is(input,textarea):disabled]:opacity-40',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]]:border-error-500',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]:focus]:border-error-500',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]:focus]:ring-error-200',\n ],\n argo: [\n // argo follows the brand radius token (overrides the static base)\n 'tw:rounded-[var(--radius-lg,0.25rem)]',\n // muted filled input surface — gray, distinct from white containers; not the app-background token.\n // Deliberately `muted`, not the `input-background` field token legacy uses: argo's field is a\n // grey inset by design. Converging the two is a brand-value decision, not a component one.\n 'tw:bg-muted',\n 'tw:border-input',\n 'tw:text-foreground',\n 'tw:has-[:is(input,textarea):disabled]:opacity-50',\n // readonly: muted fill, input border — same pair as the editable argo field.\n 'tw:has-[:is(input,textarea)[readonly]]:bg-muted',\n 'tw:has-[:is(input,textarea)[readonly]]:border-input',\n // higher specificity than has-[:is(input,textarea):focus] — prevents focus border on readonly\n 'tw:has-[:is(input,textarea)[readonly]:focus]:border-input',\n // aria-invalid on the control surfaces the error chrome without a `state` prop — the\n // accessible path (uses the themeable `destructive` status token).\n 'tw:has-[:is(input,textarea)[aria-invalid=true]]:border-destructive',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]:focus]:border-destructive',\n 'tw:has-[:is(input,textarea)[aria-invalid=true]:focus]:ring-destructive/20',\n ],\n },\n sizing: {\n default: [\n 'tw:[&_:is(input,textarea)]:py-2.5',\n 'tw:[&_:is(input,textarea)]:leading-[18px]',\n 'tw:[&_textarea]:!min-h-[calc(2.5rem-2px)]',\n ],\n small: [\n 'tw:[&_:is(input,textarea)]:py-2',\n 'tw:[&_:is(input,textarea)]:leading-[16px]',\n 'tw:[&_textarea]:!min-h-[calc(2rem-2px)]',\n ],\n medium: [\n 'tw:[&_:is(input,textarea)]:py-2',\n 'tw:[&_:is(input,textarea)]:leading-[18px]',\n 'tw:[&_textarea]:!min-h-[calc(2.25rem-2px)]',\n ],\n },\n state: {\n default: [\n 'tw:has-[:is(input,textarea):focus]:border-ring',\n 'tw:has-[:is(input,textarea):focus]:ring-ring/30',\n ],\n error: [\n 'tw:border-error-500',\n 'tw:has-[:is(input,textarea):focus]:border-error-500',\n 'tw:has-[:is(input,textarea):focus]:ring-error-200',\n ],\n warning: [\n 'tw:border-warning-500',\n 'tw:has-[:is(input,textarea):focus]:border-warning-500',\n 'tw:has-[:is(input,textarea):focus]:ring-warning-200',\n ],\n },\n },\n },\n);\n\ntype Props = ComponentPropsWithRef<'div'> &\n Omit<VariantProps<typeof inputGroupVariants>, 'variant'> & {\n variant?: Exclude<VariantProps<typeof inputGroupVariants>['variant'], 'argo'>;\n };\n\nconst InputGroupRoot = ({\n ref,\n children,\n state,\n variant,\n sizing,\n focusVariant,\n className,\n ...props\n}: Props) => {\n const isArgo = useArgoDesign();\n const effectiveVariant = isArgo ? 'argo' : variant;\n const effectiveSizing = effectiveVariant === 'argo' ? 'medium' : sizing;\n return (\n <div\n {...props}\n ref={ref}\n className={cn(\n inputGroupVariants({\n state,\n variant: effectiveVariant,\n sizing: effectiveSizing,\n focusVariant,\n className,\n }),\n )}\n >\n {children}\n </div>\n );\n};\n\nexport const InputGroup = InputGroupRoot as typeof InputGroupRoot & {\n Input: typeof InputGroupInput;\n Addon: typeof InputGroupAddon;\n Button: typeof InputGroupButton;\n TextArea: typeof InputGroupTextArea;\n Text: typeof InputGroupText;\n};\n\nInputGroup.Input = InputGroupInput;\nInputGroup.Addon = InputGroupAddon;\nInputGroup.Button = InputGroupButton;\nInputGroup.TextArea = InputGroupTextArea;\nInputGroup.Text = InputGroupText;\n"],"mappings":";;;;;;;AAOA,MAAM,gBAAgB,IACpB;CACE;CACA;CACA;CAGA;CACA;AACF,GACA;CACE,iBAAiB,EACf,OAAO,eACT;CACA,UAAU,EACR,OAAO;EACL,gBAAgB;GAAC;GAAkB;GAAe;EAAyB;EAC3E,cAAc;GAAC;GAAiB;GAAe;EAAyB;EACxE,eAAe;GACb;GAIA;GACA;GACA;EACF;EACA,aAAa;GACX;GACA;GACA;GACA;EACF;CACF,EACF;AACF,CACF;AAIA,MAAa,mBAAmB,EAC9B,UACA,QAAQ,gBACR,WACA,GAAG,YAEH,oBAAC,OAAD;CAAK,GAAI;CAAO,cAAY;CAAO,WAAW,GAAG,cAAc;EAAE;EAAO;CAAU,CAAC,CAAC;CACjF;AACE,CAAA;;;AC9CP,MAAa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;EACT,OAAO;EACP,QAAQ;EACR,cAAc;CAChB;CACA,kBAAkB;EAChB;GACE,SAAS;GACT,OAAO;GAEP,WAAW,CAAC,mBAAmB,qBAAqB;EACtD;EACA;GACE,SAAS;GACT,OAAO;GAEP,WAAW,CAAC,qBAAqB,qBAAqB;EACxD;EACA;GACE,SAAS;GACT,OAAO;GACP,cAAc;GACd,WAAW,CAAC,uDAAuD;EACrE;EACA;GACE,SAAS;GACT,OAAO;GACP,cAAc;GACd,WAAW,CAAC,qDAAqD;EACnE;EACA;GACE,SAAS,CAAC,WAAW,WAAW;GAChC,OAAO;GACP,cAAc;GACd,WAAW,CAAC,wBAAwB,oBAAoB;EAC1D;EACA;GACE,SAAS,CAAC,WAAW,WAAW;GAChC,OAAO;GACP,cAAc;GACd,WAAW,CAAC,0BAA0B,sBAAsB;EAC9D;EAEA;GACE,SAAS;GACT,OAAO;GACP,WAAW,CACT,qDACA,iDACF;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,WAAW;IACT;IACA;IACA;GACF;EACF;EACA;GACE,SAAS;GACT,cAAc;GACd,WAAW,CAAC,sBAAsB,kBAAkB;EACtD;EACA;GACE,SAAS;GACT,OAAO;GACP,cAAc;GACd,WAAW,CAAC,0BAA0B,yBAAyB;EACjE;EACA;GACE,SAAS;GACT,OAAO;GACP,cAAc;GACd,WAAW,CAAC,iDAAiD;EAC/D;CACF;CACA,UAAU;EACR,cAAc;GACZ,SAAS,CAAC;GACV,IAAI;IAAC;IAAmB;IAAoB;GAAY;GACxD,KAAK,CAAC,4CAA4C;EACpD;EACA,SAAS;GACP,SAAS;IAGP;IACA;IACA;IAIA;IACA;IACA;GACF;GACA,WAAW;IACT;IACA;IACA;IACA;IACA;IACA;GACF;GACA,MAAM;IAEJ;IAIA;IACA;IACA;IACA;IAEA;IACA;IAEA;IAGA;IACA;IACA;GACF;EACF;EACA,QAAQ;GACN,SAAS;IACP;IACA;IACA;GACF;GACA,OAAO;IACL;IACA;IACA;GACF;GACA,QAAQ;IACN;IACA;IACA;GACF;EACF;EACA,OAAO;GACL,SAAS,CACP,kDACA,iDACF;GACA,OAAO;IACL;IACA;IACA;GACF;GACA,SAAS;IACP;IACA;IACA;GACF;EACF;CACF;AACF,CACF;AAOA,MAAM,kBAAkB,EACtB,KACA,UACA,OACA,SACA,QACA,cACA,WACA,GAAG,YACQ;CAEX,MAAM,mBADS,cACe,IAAI,SAAS;CAC3C,MAAM,kBAAkB,qBAAqB,SAAS,WAAW;CACjE,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,WAAW,GACT,mBAAmB;GACjB;GACA,SAAS;GACT,QAAQ;GACR;GACA;EACF,CAAC,CACH;EAEC;CACE,CAAA;AAET;AAEA,MAAa,aAAa;AAQ1B,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,SAAS;AACpB,WAAW,WAAW;AACtB,WAAW,OAAO"}
|
|
@@ -2,7 +2,7 @@ import { __exportAll } from "./rolldown-runtime-Bdc48AWt.js";
|
|
|
2
2
|
import { DiagramSkeleton } from "./internal/blocks/DiagramShared/DiagramSkeleton.js";
|
|
3
3
|
import { DiagramSource } from "./DiagramSource-C5_d8Gdj.js";
|
|
4
4
|
import { useThemeAttributes } from "./useThemeAttributes-B199Regy.js";
|
|
5
|
-
import { ZoomableSvg } from "./ZoomableSvg-
|
|
5
|
+
import { ZoomableSvg } from "./ZoomableSvg-C65nta_r.js";
|
|
6
6
|
import { createTokenResolver } from "./themeTokens-7DEab0kp.js";
|
|
7
7
|
import { flattenForeignObjectLabels, hasDrawnContent, makeResponsive } from "./svgTransforms-Dw2hRA-i.js";
|
|
8
8
|
import { useEffect, useId, useRef, useState } from "react";
|
|
@@ -299,4 +299,4 @@ const MermaidDiagram = ({ code, renderActions }) => {
|
|
|
299
299
|
//#endregion
|
|
300
300
|
export { MermaidDiagram, MermaidDiagram_exports };
|
|
301
301
|
|
|
302
|
-
//# sourceMappingURL=MermaidDiagram-
|
|
302
|
+
//# sourceMappingURL=MermaidDiagram-B30x2yV7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MermaidDiagram-BQvz6bhv.js","names":[],"sources":["../src/blocks/MermaidDiagram/mermaidTheme.ts","../src/blocks/MermaidDiagram/MermaidDiagram.tsx"],"sourcesContent":["import type { RenderOptions } from 'beautiful-mermaid';\nimport type { MermaidConfig } from 'mermaid';\n\nimport type { ResolvedColorScheme } from '../../components/ThemeProvider/types';\nimport { createTokenResolver } from '../../utils/themeTokens';\n\nconst DIAGRAM_FONT = 'Inter, system-ui, sans-serif';\n\n/**\n * Token fallbacks; keep in sync with the `:root` / `[data-theme='dark']` blocks of `styles.css`.\n *\n * - Used only when the live custom property is missing (SSR, tests without CSS).\n */\nconst FALLBACK_CHANNELS = {\n card: { light: '255 255 255', dark: '34 34 40' },\n 'card-foreground': { light: '30 41 59', dark: '229 230 236' },\n foreground: { light: '30 41 59', dark: '229 230 236' },\n muted: { light: '241 245 249', dark: '38 38 45' },\n 'muted-foreground': { light: '100 116 139', dark: '141 144 153' },\n border: { light: '229 231 235', dark: '52 53 62' },\n primary: { light: '37 99 235', dark: '31 143 255' },\n accent: { light: '224 242 254', dark: '30 58 95' },\n 'accent-foreground': { light: '13 65 127', dark: '147 197 253' },\n warning: { light: '138 82 16', dark: '255 190 92' },\n success: { light: '24 122 76', dark: '62 207 127' },\n destructive: { light: '220 38 38', dark: '229 72 77' },\n} as const;\n\ntype TokenName = keyof typeof FALLBACK_CHANNELS;\n\n/** One `getComputedStyle` snapshot per palette; never hoist — values follow scheme and brand. */\nconst tokenReader = (scheme: ResolvedColorScheme, from?: Element | null) => {\n const resolve = createTokenResolver(from);\n return (name: TokenName, alpha?: number): string =>\n resolve(name, FALLBACK_CHANNELS[name][scheme], alpha);\n};\n\n/**\n * Palette for `beautiful-mermaid`'s synchronous renderer.\n *\n * - It derives the rest from `bg` + `fg` via `color-mix()`, so both must be set.\n * - With `transparent`, `bg` only feeds those derivations; `surface` pins the node fill.\n */\nexport const fastRenderOptions = (\n scheme: ResolvedColorScheme,\n from?: Element | null,\n): RenderOptions => {\n const token = tokenReader(scheme, from);\n\n return {\n bg: token('card'),\n fg: token('foreground'),\n line: token('border'),\n accent: token('primary'),\n muted: token('muted-foreground'),\n surface: token('muted'),\n border: token('border'),\n transparent: true,\n font: DIAGRAM_FONT,\n };\n};\n\n/**\n * Config for the async `mermaid` renderer (unparseable dialects and icon diagrams).\n *\n * - `base` theme, so every colour comes from `themeVariables`.\n * - Status tokens are text colours, so fills use a low-alpha tint (brand-neutrality contract).\n */\nexport const mermaidConfig = (\n scheme: ResolvedColorScheme,\n from?: Element | null,\n): MermaidConfig => {\n const token = tokenReader(scheme, from);\n\n const surface = token('accent');\n const onSurface = token('accent-foreground');\n const container = token('card');\n const onContainer = token('card-foreground');\n const line = token('border');\n const stroke = token('primary');\n const text = token('foreground');\n\n return {\n startOnLoad: false,\n securityLevel: 'strict',\n theme: 'base',\n themeVariables: {\n darkMode: scheme === 'dark',\n background: container,\n primaryColor: surface,\n primaryTextColor: onSurface,\n primaryBorderColor: stroke,\n secondaryColor: container,\n secondaryTextColor: onContainer,\n secondaryBorderColor: line,\n tertiaryColor: token('warning', 0.15),\n tertiaryTextColor: token('warning'),\n tertiaryBorderColor: token('warning'),\n lineColor: line,\n textColor: text,\n mainBkg: surface,\n nodeBorder: stroke,\n clusterBkg: container,\n clusterBorder: line,\n titleColor: text,\n edgeLabelBackground: container,\n nodeTextColor: onSurface,\n actorBorder: stroke,\n actorBkg: surface,\n actorTextColor: onSurface,\n actorLineColor: line,\n signalColor: text,\n signalTextColor: text,\n labelBoxBkgColor: surface,\n labelBoxBorderColor: stroke,\n labelTextColor: onSurface,\n loopTextColor: text,\n noteBorderColor: token('warning'),\n noteBkgColor: token('warning', 0.15),\n noteTextColor: text,\n sectionBkgColor: surface,\n altSectionBkgColor: container,\n sectionBkgColor2: token('muted'),\n taskBorderColor: stroke,\n taskBkgColor: surface,\n taskTextColor: onSurface,\n taskTextDarkColor: text,\n taskTextLightColor: text,\n activeTaskBorderColor: stroke,\n activeTaskBkgColor: token('primary', 0.25),\n doneTaskBorderColor: token('success'),\n doneTaskBkgColor: token('success', 0.15),\n critBorderColor: token('destructive'),\n critBkgColor: token('destructive', 0.15),\n fontFamily: DIAGRAM_FONT,\n fontSize: '14px',\n },\n };\n};\n","import { useEffect, useId, useRef, useState } from 'react';\nimport type { ReactNode } from 'react';\nimport { renderMermaidSVG } from 'beautiful-mermaid';\nimport type mermaid from 'mermaid';\n\nimport type { ResolvedColorScheme } from '../../components/ThemeProvider/types';\nimport { useThemeAttributes } from '../../components/ThemeProvider/useThemeAttributes';\nimport { ZoomableSvg } from '../../components/ZoomableSvg';\nimport { DiagramSkeleton } from '../DiagramShared/DiagramSkeleton';\nimport { DiagramSource } from '../DiagramShared/DiagramSource';\nimport {\n flattenForeignObjectLabels,\n hasDrawnContent,\n makeResponsive,\n} from '../DiagramShared/svgTransforms';\n\nimport { fastRenderOptions, mermaidConfig } from './mermaidTheme';\n\ntype MermaidModule = { default: typeof mermaid };\n\nlet mermaidPromise: Promise<MermaidModule> | null = null;\n\n// Makes `lucide:name` icon refs render; the pack is a lazy local chunk, so no CDN fetch and it works under strict CSP.\nconst registerLucideIconPack = (m: typeof mermaid): void => {\n m.registerIconPacks([\n {\n name: 'lucide',\n loader: () => import('@iconify-json/lucide/icons.json').then((mod) => mod.default),\n },\n ]);\n};\n\nconst getMermaid = (): Promise<MermaidModule> => {\n if (!mermaidPromise) {\n mermaidPromise = import('mermaid')\n .then((m) => {\n registerLucideIconPack(m.default);\n return m;\n })\n .catch((err) => {\n mermaidPromise = null;\n throw err;\n });\n }\n return mermaidPromise;\n};\n\nconst stripFontImports = (svg: string): string =>\n svg.replace(/@import\\s+url\\([^)]*fonts\\.googleapis\\.com[^)]*\\);?\\s*/g, '');\n\n// The fast renderer has no icon packs, so icon syntax takes the async path. Matches:\n// - `@{ icon: \"pack:name\" }`\n// - `icon|service|group <id>(pack:name)`, id optional\n// - FontAwesome `fa:fa-*` / `fab:` in node text\nconst hasIconSyntax = (code: string): boolean =>\n /@\\{[^}]*\\bicon\\s*:/.test(code) ||\n /\\b(?:icon|service|group)\\b[^\\n(]*\\(\\s*[\\w-]+:/.test(code) ||\n /\\bfa[bslr]?:fa-/.test(code);\n\nconst tryFastRender = (\n code: string,\n scheme: ResolvedColorScheme,\n from: Element | null,\n): string | null => {\n if (hasIconSyntax(code)) return null;\n try {\n const svg = stripFontImports(renderMermaidSVG(code, fastRenderOptions(scheme, from)));\n // A zero-sized result is a silent layout failure — fall back instead of caching it.\n return hasDrawnContent(svg) ? svg : null;\n } catch (err) {\n // Unsupported dialects are expected here; debug level keeps the console quiet.\n console.debug('[MermaidDiagram] fast render unavailable, using async fallback:', err);\n return null;\n }\n};\n\n/**\n * Whether a mermaid parse error means \"ran out of input\" rather than \"bad syntax\".\n *\n * - Jison parsers report end of input as token `1`, as in every streaming frame.\n * - Lower bound only: some truncations hit a real token and show as `<pre>` for one frame.\n */\nconst isTruncatedDiagram = (err: unknown): boolean =>\n typeof err === 'object' && err !== null && 'hash' in err\n ? (err as { hash?: { token?: unknown } }).hash?.token === 1\n : false;\n\nconst RENDER_DEBOUNCE_MS = 300;\n\n// Longer than the gap between streamed chunks, short enough for an abandoned stream.\nconst TRUNCATION_GRACE_MS = 2_000;\n\n// Survives remounts. Colours are baked into the SVG, so the key includes the theme key.\nconst svgCache = new Map<string, string>();\n\nconst diagramCacheKey = (code: string, themeKey: string): string => `${themeKey}\\n${code}`;\n\n// Cache hit or fast render; null means the caller takes the async render.\nconst resolveSyncSvg = (\n code: string,\n cacheKey: string,\n scheme: ResolvedColorScheme,\n from: Element | null,\n): string | null => {\n const cached = svgCache.get(cacheKey);\n if (cached) return cached;\n const fast = tryFastRender(code, scheme, from);\n if (fast) svgCache.set(cacheKey, fast);\n return fast;\n};\n\ntype Props = {\n /** Mermaid source. Gantt time-only `dateFormat HH:mm` is unsupported — use\n * `dateFormat YYYY-MM-DD HH:mm` with `axisFormat %H:%M`. */\n code: string;\n /** Extra toolbar controls forwarded to `ZoomableSvg`; receives the sanitized SVG. */\n renderActions?: (safeSvg: string) => ReactNode;\n};\n\nexport const MermaidDiagram = ({ code, renderActions }: Props) => {\n const id = useId();\n // - Scheme and key come from one read, so a palette is never cached under the wrong scheme.\n // - `scope` is the element tokens are read off (`null` = `<html>`) and is part of `themeKey`.\n const { scheme, cacheKey: themeKey, scope } = useThemeAttributes();\n const cacheKey = diagramCacheKey(code, themeKey);\n\n const [svg, setSvg] = useState<string | null>(() =>\n resolveSyncSvg(code, cacheKey, scheme, scope),\n );\n const [renderFailed, setRenderFailed] = useState(false);\n const [truncated, setTruncated] = useState(false);\n const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const renderIdRef = useRef(0);\n\n // Render-phase reset avoids a one-frame flash of the previous diagram.\n const [prevKey, setPrevKey] = useState(cacheKey);\n if (cacheKey !== prevKey) {\n setPrevKey(cacheKey);\n setSvg(resolveSyncSvg(code, cacheKey, scheme, scope));\n setRenderFailed(false);\n setTruncated(false);\n }\n\n useEffect(() => {\n // Sync results are already applied by the initializer and the render-phase reset.\n if (svgCache.has(cacheKey)) return;\n\n const currentRenderId = ++renderIdRef.current;\n\n if (debounceRef.current) {\n clearTimeout(debounceRef.current);\n }\n\n debounceRef.current = setTimeout(() => {\n getMermaid()\n .then(async (mermaidModule) => {\n if (renderIdRef.current !== currentRenderId) return;\n const rendererId = `mermaid-${id.replaceAll(':', '')}`;\n const container = document.createElement('div');\n container.style.visibility = 'hidden';\n container.style.position = 'absolute';\n container.style.top = '-9999px';\n container.style.width = '900px';\n document.body.appendChild(container);\n // Per render: `initialize` is the only way to change mermaid's palette.\n mermaidModule.default.initialize(mermaidConfig(scheme, scope));\n try {\n const result = await mermaidModule.default.render(rendererId, code, container);\n if (renderIdRef.current === currentRenderId && result) {\n const svgOutput = flattenForeignObjectLabels(result.svg);\n svgCache.set(cacheKey, svgOutput);\n setSvg(svgOutput);\n setRenderFailed(false);\n setTruncated(false);\n }\n } finally {\n container.remove();\n }\n })\n .catch((err: unknown) => {\n if (renderIdRef.current !== currentRenderId) return;\n setSvg(null);\n // A streaming diagram is truncated at almost every frame — keep the skeleton, not `<pre>`.\n if (isTruncatedDiagram(err)) {\n console.debug('[MermaidDiagram] incomplete diagram, awaiting more input:', err);\n setTruncated(true);\n return;\n }\n console.error('[MermaidDiagram] fallback failed:', err);\n setRenderFailed(true);\n });\n }, RENDER_DEBOUNCE_MS);\n\n const timer = debounceRef.current;\n const renderId = renderIdRef;\n return () => {\n renderId.current++;\n if (timer) {\n clearTimeout(timer);\n }\n };\n }, [cacheKey, code, id, scheme, scope]);\n\n // A truncated diagram may never get another chunk, so fall back to source after a grace period.\n // A new chunk resets `truncated` and clears the timer.\n useEffect(() => {\n if (!truncated) return;\n const timer = setTimeout(() => setRenderFailed(true), TRUNCATION_GRACE_MS);\n return () => clearTimeout(timer);\n }, [truncated, cacheKey]);\n\n const processedSvg = svg ? makeResponsive(svg) : null;\n\n if (renderFailed) {\n return <DiagramSource code={code} />;\n }\n\n if (processedSvg) {\n return (\n <ZoomableSvg\n key={code}\n html={processedSvg}\n copyText={`\\`\\`\\`mermaid\\n${code}\\n\\`\\`\\``}\n className=\"tw:my-3\"\n allowForeignObject\n renderActions={renderActions}\n />\n );\n }\n\n return <DiagramSkeleton />;\n};\n"],"mappings":";;;;;;;;;;;AAMA,MAAM,eAAe;;;;;;AAOrB,MAAM,oBAAoB;CACxB,MAAM;EAAE,OAAO;EAAe,MAAM;CAAW;CAC/C,mBAAmB;EAAE,OAAO;EAAY,MAAM;CAAc;CAC5D,YAAY;EAAE,OAAO;EAAY,MAAM;CAAc;CACrD,OAAO;EAAE,OAAO;EAAe,MAAM;CAAW;CAChD,oBAAoB;EAAE,OAAO;EAAe,MAAM;CAAc;CAChE,QAAQ;EAAE,OAAO;EAAe,MAAM;CAAW;CACjD,SAAS;EAAE,OAAO;EAAa,MAAM;CAAa;CAClD,QAAQ;EAAE,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G,mBAAmB;EACzE,aAAa,aAAa,KAAK;CACjC,GAAG,CAAC,WAAW,QAAQ,CAAC;CAExB,MAAM,eAAe,MAAM,eAAe,GAAG,IAAI;CAEjD,IAAI,cACF,OAAO,oBAAC,eAAD,EAAqB,KAAO,CAAA;CAGrC,IAAI,cACF,OACE,oBAAC,aAAD;EAEE,MAAM;EACN,UAAU,kBAAkB,KAAK;EACjC,WAAU;EACV,oBAAA;EACe;CAChB,GANM,IAMN;CAIL,OAAO,oBAAC,iBAAD,CAAkB,CAAA;AAC3B"}
|
|
1
|
+
{"version":3,"file":"MermaidDiagram-B30x2yV7.js","names":[],"sources":["../src/blocks/MermaidDiagram/mermaidTheme.ts","../src/blocks/MermaidDiagram/MermaidDiagram.tsx"],"sourcesContent":["import type { RenderOptions } from 'beautiful-mermaid';\nimport type { MermaidConfig } from 'mermaid';\n\nimport type { ResolvedColorScheme } from '../../components/ThemeProvider/types';\nimport { createTokenResolver } from '../../utils/themeTokens';\n\nconst DIAGRAM_FONT = 'Inter, system-ui, sans-serif';\n\n/**\n * Token fallbacks; keep in sync with the `:root` / `[data-theme='dark']` blocks of `styles.css`.\n *\n * - Used only when the live custom property is missing (SSR, tests without CSS).\n */\nconst FALLBACK_CHANNELS = {\n card: { light: '255 255 255', dark: '34 34 40' },\n 'card-foreground': { light: '30 41 59', dark: '229 230 236' },\n foreground: { light: '30 41 59', dark: '229 230 236' },\n muted: { light: '241 245 249', dark: '38 38 45' },\n 'muted-foreground': { light: '100 116 139', dark: '141 144 153' },\n border: { light: '229 231 235', dark: '52 53 62' },\n primary: { light: '37 99 235', dark: '31 143 255' },\n accent: { light: '224 242 254', dark: '30 58 95' },\n 'accent-foreground': { light: '13 65 127', dark: '147 197 253' },\n warning: { light: '138 82 16', dark: '255 190 92' },\n success: { light: '24 122 76', dark: '62 207 127' },\n destructive: { light: '220 38 38', dark: '229 72 77' },\n} as const;\n\ntype TokenName = keyof typeof FALLBACK_CHANNELS;\n\n/** One `getComputedStyle` snapshot per palette; never hoist — values follow scheme and brand. */\nconst tokenReader = (scheme: ResolvedColorScheme, from?: Element | null) => {\n const resolve = createTokenResolver(from);\n return (name: TokenName, alpha?: number): string =>\n resolve(name, FALLBACK_CHANNELS[name][scheme], alpha);\n};\n\n/**\n * Palette for `beautiful-mermaid`'s synchronous renderer.\n *\n * - It derives the rest from `bg` + `fg` via `color-mix()`, so both must be set.\n * - With `transparent`, `bg` only feeds those derivations; `surface` pins the node fill.\n */\nexport const fastRenderOptions = (\n scheme: ResolvedColorScheme,\n from?: Element | null,\n): RenderOptions => {\n const token = tokenReader(scheme, from);\n\n return {\n bg: token('card'),\n fg: token('foreground'),\n line: token('border'),\n accent: token('primary'),\n muted: token('muted-foreground'),\n surface: token('muted'),\n border: token('border'),\n transparent: true,\n font: DIAGRAM_FONT,\n };\n};\n\n/**\n * Config for the async `mermaid` renderer (unparseable dialects and icon diagrams).\n *\n * - `base` theme, so every colour comes from `themeVariables`.\n * - Status tokens are text colours, so fills use a low-alpha tint (brand-neutrality contract).\n */\nexport const mermaidConfig = (\n scheme: ResolvedColorScheme,\n from?: Element | null,\n): MermaidConfig => {\n const token = tokenReader(scheme, from);\n\n const surface = token('accent');\n const onSurface = token('accent-foreground');\n const container = token('card');\n const onContainer = token('card-foreground');\n const line = token('border');\n const stroke = token('primary');\n const text = token('foreground');\n\n return {\n startOnLoad: false,\n securityLevel: 'strict',\n theme: 'base',\n themeVariables: {\n darkMode: scheme === 'dark',\n background: container,\n primaryColor: surface,\n primaryTextColor: onSurface,\n primaryBorderColor: stroke,\n secondaryColor: container,\n secondaryTextColor: onContainer,\n secondaryBorderColor: line,\n tertiaryColor: token('warning', 0.15),\n tertiaryTextColor: token('warning'),\n tertiaryBorderColor: token('warning'),\n lineColor: line,\n textColor: text,\n mainBkg: surface,\n nodeBorder: stroke,\n clusterBkg: container,\n clusterBorder: line,\n titleColor: text,\n edgeLabelBackground: container,\n nodeTextColor: onSurface,\n actorBorder: stroke,\n actorBkg: surface,\n actorTextColor: onSurface,\n actorLineColor: line,\n signalColor: text,\n signalTextColor: text,\n labelBoxBkgColor: surface,\n labelBoxBorderColor: stroke,\n labelTextColor: onSurface,\n loopTextColor: text,\n noteBorderColor: token('warning'),\n noteBkgColor: token('warning', 0.15),\n noteTextColor: text,\n sectionBkgColor: surface,\n altSectionBkgColor: container,\n sectionBkgColor2: token('muted'),\n taskBorderColor: stroke,\n taskBkgColor: surface,\n taskTextColor: onSurface,\n taskTextDarkColor: text,\n taskTextLightColor: text,\n activeTaskBorderColor: stroke,\n activeTaskBkgColor: token('primary', 0.25),\n doneTaskBorderColor: token('success'),\n doneTaskBkgColor: token('success', 0.15),\n critBorderColor: token('destructive'),\n critBkgColor: token('destructive', 0.15),\n fontFamily: DIAGRAM_FONT,\n fontSize: '14px',\n },\n };\n};\n","import { useEffect, useId, useRef, useState } from 'react';\nimport type { ReactNode } from 'react';\nimport { renderMermaidSVG } from 'beautiful-mermaid';\nimport type mermaid from 'mermaid';\n\nimport type { ResolvedColorScheme } from '../../components/ThemeProvider/types';\nimport { useThemeAttributes } from '../../components/ThemeProvider/useThemeAttributes';\nimport { ZoomableSvg } from '../../components/ZoomableSvg';\nimport { DiagramSkeleton } from '../DiagramShared/DiagramSkeleton';\nimport { DiagramSource } from '../DiagramShared/DiagramSource';\nimport {\n flattenForeignObjectLabels,\n hasDrawnContent,\n makeResponsive,\n} from '../DiagramShared/svgTransforms';\n\nimport { fastRenderOptions, mermaidConfig } from './mermaidTheme';\n\ntype MermaidModule = { default: typeof mermaid };\n\nlet mermaidPromise: Promise<MermaidModule> | null = null;\n\n// Makes `lucide:name` icon refs render; the pack is a lazy local chunk, so no CDN fetch and it works under strict CSP.\nconst registerLucideIconPack = (m: typeof mermaid): void => {\n m.registerIconPacks([\n {\n name: 'lucide',\n loader: () => import('@iconify-json/lucide/icons.json').then((mod) => mod.default),\n },\n ]);\n};\n\nconst getMermaid = (): Promise<MermaidModule> => {\n if (!mermaidPromise) {\n mermaidPromise = import('mermaid')\n .then((m) => {\n registerLucideIconPack(m.default);\n return m;\n })\n .catch((err) => {\n mermaidPromise = null;\n throw err;\n });\n }\n return mermaidPromise;\n};\n\nconst stripFontImports = (svg: string): string =>\n svg.replace(/@import\\s+url\\([^)]*fonts\\.googleapis\\.com[^)]*\\);?\\s*/g, '');\n\n// The fast renderer has no icon packs, so icon syntax takes the async path. Matches:\n// - `@{ icon: \"pack:name\" }`\n// - `icon|service|group <id>(pack:name)`, id optional\n// - FontAwesome `fa:fa-*` / `fab:` in node text\nconst hasIconSyntax = (code: string): boolean =>\n /@\\{[^}]*\\bicon\\s*:/.test(code) ||\n /\\b(?:icon|service|group)\\b[^\\n(]*\\(\\s*[\\w-]+:/.test(code) ||\n /\\bfa[bslr]?:fa-/.test(code);\n\nconst tryFastRender = (\n code: string,\n scheme: ResolvedColorScheme,\n from: Element | null,\n): string | null => {\n if (hasIconSyntax(code)) return null;\n try {\n const svg = stripFontImports(renderMermaidSVG(code, fastRenderOptions(scheme, from)));\n // A zero-sized result is a silent layout failure — fall back instead of caching it.\n return hasDrawnContent(svg) ? svg : null;\n } catch (err) {\n // Unsupported dialects are expected here; debug level keeps the console quiet.\n console.debug('[MermaidDiagram] fast render unavailable, using async fallback:', err);\n return null;\n }\n};\n\n/**\n * Whether a mermaid parse error means \"ran out of input\" rather than \"bad syntax\".\n *\n * - Jison parsers report end of input as token `1`, as in every streaming frame.\n * - Lower bound only: some truncations hit a real token and show as `<pre>` for one frame.\n */\nconst isTruncatedDiagram = (err: unknown): boolean =>\n typeof err === 'object' && err !== null && 'hash' in err\n ? (err as { hash?: { token?: unknown } }).hash?.token === 1\n : false;\n\nconst RENDER_DEBOUNCE_MS = 300;\n\n// Longer than the gap between streamed chunks, short enough for an abandoned stream.\nconst TRUNCATION_GRACE_MS = 2_000;\n\n// Survives remounts. Colours are baked into the SVG, so the key includes the theme key.\nconst svgCache = new Map<string, string>();\n\nconst diagramCacheKey = (code: string, themeKey: string): string => `${themeKey}\\n${code}`;\n\n// Cache hit or fast render; null means the caller takes the async render.\nconst resolveSyncSvg = (\n code: string,\n cacheKey: string,\n scheme: ResolvedColorScheme,\n from: Element | null,\n): string | null => {\n const cached = svgCache.get(cacheKey);\n if (cached) return cached;\n const fast = tryFastRender(code, scheme, from);\n if (fast) svgCache.set(cacheKey, fast);\n return fast;\n};\n\ntype Props = {\n /** Mermaid source. Gantt time-only `dateFormat HH:mm` is unsupported — use\n * `dateFormat YYYY-MM-DD HH:mm` with `axisFormat %H:%M`. */\n code: string;\n /** Extra toolbar controls forwarded to `ZoomableSvg`; receives the sanitized SVG. */\n renderActions?: (safeSvg: string) => ReactNode;\n};\n\nexport const MermaidDiagram = ({ code, renderActions }: Props) => {\n const id = useId();\n // - Scheme and key come from one read, so a palette is never cached under the wrong scheme.\n // - `scope` is the element tokens are read off (`null` = `<html>`) and is part of `themeKey`.\n const { scheme, cacheKey: themeKey, scope } = useThemeAttributes();\n const cacheKey = diagramCacheKey(code, themeKey);\n\n const [svg, setSvg] = useState<string | null>(() =>\n resolveSyncSvg(code, cacheKey, scheme, scope),\n );\n const [renderFailed, setRenderFailed] = useState(false);\n const [truncated, setTruncated] = useState(false);\n const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const renderIdRef = useRef(0);\n\n // Render-phase reset avoids a one-frame flash of the previous diagram.\n const [prevKey, setPrevKey] = useState(cacheKey);\n if (cacheKey !== prevKey) {\n setPrevKey(cacheKey);\n setSvg(resolveSyncSvg(code, cacheKey, scheme, scope));\n setRenderFailed(false);\n setTruncated(false);\n }\n\n useEffect(() => {\n // Sync results are already applied by the initializer and the render-phase reset.\n if (svgCache.has(cacheKey)) return;\n\n const currentRenderId = ++renderIdRef.current;\n\n if (debounceRef.current) {\n clearTimeout(debounceRef.current);\n }\n\n debounceRef.current = setTimeout(() => {\n getMermaid()\n .then(async (mermaidModule) => {\n if (renderIdRef.current !== currentRenderId) return;\n const rendererId = `mermaid-${id.replaceAll(':', '')}`;\n const container = document.createElement('div');\n container.style.visibility = 'hidden';\n container.style.position = 'absolute';\n container.style.top = '-9999px';\n container.style.width = '900px';\n document.body.appendChild(container);\n // Per render: `initialize` is the only way to change mermaid's palette.\n mermaidModule.default.initialize(mermaidConfig(scheme, scope));\n try {\n const result = await mermaidModule.default.render(rendererId, code, container);\n if (renderIdRef.current === currentRenderId && result) {\n const svgOutput = flattenForeignObjectLabels(result.svg);\n svgCache.set(cacheKey, svgOutput);\n setSvg(svgOutput);\n setRenderFailed(false);\n setTruncated(false);\n }\n } finally {\n container.remove();\n }\n })\n .catch((err: unknown) => {\n if (renderIdRef.current !== currentRenderId) return;\n setSvg(null);\n // A streaming diagram is truncated at almost every frame — keep the skeleton, not `<pre>`.\n if (isTruncatedDiagram(err)) {\n console.debug('[MermaidDiagram] incomplete diagram, awaiting more input:', err);\n setTruncated(true);\n return;\n }\n console.error('[MermaidDiagram] fallback failed:', err);\n setRenderFailed(true);\n });\n }, RENDER_DEBOUNCE_MS);\n\n const timer = debounceRef.current;\n const renderId = renderIdRef;\n return () => {\n renderId.current++;\n if (timer) {\n clearTimeout(timer);\n }\n };\n }, [cacheKey, code, id, scheme, scope]);\n\n // A truncated diagram may never get another chunk, so fall back to source after a grace period.\n // A new chunk resets `truncated` and clears the timer.\n useEffect(() => {\n if (!truncated) return;\n const timer = setTimeout(() => setRenderFailed(true), TRUNCATION_GRACE_MS);\n return () => clearTimeout(timer);\n }, [truncated, cacheKey]);\n\n const processedSvg = svg ? makeResponsive(svg) : null;\n\n if (renderFailed) {\n return <DiagramSource code={code} />;\n }\n\n if (processedSvg) {\n return (\n <ZoomableSvg\n key={code}\n html={processedSvg}\n copyText={`\\`\\`\\`mermaid\\n${code}\\n\\`\\`\\``}\n className=\"tw:my-3\"\n allowForeignObject\n renderActions={renderActions}\n />\n );\n }\n\n return <DiagramSkeleton />;\n};\n"],"mappings":";;;;;;;;;;;AAMA,MAAM,eAAe;;;;;;AAOrB,MAAM,oBAAoB;CACxB,MAAM;EAAE,OAAO;EA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AAG;IACtD,gBAAgB,IAAI;GACtB,CAAC;EACL,GAAG,kBAAkB;EAErB,MAAM,QAAQ,YAAY;EAC1B,MAAM,WAAW;EACjB,aAAa;GACX,SAAS;GACT,IAAI,OACF,aAAa,KAAK;EAEtB;CACF,GAAG;EAAC;EAAU;EAAM;EAAI;EAAQ;CAAK,CAAC;CAItC,gBAAgB;EACd,IAAI,CAAC,WAAW;EAChB,MAAM,QAAQ,iBAAiB,gBAAgB,IAAI,GAAG,mBAAmB;EACzE,aAAa,aAAa,KAAK;CACjC,GAAG,CAAC,WAAW,QAAQ,CAAC;CAExB,MAAM,eAAe,MAAM,eAAe,GAAG,IAAI;CAEjD,IAAI,cACF,OAAO,oBAAC,eAAD,EAAqB,KAAO,CAAA;CAGrC,IAAI,cACF,OACE,oBAAC,aAAD;EAEE,MAAM;EACN,UAAU,kBAAkB,KAAK;EACjC,WAAU;EACV,oBAAA;EACe;CAChB,GANM,IAMN;CAIL,OAAO,oBAAC,iBAAD,CAAkB,CAAA;AAC3B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cn } from "./classNames-BzrkDnOD.js";
|
|
2
2
|
import { useArgoDesign } from "./context-U293r3v-.js";
|
|
3
3
|
import { X } from "./icons-wcA70iQx.js";
|
|
4
|
-
import { Button } from "./Button-
|
|
4
|
+
import { Button } from "./Button-B21oVcPU.js";
|
|
5
5
|
import { ModalDescription, ModalOverlay, ModalTitle } from "./ModalTitle-BxopkIoQ.js";
|
|
6
6
|
import { Separator } from "./internal/components/Separator.js";
|
|
7
7
|
import { useEffect, useState } from "react";
|
|
@@ -177,4 +177,4 @@ Modal.Overlay = ModalOverlay;
|
|
|
177
177
|
//#endregion
|
|
178
178
|
export { Modal };
|
|
179
179
|
|
|
180
|
-
//# sourceMappingURL=Modal-
|
|
180
|
+
//# sourceMappingURL=Modal-BkSuS9Yz.js.map
|