@open-mercato/ui 0.10.1-develop.8042.1.c981a94bea → 0.10.1-develop.8044.1.a49d478346
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.
|
@@ -43,7 +43,7 @@ function FormActionButtons({
|
|
|
43
43
|
{
|
|
44
44
|
type: "submit",
|
|
45
45
|
form: submit.formId,
|
|
46
|
-
disabled: submit.pending,
|
|
46
|
+
disabled: submit.pending || submit.disabled,
|
|
47
47
|
children: [
|
|
48
48
|
submit.pending ? /* @__PURE__ */ jsx(Loader2, { className: "size-4 mr-2 animate-spin" }) : /* @__PURE__ */ jsx(SubmitIcon, { className: "size-4 mr-2" }),
|
|
49
49
|
submit.pending ? resolvedPendingLabel : resolvedSubmitLabel
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/backend/forms/FormActionButtons.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Trash2, Save, Loader2 } from 'lucide-react'\nimport { Button } from '../../primitives/button'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\nexport type FormActionButtonsProps = {\n /** Extra action buttons rendered before the standard buttons */\n extraActions?: React.ReactNode\n /** Show the delete button */\n showDelete?: boolean\n /** Callback when delete is clicked */\n onDelete?: () => void\n /** Label for the delete button */\n deleteLabel?: string\n /** Whether the delete button shows a loading spinner */\n isDeleting?: boolean\n /** URL for the cancel link */\n cancelHref?: string\n /** Label for the cancel link */\n cancelLabel?: string\n /** Submit button configuration */\n submit?: {\n /** Form ID for the submit button (needed in header to trigger form submit) */\n formId?: string\n /** Whether the form is currently submitting */\n pending?: boolean\n /** Label while idle */\n label?: string\n /** Label while saving */\n pendingLabel?: string\n /** Optional icon for idle submit state */\n icon?: React.ComponentType<{ className?: string }>\n }\n /** When true, hides all buttons */\n hidden?: boolean\n}\n\nexport function FormActionButtons({\n extraActions,\n showDelete,\n onDelete,\n deleteLabel,\n isDeleting,\n cancelHref,\n cancelLabel,\n submit,\n hidden,\n}: FormActionButtonsProps) {\n const t = useT()\n\n if (hidden) return null\n\n const resolvedDeleteLabel = deleteLabel ?? t('ui.forms.actions.delete')\n const resolvedCancelLabel = cancelLabel ?? t('ui.forms.actions.cancel')\n const resolvedSubmitLabel = submit?.label ?? t('ui.forms.actions.save')\n const resolvedPendingLabel = submit?.pendingLabel ?? t('ui.forms.status.saving')\n const SubmitIcon = submit?.icon ?? Save\n\n return (\n <div className=\"flex flex-wrap items-center gap-2\">\n {extraActions}\n {showDelete ? (\n <Button\n type=\"button\"\n variant=\"destructive-outline\"\n onClick={onDelete}\n disabled={isDeleting}\n >\n {isDeleting ? (\n <Loader2 className=\"size-4 mr-2 animate-spin\" />\n ) : (\n <Trash2 className=\"size-4 mr-2\" />\n )}\n {resolvedDeleteLabel}\n </Button>\n ) : null}\n {cancelHref ? (\n <Button asChild variant=\"outline\">\n <Link href={cancelHref}>{resolvedCancelLabel}</Link>\n </Button>\n ) : null}\n {submit ? (\n <Button\n type=\"submit\"\n form={submit.formId}\n disabled={submit.pending}\n >\n {submit.pending ? <Loader2 className=\"size-4 mr-2 animate-spin\" /> : <SubmitIcon className=\"size-4 mr-2\" />}\n {submit.pending ? resolvedPendingLabel : resolvedSubmitLabel}\n </Button>\n ) : null}\n </div>\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Trash2, Save, Loader2 } from 'lucide-react'\nimport { Button } from '../../primitives/button'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\nexport type FormActionButtonsProps = {\n /** Extra action buttons rendered before the standard buttons */\n extraActions?: React.ReactNode\n /** Show the delete button */\n showDelete?: boolean\n /** Callback when delete is clicked */\n onDelete?: () => void\n /** Label for the delete button */\n deleteLabel?: string\n /** Whether the delete button shows a loading spinner */\n isDeleting?: boolean\n /** URL for the cancel link */\n cancelHref?: string\n /** Label for the cancel link */\n cancelLabel?: string\n /** Submit button configuration */\n submit?: {\n /** Form ID for the submit button (needed in header to trigger form submit) */\n formId?: string\n /** Whether the form is currently submitting */\n pending?: boolean\n /** Label while idle */\n label?: string\n /** Label while saving */\n pendingLabel?: string\n /** Optional icon for idle submit state */\n icon?: React.ComponentType<{ className?: string }>\n /** Keeps the submit disabled while the form is not ready (e.g. async field definitions still loading) */\n disabled?: boolean\n }\n /** When true, hides all buttons */\n hidden?: boolean\n}\n\nexport function FormActionButtons({\n extraActions,\n showDelete,\n onDelete,\n deleteLabel,\n isDeleting,\n cancelHref,\n cancelLabel,\n submit,\n hidden,\n}: FormActionButtonsProps) {\n const t = useT()\n\n if (hidden) return null\n\n const resolvedDeleteLabel = deleteLabel ?? t('ui.forms.actions.delete')\n const resolvedCancelLabel = cancelLabel ?? t('ui.forms.actions.cancel')\n const resolvedSubmitLabel = submit?.label ?? t('ui.forms.actions.save')\n const resolvedPendingLabel = submit?.pendingLabel ?? t('ui.forms.status.saving')\n const SubmitIcon = submit?.icon ?? Save\n\n return (\n <div className=\"flex flex-wrap items-center gap-2\">\n {extraActions}\n {showDelete ? (\n <Button\n type=\"button\"\n variant=\"destructive-outline\"\n onClick={onDelete}\n disabled={isDeleting}\n >\n {isDeleting ? (\n <Loader2 className=\"size-4 mr-2 animate-spin\" />\n ) : (\n <Trash2 className=\"size-4 mr-2\" />\n )}\n {resolvedDeleteLabel}\n </Button>\n ) : null}\n {cancelHref ? (\n <Button asChild variant=\"outline\">\n <Link href={cancelHref}>{resolvedCancelLabel}</Link>\n </Button>\n ) : null}\n {submit ? (\n <Button\n type=\"submit\"\n form={submit.formId}\n disabled={submit.pending || submit.disabled}\n >\n {submit.pending ? <Loader2 className=\"size-4 mr-2 animate-spin\" /> : <SubmitIcon className=\"size-4 mr-2\" />}\n {submit.pending ? resolvedPendingLabel : resolvedSubmitLabel}\n </Button>\n ) : null}\n </div>\n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CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/ui",
|
|
3
|
-
"version": "0.10.1-develop.
|
|
3
|
+
"version": "0.10.1-develop.8044.1.a49d478346",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -156,14 +156,14 @@
|
|
|
156
156
|
"remark-gfm": "^4.0.1"
|
|
157
157
|
},
|
|
158
158
|
"peerDependencies": {
|
|
159
|
-
"@open-mercato/shared": "0.10.1-develop.
|
|
159
|
+
"@open-mercato/shared": "0.10.1-develop.8044.1.a49d478346",
|
|
160
160
|
"react": ">=18.0.0",
|
|
161
161
|
"react-dom": ">=18.0.0",
|
|
162
162
|
"react-is": ">=18.0.0"
|
|
163
163
|
},
|
|
164
164
|
"devDependencies": {
|
|
165
165
|
"@figma/code-connect": "^1.3.4",
|
|
166
|
-
"@open-mercato/shared": "0.10.1-develop.
|
|
166
|
+
"@open-mercato/shared": "0.10.1-develop.8044.1.a49d478346",
|
|
167
167
|
"@testing-library/dom": "^10.4.1",
|
|
168
168
|
"@testing-library/jest-dom": "^7.0.1",
|
|
169
169
|
"@testing-library/react": "^16.3.3",
|
|
@@ -33,6 +33,8 @@ export type FormActionButtonsProps = {
|
|
|
33
33
|
pendingLabel?: string
|
|
34
34
|
/** Optional icon for idle submit state */
|
|
35
35
|
icon?: React.ComponentType<{ className?: string }>
|
|
36
|
+
/** Keeps the submit disabled while the form is not ready (e.g. async field definitions still loading) */
|
|
37
|
+
disabled?: boolean
|
|
36
38
|
}
|
|
37
39
|
/** When true, hides all buttons */
|
|
38
40
|
hidden?: boolean
|
|
@@ -86,7 +88,7 @@ export function FormActionButtons({
|
|
|
86
88
|
<Button
|
|
87
89
|
type="submit"
|
|
88
90
|
form={submit.formId}
|
|
89
|
-
disabled={submit.pending}
|
|
91
|
+
disabled={submit.pending || submit.disabled}
|
|
90
92
|
>
|
|
91
93
|
{submit.pending ? <Loader2 className="size-4 mr-2 animate-spin" /> : <SubmitIcon className="size-4 mr-2" />}
|
|
92
94
|
{submit.pending ? resolvedPendingLabel : resolvedSubmitLabel}
|