@lattice-php/lattice 0.40.0 → 0.41.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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/provider-base.js +1 -1
- package/dist/provider-base.js.map +1 -1
- package/dist/registry.js +1 -1
- package/dist/registry.js.map +1 -1
- package/dist/runtime.d.ts +11 -3
- package/dist/runtime.js +12 -3
- package/dist/types/core-augmentation.d.ts +2 -1
- package/dist/vite.js +2 -0
- package/dist/vite.js.map +1 -1
- package/dist-standalone/chunks/chart-view-DghsYabe.js +59 -0
- package/dist-standalone/chunks/format-context-DCYPeoEM.js +1 -0
- package/dist-standalone/chunks/{rich-editor-field-n-mtzlT-.js → rich-editor-field-DnkT5hlA.js} +40 -40
- package/dist-standalone/chunks/runtime-zkYqbYk4.js +27 -0
- package/dist-standalone/chunks/{icon-button-COE_nq4v.js → toolbar-button-BmtWFTk1.js} +1 -1
- package/dist-standalone/lattice.css +1 -1
- package/dist-standalone/lattice.js +1 -1
- package/dist-standalone/manifest.json +1 -1
- package/dist-standalone/react-dom.js +1 -0
- package/dist-standalone/runtime.js +1 -1
- package/package.json +8 -16
- package/dist/_virtual/_rolldown/runtime.js +0 -27
- package/dist/action/components/action-form.d.ts +0 -1
- package/dist/action/components/action-form.js +0 -10
- package/dist/action/components/action-form.js.map +0 -1
- package/dist/action/components/action-group.d.ts +0 -3
- package/dist/action/components/action-group.js +0 -51
- package/dist/action/components/action-group.js.map +0 -1
- package/dist/action/components/action-trigger-provider.d.ts +0 -10
- package/dist/action/components/action-trigger-provider.js +0 -24
- package/dist/action/components/action-trigger-provider.js.map +0 -1
- package/dist/action/components/action.d.ts +0 -3
- package/dist/action/components/action.js +0 -36
- package/dist/action/components/action.js.map +0 -1
- package/dist/action/hooks/use-action.d.ts +0 -18
- package/dist/action/hooks/use-action.js +0 -100
- package/dist/action/hooks/use-action.js.map +0 -1
- package/dist/action/index.d.ts +0 -8
- package/dist/action/index.js +0 -11
- package/dist/action/lib/action-label.d.ts +0 -2
- package/dist/action/lib/action-label.js +0 -9
- package/dist/action/lib/action-label.js.map +0 -1
- package/dist/action/lib/run-action.d.ts +0 -1
- package/dist/action/lib/run-action.js +0 -10
- package/dist/action/lib/run-action.js.map +0 -1
- package/dist/action/plugin.d.ts +0 -2
- package/dist/action/plugin.js +0 -15
- package/dist/action/plugin.js.map +0 -1
- package/dist-standalone/chunks/chart-view-DFSCMDuw.js +0 -59
- package/dist-standalone/chunks/number-DjNO0Pxv.js +0 -1
- package/dist-standalone/chunks/runtime-Bh_GyTCD.js +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lattice-php/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "Server-driven React components for Laravel and Inertia.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Manuel Christlieb <manuel@christlieb.eu>",
|
|
@@ -32,14 +32,6 @@
|
|
|
32
32
|
"import": "./dist/index.js"
|
|
33
33
|
},
|
|
34
34
|
"./css": "./dist/lattice.css",
|
|
35
|
-
"./action": {
|
|
36
|
-
"types": "./dist/action/index.d.ts",
|
|
37
|
-
"import": "./dist/action/index.js"
|
|
38
|
-
},
|
|
39
|
-
"./action/lib/run-action": {
|
|
40
|
-
"types": "./dist/action/lib/run-action.d.ts",
|
|
41
|
-
"import": "./dist/action/lib/run-action.js"
|
|
42
|
-
},
|
|
43
35
|
"./appearance": {
|
|
44
36
|
"types": "./dist/appearance/index.d.ts",
|
|
45
37
|
"import": "./dist/appearance/index.js"
|
|
@@ -121,14 +113,15 @@
|
|
|
121
113
|
"build": "vite build",
|
|
122
114
|
"build:standalone": "vite build --mode standalone",
|
|
123
115
|
"prepack": "npm run build",
|
|
124
|
-
"typecheck": "tsc --noEmit"
|
|
125
|
-
"test": "vitest run"
|
|
116
|
+
"typecheck": "tsc --noEmit"
|
|
126
117
|
},
|
|
127
118
|
"dependencies": {
|
|
128
|
-
"@lattice-php/
|
|
129
|
-
"@lattice-php/
|
|
130
|
-
"@lattice-php/
|
|
131
|
-
"@lattice-php/
|
|
119
|
+
"@lattice-php/action": "0.41.0",
|
|
120
|
+
"@lattice-php/core": "0.41.0",
|
|
121
|
+
"@lattice-php/form": "0.41.0",
|
|
122
|
+
"@lattice-php/table": "0.41.0",
|
|
123
|
+
"@lattice-php/ui": "0.41.0",
|
|
124
|
+
"@lattice-php/vite-svg-sprite": "^0.3.0",
|
|
132
125
|
"@atlaskit/pragmatic-drag-and-drop": "^2.0.1",
|
|
133
126
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^3.0.0",
|
|
134
127
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^2.0.0",
|
|
@@ -140,7 +133,6 @@
|
|
|
140
133
|
"@codemirror/legacy-modes": "^6.5.3",
|
|
141
134
|
"@codemirror/state": "^6.7.1",
|
|
142
135
|
"@codemirror/view": "^6.43.7",
|
|
143
|
-
"@lattice-php/vite-svg-sprite": "^0.3.0",
|
|
144
136
|
"@lezer/highlight": "^1.2.3",
|
|
145
137
|
"@radix-ui/react-toast": "^1.2.16"
|
|
146
138
|
},
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __exportAll = (all, no_symbols) => {
|
|
7
|
-
let target = {};
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
-
return target;
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
17
|
-
key = keys[i];
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
-
get: ((k) => from[k]).bind(null, key),
|
|
20
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return to;
|
|
24
|
-
};
|
|
25
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
26
|
-
//#endregion
|
|
27
|
-
export { __exportAll, __reExport };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@lattice-php/form/action-form';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { __exportAll, __reExport } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
export * from "@lattice-php/form/action-form";
|
|
3
|
-
//#region resources/js/action/components/action-form.tsx
|
|
4
|
-
var action_form_exports = /* @__PURE__ */ __exportAll({});
|
|
5
|
-
import * as import__lattice_php_form_action_form from "@lattice-php/form/action-form";
|
|
6
|
-
__reExport(action_form_exports, import__lattice_php_form_action_form);
|
|
7
|
-
//#endregion
|
|
8
|
-
export { action_form_exports };
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=action-form.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action-form.js","names":[],"sources":["../../../resources/js/action/components/action-form.tsx"],"sourcesContent":["export * from \"@lattice-php/form/action-form\";\n"],"mappings":""}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Icon } from "@lattice-php/ui/icons";
|
|
2
|
-
import { cn } from "@lattice-php/ui/lib/utils";
|
|
3
|
-
import { useT } from "@lattice-php/ui/i18n";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { nodeIdentity } from "@lattice-php/core/test-id";
|
|
6
|
-
import { Button } from "@lattice-php/ui/components/button";
|
|
7
|
-
import { ActionMenuProvider } from "@lattice-php/ui/action-menu-context";
|
|
8
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from "@lattice-php/ui/dropdown-menu";
|
|
9
|
-
//#region resources/js/action/components/action-group.tsx
|
|
10
|
-
var ActionGroupComponent = ({ children, node }) => {
|
|
11
|
-
const { t } = useT("lattice");
|
|
12
|
-
const label = node.props.label ?? t("common.action-group.label", "Actions");
|
|
13
|
-
const orientation = node.props.orientation;
|
|
14
|
-
if (orientation) return /* @__PURE__ */ jsx("div", {
|
|
15
|
-
"aria-label": label,
|
|
16
|
-
className: cn("inline-flex max-w-full gap-1", orientation === "vertical" ? "flex-col items-stretch" : "flex-row flex-wrap items-center"),
|
|
17
|
-
"data-lattice-component": node.id,
|
|
18
|
-
role: "group",
|
|
19
|
-
children
|
|
20
|
-
});
|
|
21
|
-
return /* @__PURE__ */ jsx("div", {
|
|
22
|
-
className: "inline-flex",
|
|
23
|
-
"data-lattice-component": node.id,
|
|
24
|
-
children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
25
|
-
asChild: true,
|
|
26
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
27
|
-
"aria-label": label,
|
|
28
|
-
className: "size-lt-control-sm text-lt-muted-fg shadow-none hover:text-lt-fg",
|
|
29
|
-
"data-test": nodeIdentity(node),
|
|
30
|
-
size: "icon",
|
|
31
|
-
type: "button",
|
|
32
|
-
emphasis: "ghost",
|
|
33
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
34
|
-
name: "more-horizontal",
|
|
35
|
-
"aria-hidden": "true",
|
|
36
|
-
className: "size-lt-icon-md"
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
}), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
40
|
-
align: "end",
|
|
41
|
-
"aria-label": label,
|
|
42
|
-
className: "min-w-44 gap-0.5 p-1.5",
|
|
43
|
-
sideOffset: 8,
|
|
44
|
-
children: /* @__PURE__ */ jsx(ActionMenuProvider, { children })
|
|
45
|
-
})] })
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
//#endregion
|
|
49
|
-
export { ActionGroupComponent as default };
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=action-group.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action-group.js","names":[],"sources":["../../../resources/js/action/components/action-group.tsx"],"sourcesContent":["import { Icon } from \"@lattice-php/ui/icons\";\nimport { Button } from \"@lattice-php/ui/components/button\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from \"@lattice-php/ui/dropdown-menu\";\nimport { nodeIdentity } from \"@lattice-php/core/test-id\";\nimport type { RendererComponent } from \"@lattice-php/core/types\";\nimport { cn } from \"@lattice-php/ui/lib/utils\";\nimport { useT } from \"@lattice-php/ui/i18n\";\nimport { ActionMenuProvider } from \"@lattice-php/ui/action-menu-context\";\n\nconst ActionGroupComponent: RendererComponent<\"action.group\"> = ({ children, node }) => {\n const { t } = useT(\"lattice\");\n const label = node.props.label ?? t(\"common.action-group.label\", \"Actions\");\n const orientation = node.props.orientation;\n\n if (orientation) {\n return (\n <div\n aria-label={label}\n className={cn(\n \"inline-flex max-w-full gap-1\",\n orientation === \"vertical\" ? \"flex-col items-stretch\" : \"flex-row flex-wrap items-center\",\n )}\n data-lattice-component={node.id}\n role=\"group\"\n >\n {children}\n </div>\n );\n }\n\n return (\n <div className=\"inline-flex\" data-lattice-component={node.id}>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n aria-label={label}\n className=\"size-lt-control-sm text-lt-muted-fg shadow-none hover:text-lt-fg\"\n data-test={nodeIdentity(node)}\n size=\"icon\"\n type=\"button\"\n emphasis=\"ghost\"\n >\n <Icon name=\"more-horizontal\" aria-hidden=\"true\" className=\"size-lt-icon-md\" />\n </Button>\n </DropdownMenuTrigger>\n\n <DropdownMenuContent\n align=\"end\"\n aria-label={label}\n className=\"min-w-44 gap-0.5 p-1.5\"\n sideOffset={8}\n >\n <ActionMenuProvider>{children}</ActionMenuProvider>\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n );\n};\n\nexport default ActionGroupComponent;\n"],"mappings":";;;;;;;;;AAaA,IAAM,wBAA2D,EAAE,UAAU,WAAW;CACtF,MAAM,EAAE,MAAM,KAAK,SAAS;CAC5B,MAAM,QAAQ,KAAK,MAAM,SAAS,EAAE,6BAA6B,SAAS;CAC1E,MAAM,cAAc,KAAK,MAAM;CAE/B,IAAI,aACF,OACE,oBAAC,OAAD;EACE,cAAY;EACZ,WAAW,GACT,gCACA,gBAAgB,aAAa,2BAA2B,iCAC1D;EACA,0BAAwB,KAAK;EAC7B,MAAK;EAEJ;CACE,CAAA;CAIT,OACE,oBAAC,OAAD;EAAK,WAAU;EAAc,0BAAwB,KAAK;EACxD,UAAA,qBAAC,cAAD,EAAA,UAAA,CACE,oBAAC,qBAAD;GAAqB,SAAA;GACnB,UAAA,oBAAC,QAAD;IACE,cAAY;IACZ,WAAU;IACV,aAAW,aAAa,IAAI;IAC5B,MAAK;IACL,MAAK;IACL,UAAS;IAET,UAAA,oBAAC,MAAD;KAAM,MAAK;KAAkB,eAAY;KAAO,WAAU;IAAmB,CAAA;GACvE,CAAA;EACW,CAAA,GAErB,oBAAC,qBAAD;GACE,OAAM;GACN,cAAY;GACZ,WAAU;GACV,YAAY;GAEZ,UAAA,oBAAC,oBAAD,EAAqB,SAA6B,CAAA;EAC/B,CAAA,CACT,EAAA,CAAA;CACX,CAAA;AAET"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { Node } from '@lattice-php/core/types';
|
|
3
|
-
import { TriggerState } from '@lattice-php/ui/click-behavior';
|
|
4
|
-
export declare function ActionTrigger({ action, children, }: {
|
|
5
|
-
action: Node<"action" | "action.bulk">;
|
|
6
|
-
children: (trigger: TriggerState) => ReactNode;
|
|
7
|
-
}): import("react").JSX.Element;
|
|
8
|
-
export declare function ActionInteractionProvider({ children }: {
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
}): import("react").JSX.Element;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useAction } from "../hooks/use-action.js";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { ActionTriggerProvider } from "@lattice-php/ui/click-behavior";
|
|
4
|
-
//#region resources/js/action/components/action-trigger-provider.tsx
|
|
5
|
-
function ActionTrigger({ action, children }) {
|
|
6
|
-
const { processing, requestSubmit, overlays } = useAction(action);
|
|
7
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [children({
|
|
8
|
-
onClick: requestSubmit,
|
|
9
|
-
processing
|
|
10
|
-
}), overlays] });
|
|
11
|
-
}
|
|
12
|
-
function ActionInteractionProvider({ children }) {
|
|
13
|
-
return /* @__PURE__ */ jsx(ActionTriggerProvider, {
|
|
14
|
-
render: (props) => /* @__PURE__ */ jsx(ActionTrigger, {
|
|
15
|
-
action: props.action,
|
|
16
|
-
children: props.children
|
|
17
|
-
}),
|
|
18
|
-
children
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { ActionInteractionProvider, ActionTrigger };
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=action-trigger-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action-trigger-provider.js","names":[],"sources":["../../../resources/js/action/components/action-trigger-provider.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { Node } from \"@lattice-php/core/types\";\nimport { ActionTriggerProvider, type TriggerState } from \"@lattice-php/ui/click-behavior\";\nimport { useAction } from \"@lattice-php/lattice/action/hooks/use-action\";\n\nexport function ActionTrigger({\n action,\n children,\n}: {\n action: Node<\"action\" | \"action.bulk\">;\n children: (trigger: TriggerState) => ReactNode;\n}) {\n const { processing, requestSubmit, overlays } = useAction(action);\n\n return (\n <>\n {children({ onClick: requestSubmit, processing })}\n {overlays}\n </>\n );\n}\n\nexport function ActionInteractionProvider({ children }: { children: ReactNode }) {\n return (\n <ActionTriggerProvider\n render={(props) => <ActionTrigger action={props.action}>{props.children}</ActionTrigger>}\n >\n {children}\n </ActionTriggerProvider>\n );\n}\n"],"mappings":";;;;AAKA,SAAgB,cAAc,EAC5B,QACA,YAIC;CACD,MAAM,EAAE,YAAY,eAAe,aAAa,UAAU,MAAM;CAEhE,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,SAAS;EAAE,SAAS;EAAe;CAAW,CAAC,GAC/C,QACD,EAAA,CAAA;AAEN;AAEA,SAAgB,0BAA0B,EAAE,YAAqC;CAC/E,OACE,oBAAC,uBAAD;EACE,SAAS,UAAU,oBAAC,eAAD;GAAe,QAAQ,MAAM;GAAS,UAAA,MAAM;EAAwB,CAAA;EAEtF;CACoB,CAAA;AAE3B"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { actionLabel } from "../lib/action-label.js";
|
|
2
|
-
import { useAction } from "../hooks/use-action.js";
|
|
3
|
-
import { IconRenderer } from "@lattice-php/ui/icons";
|
|
4
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { prefixedTestId } from "@lattice-php/core/test-id";
|
|
6
|
-
import { Button } from "@lattice-php/ui/components/button";
|
|
7
|
-
import { Spinner } from "@lattice-php/ui/spinner";
|
|
8
|
-
import { actionMenuItemClassName, useActionMenu } from "@lattice-php/ui/action-menu-context";
|
|
9
|
-
//#region resources/js/action/components/action.tsx
|
|
10
|
-
var ActionComponent = ({ node }) => {
|
|
11
|
-
const endpoint = node.props.endpoint ?? "";
|
|
12
|
-
const icon = node.props.icon;
|
|
13
|
-
const label = actionLabel(node);
|
|
14
|
-
const isMenuItem = useActionMenu();
|
|
15
|
-
const { variant, emphasis } = node.props;
|
|
16
|
-
const { processing, requestSubmit, overlays } = useAction(node);
|
|
17
|
-
const testId = node.key ?? prefixedTestId("action", node.id);
|
|
18
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Button, {
|
|
19
|
-
className: isMenuItem ? actionMenuItemClassName : void 0,
|
|
20
|
-
"data-lattice-component": node.id,
|
|
21
|
-
"data-test": testId,
|
|
22
|
-
disabled: processing || !endpoint,
|
|
23
|
-
onClick: requestSubmit,
|
|
24
|
-
type: "button",
|
|
25
|
-
emphasis: isMenuItem ? "ghost" : emphasis,
|
|
26
|
-
variant: isMenuItem ? null : variant,
|
|
27
|
-
children: [processing ? /* @__PURE__ */ jsx(Spinner, { className: isMenuItem ? "size-lt-icon-sm" : void 0 }) : icon && /* @__PURE__ */ jsx(IconRenderer, {
|
|
28
|
-
className: isMenuItem ? "size-lt-icon-sm" : "size-lt-icon-md",
|
|
29
|
-
icon
|
|
30
|
-
}), label]
|
|
31
|
-
}), overlays] });
|
|
32
|
-
};
|
|
33
|
-
//#endregion
|
|
34
|
-
export { ActionComponent as default };
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=action.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","names":[],"sources":["../../../resources/js/action/components/action.tsx"],"sourcesContent":["import { Button } from \"@lattice-php/ui/components/button\";\nimport { Spinner } from \"@lattice-php/ui/spinner\";\nimport { prefixedTestId } from \"@lattice-php/core/test-id\";\nimport type { RendererComponent } from \"@lattice-php/core/types\";\nimport { IconRenderer } from \"@lattice-php/ui/icons\";\nimport { actionMenuItemClassName, useActionMenu } from \"@lattice-php/ui/action-menu-context\";\nimport { useAction } from \"@lattice-php/lattice/action/hooks/use-action\";\nimport { actionLabel } from \"@lattice-php/lattice/action/lib/action-label\";\n\nconst ActionComponent: RendererComponent<\"action\"> = ({ node }) => {\n const endpoint = node.props.endpoint ?? \"\";\n const icon = node.props.icon;\n const label = actionLabel(node);\n const isMenuItem = useActionMenu();\n const { variant, emphasis } = node.props;\n const { processing, requestSubmit, overlays } = useAction(node);\n const testId = node.key ?? prefixedTestId(\"action\", node.id);\n\n return (\n <>\n <Button\n className={isMenuItem ? actionMenuItemClassName : undefined}\n data-lattice-component={node.id}\n data-test={testId}\n disabled={processing || !endpoint}\n onClick={requestSubmit}\n type=\"button\"\n emphasis={isMenuItem ? \"ghost\" : emphasis}\n variant={isMenuItem ? null : variant}\n >\n {processing ? (\n <Spinner className={isMenuItem ? \"size-lt-icon-sm\" : undefined} />\n ) : (\n icon && (\n <IconRenderer\n className={isMenuItem ? \"size-lt-icon-sm\" : \"size-lt-icon-md\"}\n icon={icon}\n />\n )\n )}\n {label}\n </Button>\n\n {overlays}\n </>\n );\n};\n\nexport default ActionComponent;\n"],"mappings":";;;;;;;;;AASA,IAAM,mBAAgD,EAAE,WAAW;CACjE,MAAM,WAAW,KAAK,MAAM,YAAY;CACxC,MAAM,OAAO,KAAK,MAAM;CACxB,MAAM,QAAQ,YAAY,IAAI;CAC9B,MAAM,aAAa,cAAc;CACjC,MAAM,EAAE,SAAS,aAAa,KAAK;CACnC,MAAM,EAAE,YAAY,eAAe,aAAa,UAAU,IAAI;CAC9D,MAAM,SAAS,KAAK,OAAO,eAAe,UAAU,KAAK,EAAE;CAE3D,OACE,qBAAA,UAAA,EAAA,UAAA,CACE,qBAAC,QAAD;EACE,WAAW,aAAa,0BAA0B,KAAA;EAClD,0BAAwB,KAAK;EAC7B,aAAW;EACX,UAAU,cAAc,CAAC;EACzB,SAAS;EACT,MAAK;EACL,UAAU,aAAa,UAAU;EACjC,SAAS,aAAa,OAAO;EAR/B,UAAA,CAUG,aACC,oBAAC,SAAD,EAAS,WAAW,aAAa,oBAAoB,KAAA,EAAY,CAAA,IAEjE,QACE,oBAAC,cAAD;GACE,WAAW,aAAa,oBAAoB;GACtC;EACP,CAAA,GAGJ,KACK;CAEP,CAAA,GAAA,QACD,EAAA,CAAA;AAEN"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { Node } from '@lattice-php/core/types';
|
|
3
|
-
type UseAction = {
|
|
4
|
-
/** Whether the action request is in flight. */
|
|
5
|
-
processing: boolean;
|
|
6
|
-
/** Gate then run the action: open the form, confirm, or dispatch directly. */
|
|
7
|
-
requestSubmit: () => void;
|
|
8
|
-
/** The confirm dialog and action form rendered next to the trigger. */
|
|
9
|
-
overlays: ReactNode;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* The shared action machinery behind the Action button, action menu items, and
|
|
13
|
-
* action links: it gates submission (form → modal, confirmation → confirm,
|
|
14
|
-
* otherwise dispatch) and renders the matching overlays. The host owns the
|
|
15
|
-
* trigger element so each surface keeps its own styling.
|
|
16
|
-
*/
|
|
17
|
-
export declare function useAction(node: Node<"action" | "action.bulk">): UseAction;
|
|
18
|
-
export {};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { run_action_exports } from "../lib/run-action.js";
|
|
2
|
-
import { action_form_exports } from "../components/action-form.js";
|
|
3
|
-
import { actionLabel } from "../lib/action-label.js";
|
|
4
|
-
import { router } from "@inertiajs/react";
|
|
5
|
-
import { useState } from "react";
|
|
6
|
-
import { apiFetch } from "@lattice-php/core/api";
|
|
7
|
-
import { withHeaders } from "@lattice-php/core/headers";
|
|
8
|
-
import { translate } from "@lattice-php/ui/i18n";
|
|
9
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { ConfirmDialog } from "@lattice-php/ui/confirm-dialog";
|
|
11
|
-
import { useEffectDispatcher } from "@lattice-php/ui/effects/use-effect-dispatcher";
|
|
12
|
-
//#region resources/js/action/hooks/use-action.tsx
|
|
13
|
-
/**
|
|
14
|
-
* The shared action machinery behind the Action button, action menu items, and
|
|
15
|
-
* action links: it gates submission (form → modal, confirmation → confirm,
|
|
16
|
-
* otherwise dispatch) and renders the matching overlays. The host owns the
|
|
17
|
-
* trigger element so each surface keeps its own styling.
|
|
18
|
-
*/
|
|
19
|
-
function useAction(node) {
|
|
20
|
-
const endpoint = node.props.endpoint ?? "";
|
|
21
|
-
const componentRef = node.props.ref ?? "";
|
|
22
|
-
const method = node.props.method ?? "post";
|
|
23
|
-
const label = actionLabel(node);
|
|
24
|
-
const { variant, emphasis } = node.props;
|
|
25
|
-
const confirmation = node.props.confirmation;
|
|
26
|
-
const inlineForm = node.props.form;
|
|
27
|
-
const lazyForm = node.props.lazyForm === true;
|
|
28
|
-
const hasForm = Boolean(inlineForm) || lazyForm;
|
|
29
|
-
const [processing, setProcessing] = useState(false);
|
|
30
|
-
const dispatch = useEffectDispatcher();
|
|
31
|
-
const [isConfirming, setIsConfirming] = useState(false);
|
|
32
|
-
const [isFilling, setIsFilling] = useState(false);
|
|
33
|
-
const lazyNode = (0, action_form_exports.useLazyActionForm)(endpoint, componentRef, isFilling && lazyForm);
|
|
34
|
-
const formNode = lazyForm ? lazyNode : inlineForm;
|
|
35
|
-
const submit = async () => {
|
|
36
|
-
if (!endpoint) return;
|
|
37
|
-
if (method === "get") {
|
|
38
|
-
router.visit(endpoint, { headers: withHeaders(componentRef) });
|
|
39
|
-
setIsConfirming(false);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
setProcessing(true);
|
|
43
|
-
const ok = await (0, run_action_exports.runAction)(() => apiFetch(endpoint, {
|
|
44
|
-
method,
|
|
45
|
-
ref: componentRef,
|
|
46
|
-
throwOnError: false
|
|
47
|
-
}), dispatch);
|
|
48
|
-
setProcessing(false);
|
|
49
|
-
if (ok) setIsConfirming(false);
|
|
50
|
-
};
|
|
51
|
-
const requestSubmit = () => {
|
|
52
|
-
if (hasForm) {
|
|
53
|
-
setIsFilling(true);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (confirmation) {
|
|
57
|
-
setIsConfirming(true);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
submit();
|
|
61
|
-
};
|
|
62
|
-
const confirmationTitle = confirmation?.title ?? label;
|
|
63
|
-
const confirmationConfirmLabel = confirmation?.confirmLabel ?? label;
|
|
64
|
-
const confirmationCancelLabel = confirmation?.cancelLabel ?? translate("lattice", "common.cancel", "Cancel");
|
|
65
|
-
return {
|
|
66
|
-
processing,
|
|
67
|
-
requestSubmit,
|
|
68
|
-
overlays: /* @__PURE__ */ jsxs(Fragment$1, { children: [isConfirming && confirmation && /* @__PURE__ */ jsx(ConfirmDialog, {
|
|
69
|
-
title: confirmationTitle,
|
|
70
|
-
description: confirmation.description ?? void 0,
|
|
71
|
-
confirmLabel: confirmationConfirmLabel,
|
|
72
|
-
cancelLabel: confirmationCancelLabel,
|
|
73
|
-
confirmVariant: variant,
|
|
74
|
-
confirmEmphasis: emphasis,
|
|
75
|
-
processing,
|
|
76
|
-
confirmDisabled: !endpoint,
|
|
77
|
-
onConfirm: () => void submit(),
|
|
78
|
-
onCancel: () => setIsConfirming(false)
|
|
79
|
-
}), isFilling && hasForm && /* @__PURE__ */ jsx(action_form_exports.ActionForm, {
|
|
80
|
-
cancelLabel: confirmationCancelLabel,
|
|
81
|
-
componentRef,
|
|
82
|
-
description: confirmation?.description ?? void 0,
|
|
83
|
-
endpoint,
|
|
84
|
-
formNode,
|
|
85
|
-
method,
|
|
86
|
-
onClose: () => setIsFilling(false),
|
|
87
|
-
onSuccess: () => {
|
|
88
|
-
setIsFilling(false);
|
|
89
|
-
},
|
|
90
|
-
placement: node.props.modalSide ?? "center",
|
|
91
|
-
submitLabel: confirmationConfirmLabel,
|
|
92
|
-
title: confirmationTitle,
|
|
93
|
-
width: node.props.modalWidth ?? void 0
|
|
94
|
-
})] })
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
export { useAction };
|
|
99
|
-
|
|
100
|
-
//# sourceMappingURL=use-action.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-action.js","names":[],"sources":["../../../resources/js/action/hooks/use-action.tsx"],"sourcesContent":["import { router } from \"@inertiajs/react\";\nimport type { Method } from \"@inertiajs/core\";\nimport { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { ConfirmDialog } from \"@lattice-php/ui/confirm-dialog\";\nimport { apiFetch } from \"@lattice-php/core/api\";\nimport { withHeaders } from \"@lattice-php/core/headers\";\nimport type { Node } from \"@lattice-php/core/types\";\nimport { translate } from \"@lattice-php/ui/i18n\";\nimport { useEffectDispatcher } from \"@lattice-php/ui/effects/use-effect-dispatcher\";\nimport { runAction } from \"@lattice-php/lattice/action/lib/run-action\";\nimport { ActionForm, useLazyActionForm } from \"@lattice-php/lattice/action/components/action-form\";\nimport { actionLabel } from \"@lattice-php/lattice/action/lib/action-label\";\n\ntype UseAction = {\n /** Whether the action request is in flight. */\n processing: boolean;\n /** Gate then run the action: open the form, confirm, or dispatch directly. */\n requestSubmit: () => void;\n /** The confirm dialog and action form rendered next to the trigger. */\n overlays: ReactNode;\n};\n\n/**\n * The shared action machinery behind the Action button, action menu items, and\n * action links: it gates submission (form → modal, confirmation → confirm,\n * otherwise dispatch) and renders the matching overlays. The host owns the\n * trigger element so each surface keeps its own styling.\n */\nexport function useAction(node: Node<\"action\" | \"action.bulk\">): UseAction {\n const endpoint = node.props.endpoint ?? \"\";\n const componentRef = node.props.ref ?? \"\";\n const method: Method = node.props.method ?? \"post\";\n const label = actionLabel(node);\n const { variant, emphasis } = node.props;\n const confirmation = node.props.confirmation;\n const inlineForm = node.props.form;\n const lazyForm = node.props.lazyForm === true;\n const hasForm = Boolean(inlineForm) || lazyForm;\n\n const [processing, setProcessing] = useState(false);\n const dispatch = useEffectDispatcher();\n const [isConfirming, setIsConfirming] = useState(false);\n const [isFilling, setIsFilling] = useState(false);\n const lazyNode = useLazyActionForm(endpoint, componentRef, isFilling && lazyForm);\n const formNode = lazyForm ? lazyNode : inlineForm;\n\n const submit = async (): Promise<void> => {\n if (!endpoint) {\n return;\n }\n\n if (method === \"get\") {\n router.visit(endpoint, { headers: withHeaders(componentRef) });\n setIsConfirming(false);\n\n return;\n }\n\n setProcessing(true);\n\n const ok = await runAction(\n () => apiFetch(endpoint, { method, ref: componentRef, throwOnError: false }),\n dispatch,\n );\n\n setProcessing(false);\n\n if (ok) {\n setIsConfirming(false);\n }\n };\n\n const requestSubmit = (): void => {\n if (hasForm) {\n setIsFilling(true);\n\n return;\n }\n\n if (confirmation) {\n setIsConfirming(true);\n\n return;\n }\n\n void submit();\n };\n\n const confirmationTitle = confirmation?.title ?? label;\n const confirmationConfirmLabel = confirmation?.confirmLabel ?? label;\n const confirmationCancelLabel =\n confirmation?.cancelLabel ?? translate(\"lattice\", \"common.cancel\", \"Cancel\");\n\n const overlays = (\n <>\n {isConfirming && confirmation && (\n <ConfirmDialog\n title={confirmationTitle}\n description={confirmation.description ?? undefined}\n confirmLabel={confirmationConfirmLabel}\n cancelLabel={confirmationCancelLabel}\n confirmVariant={variant}\n confirmEmphasis={emphasis}\n processing={processing}\n confirmDisabled={!endpoint}\n onConfirm={() => void submit()}\n onCancel={() => setIsConfirming(false)}\n />\n )}\n\n {isFilling && hasForm && (\n <ActionForm\n cancelLabel={confirmationCancelLabel}\n componentRef={componentRef}\n description={confirmation?.description ?? undefined}\n endpoint={endpoint}\n formNode={formNode}\n method={method}\n onClose={() => setIsFilling(false)}\n onSuccess={() => {\n setIsFilling(false);\n }}\n placement={node.props.modalSide ?? \"center\"}\n submitLabel={confirmationConfirmLabel}\n title={confirmationTitle}\n width={node.props.modalWidth ?? undefined}\n />\n )}\n </>\n );\n\n return { processing, requestSubmit, overlays };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,SAAgB,UAAU,MAAiD;CACzE,MAAM,WAAW,KAAK,MAAM,YAAY;CACxC,MAAM,eAAe,KAAK,MAAM,OAAO;CACvC,MAAM,SAAiB,KAAK,MAAM,UAAU;CAC5C,MAAM,QAAQ,YAAY,IAAI;CAC9B,MAAM,EAAE,SAAS,aAAa,KAAK;CACnC,MAAM,eAAe,KAAK,MAAM;CAChC,MAAM,aAAa,KAAK,MAAM;CAC9B,MAAM,WAAW,KAAK,MAAM,aAAa;CACzC,MAAM,UAAU,QAAQ,UAAU,KAAK;CAEvC,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,WAAW,oBAAoB;CACrC,MAAM,CAAC,cAAc,mBAAmB,SAAS,KAAK;CACtD,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,YAAA,GAAW,oBAAA,kBAAA,CAAkB,UAAU,cAAc,aAAa,QAAQ;CAChF,MAAM,WAAW,WAAW,WAAW;CAEvC,MAAM,SAAS,YAA2B;EACxC,IAAI,CAAC,UACH;EAGF,IAAI,WAAW,OAAO;GACpB,OAAO,MAAM,UAAU,EAAE,SAAS,YAAY,YAAY,EAAE,CAAC;GAC7D,gBAAgB,KAAK;GAErB;EACF;EAEA,cAAc,IAAI;EAElB,MAAM,KAAK,OAAA,GAAM,mBAAA,UAAA,OACT,SAAS,UAAU;GAAE;GAAQ,KAAK;GAAc,cAAc;EAAM,CAAC,GAC3E,QACF;EAEA,cAAc,KAAK;EAEnB,IAAI,IACF,gBAAgB,KAAK;CAEzB;CAEA,MAAM,sBAA4B;EAChC,IAAI,SAAS;GACX,aAAa,IAAI;GAEjB;EACF;EAEA,IAAI,cAAc;GAChB,gBAAgB,IAAI;GAEpB;EACF;EAEA,OAAY;CACd;CAEA,MAAM,oBAAoB,cAAc,SAAS;CACjD,MAAM,2BAA2B,cAAc,gBAAgB;CAC/D,MAAM,0BACJ,cAAc,eAAe,UAAU,WAAW,iBAAiB,QAAQ;CAwC7E,OAAO;EAAE;EAAY;EAAe,UArClC,qBAAA,YAAA,EAAA,UAAA,CACG,gBAAgB,gBACf,oBAAC,eAAD;GACE,OAAO;GACP,aAAa,aAAa,eAAe,KAAA;GACzC,cAAc;GACd,aAAa;GACb,gBAAgB;GAChB,iBAAiB;GACL;GACZ,iBAAiB,CAAC;GAClB,iBAAiB,KAAK,OAAO;GAC7B,gBAAgB,gBAAgB,KAAK;EACtC,CAAA,GAGF,aAAa,WACZ,oBAAC,oBAAA,YAAD;GACE,aAAa;GACC;GACd,aAAa,cAAc,eAAe,KAAA;GAChC;GACA;GACF;GACR,eAAe,aAAa,KAAK;GACjC,iBAAiB;IACf,aAAa,KAAK;GACpB;GACA,WAAW,KAAK,MAAM,aAAa;GACnC,aAAa;GACb,OAAO;GACP,OAAO,KAAK,MAAM,cAAc,KAAA;EACjC,CAAA,CAEH,EAAA,CAGgC;CAAS;AAC/C"}
|
package/dist/action/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { default as ActionComponent } from './components/action.js';
|
|
2
|
-
export { ActionForm } from './components/action-form.js';
|
|
3
|
-
export { default as ActionGroupComponent } from './components/action-group.js';
|
|
4
|
-
export { ActionInteractionProvider, ActionTrigger } from './components/action-trigger-provider.js';
|
|
5
|
-
export { ActionMenuProvider, actionMenuItemClassName, useActionMenu, } from '@lattice-php/ui/action-menu-context';
|
|
6
|
-
export { useAction } from './hooks/use-action.js';
|
|
7
|
-
export { runAction } from './lib/run-action.js';
|
|
8
|
-
export { actionComponents } from './plugin.js';
|
package/dist/action/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { run_action_exports } from "./lib/run-action.js";
|
|
2
|
-
import { action_form_exports } from "./components/action-form.js";
|
|
3
|
-
import { useAction } from "./hooks/use-action.js";
|
|
4
|
-
import { ActionInteractionProvider, ActionTrigger } from "./components/action-trigger-provider.js";
|
|
5
|
-
import ActionComponent from "./components/action.js";
|
|
6
|
-
import ActionGroupComponent from "./components/action-group.js";
|
|
7
|
-
import { actionComponents } from "./plugin.js";
|
|
8
|
-
import { ActionMenuProvider, actionMenuItemClassName, useActionMenu } from "@lattice-php/ui/action-menu-context";
|
|
9
|
-
var ActionForm = action_form_exports.ActionForm;
|
|
10
|
-
var runAction = run_action_exports.runAction;
|
|
11
|
-
export { ActionComponent, ActionForm, ActionGroupComponent, ActionInteractionProvider, ActionMenuProvider, ActionTrigger, actionComponents, actionMenuItemClassName, runAction, useAction, useActionMenu };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { translate } from "@lattice-php/ui/i18n";
|
|
2
|
-
//#region resources/js/action/lib/action-label.ts
|
|
3
|
-
function actionLabel(node) {
|
|
4
|
-
return node.props.label ?? translate("lattice", "common.action.run", "Run action");
|
|
5
|
-
}
|
|
6
|
-
//#endregion
|
|
7
|
-
export { actionLabel };
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=action-label.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action-label.js","names":[],"sources":["../../../resources/js/action/lib/action-label.ts"],"sourcesContent":["import { translate } from \"@lattice-php/ui/i18n\";\nimport type { Node } from \"@lattice-php/core/types\";\n\nexport function actionLabel(node: Node<\"action\" | \"action.bulk\">): string {\n return node.props.label ?? translate(\"lattice\", \"common.action.run\", \"Run action\");\n}\n"],"mappings":";;AAGA,SAAgB,YAAY,MAA8C;CACxE,OAAO,KAAK,MAAM,SAAS,UAAU,WAAW,qBAAqB,YAAY;AACnF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@lattice-php/ui/effects/run-action';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { __exportAll, __reExport } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
export * from "@lattice-php/ui/effects/run-action";
|
|
3
|
-
//#region resources/js/action/lib/run-action.ts
|
|
4
|
-
var run_action_exports = /* @__PURE__ */ __exportAll({});
|
|
5
|
-
import * as import__lattice_php_ui_effects_run_action from "@lattice-php/ui/effects/run-action";
|
|
6
|
-
__reExport(run_action_exports, import__lattice_php_ui_effects_run_action);
|
|
7
|
-
//#endregion
|
|
8
|
-
export { run_action_exports };
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=run-action.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-action.js","names":[],"sources":["../../../resources/js/action/lib/run-action.ts"],"sourcesContent":["export * from \"@lattice-php/ui/effects/run-action\";\n"],"mappings":""}
|
package/dist/action/plugin.d.ts
DELETED
package/dist/action/plugin.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import ActionComponent from "./components/action.js";
|
|
2
|
-
import ActionGroupComponent from "./components/action-group.js";
|
|
3
|
-
import { eagerComponent } from "@lattice-php/core/registry";
|
|
4
|
-
//#region resources/js/action/plugin.ts
|
|
5
|
-
var actionComponents = {
|
|
6
|
-
components: {
|
|
7
|
-
action: eagerComponent(ActionComponent),
|
|
8
|
-
"action.group": eagerComponent(ActionGroupComponent)
|
|
9
|
-
},
|
|
10
|
-
name: "lattice/action"
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
|
-
export { actionComponents };
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","names":[],"sources":["../../resources/js/action/plugin.ts"],"sourcesContent":["import { eagerComponent, type ComponentRegistryFor, type Plugin } from \"@lattice-php/core/registry\";\nimport type { ActionNodeType } from \"@lattice-php/lattice/types/generated\";\nimport ActionComponent from \"./components/action\";\nimport ActionGroupComponent from \"./components/action-group\";\n\ntype ActionComponentType = Exclude<ActionNodeType, \"action.bulk\">;\n\nexport const actionComponents: Plugin = {\n components: {\n action: eagerComponent(ActionComponent),\n \"action.group\": eagerComponent(ActionGroupComponent),\n } satisfies ComponentRegistryFor<ActionComponentType>,\n name: \"lattice/action\",\n};\n"],"mappings":";;;;AAOA,IAAa,mBAA2B;CACtC,YAAY;EACV,QAAQ,eAAe,eAAe;EACtC,gBAAgB,eAAe,oBAAoB;CACrD;CACA,MAAM;AACR"}
|