@plitzi/sdk-variables 0.30.19
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/CHANGELOG.md +1097 -0
- package/dist/VariablesContext.d.ts +2 -0
- package/dist/VariablesContext.mjs +5 -0
- package/dist/VariablesHelper.d.ts +4 -0
- package/dist/VariablesHelper.mjs +41 -0
- package/dist/_virtual/_rolldown/runtime.mjs +11 -0
- package/dist/components/SchemaVariables/SchemaVariable.d.ts +19 -0
- package/dist/components/SchemaVariables/SchemaVariable.mjs +68 -0
- package/dist/components/SchemaVariables/SchemaVariables.d.ts +16 -0
- package/dist/components/SchemaVariables/SchemaVariables.mjs +62 -0
- package/dist/components/SchemaVariables/VariableActions.d.ts +8 -0
- package/dist/components/SchemaVariables/VariableActions.mjs +33 -0
- package/dist/components/SchemaVariables/VariableDetails.d.ts +8 -0
- package/dist/components/SchemaVariables/VariableDetails.mjs +57 -0
- package/dist/components/SchemaVariables/VariableValue.d.ts +7 -0
- package/dist/components/SchemaVariables/VariableValue.mjs +16 -0
- package/dist/components/SchemaVariables/index.d.ts +3 -0
- package/dist/components/SchemaVariables/index.mjs +5 -0
- package/dist/components/StyleVariables/StyleVariable.d.ts +11 -0
- package/dist/components/StyleVariables/StyleVariable.mjs +63 -0
- package/dist/components/StyleVariables/StyleVariables.d.ts +15 -0
- package/dist/components/StyleVariables/StyleVariables.mjs +58 -0
- package/dist/components/StyleVariables/VariableActions.d.ts +8 -0
- package/dist/components/StyleVariables/VariableActions.mjs +33 -0
- package/dist/components/StyleVariables/VariableDetails.d.ts +7 -0
- package/dist/components/StyleVariables/VariableDetails.mjs +30 -0
- package/dist/components/StyleVariables/VariableGroup.d.ts +10 -0
- package/dist/components/StyleVariables/VariableGroup.mjs +39 -0
- package/dist/components/StyleVariables/VariableList.d.ts +9 -0
- package/dist/components/StyleVariables/VariableList.mjs +17 -0
- package/dist/components/StyleVariables/VariableValue.d.ts +8 -0
- package/dist/components/StyleVariables/VariableValue.mjs +27 -0
- package/dist/components/StyleVariables/index.d.ts +3 -0
- package/dist/components/StyleVariables/index.mjs +5 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.mjs +10 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +11 -0
- package/dist/models/SchemaVariableForm/SchemaVariableForm.d.ts +39 -0
- package/dist/models/SchemaVariableForm/SchemaVariableForm.mjs +171 -0
- package/dist/models/SchemaVariableForm/VariableSubValue.d.ts +17 -0
- package/dist/models/SchemaVariableForm/VariableSubValue.mjs +55 -0
- package/dist/models/SchemaVariableForm/VariableSubValueActions.d.ts +9 -0
- package/dist/models/SchemaVariableForm/VariableSubValueActions.mjs +32 -0
- package/dist/models/SchemaVariableForm/VariableValue.d.ts +14 -0
- package/dist/models/SchemaVariableForm/VariableValue.mjs +76 -0
- package/dist/models/SchemaVariableForm/index.d.ts +3 -0
- package/dist/models/SchemaVariableForm/index.mjs +5 -0
- package/dist/models/StyleVariableForm/StyleVariableForm.d.ts +34 -0
- package/dist/models/StyleVariableForm/StyleVariableForm.mjs +150 -0
- package/dist/models/StyleVariableForm/index.d.ts +3 -0
- package/dist/models/StyleVariableForm/index.mjs +5 -0
- package/dist/models/index.d.ts +5 -0
- package/dist/models/index.mjs +14 -0
- package/package.json +163 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { StyleVariables } from '@plitzi/sdk-shared';
|
|
2
|
+
export declare const schemaVariablesToCss: (variables?: Record<string, string>) => string;
|
|
3
|
+
export declare const styleVariablesToCss: (variables: Partial<StyleVariables>, name?: string, tabIndentSpace?: number, includeRoot?: boolean) => string;
|
|
4
|
+
export declare const styleSelectorVariablesToCss: (variables: Partial<StyleVariables>, name: string, tabIndentSpace?: number, includeRoot?: boolean) => string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/VariablesHelper.ts
|
|
2
|
+
var e = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/, t = /^rgba?\(\s*(\d{1,3}%?\s*,\s*){2,3}\d{1,3}%?\s*\)$/, n = /^hsla?\(\s*\d{1,3}(deg|rad|turn)?\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%(\s*,\s*(0|0?\.\d+|1))?\s*\)$/, r = new Set([
|
|
3
|
+
"black",
|
|
4
|
+
"white",
|
|
5
|
+
"red",
|
|
6
|
+
"green",
|
|
7
|
+
"blue",
|
|
8
|
+
"yellow",
|
|
9
|
+
"cyan",
|
|
10
|
+
"magenta",
|
|
11
|
+
"orange",
|
|
12
|
+
"purple",
|
|
13
|
+
"brown",
|
|
14
|
+
"pink",
|
|
15
|
+
"gray",
|
|
16
|
+
"lime",
|
|
17
|
+
"teal",
|
|
18
|
+
"navy",
|
|
19
|
+
"silver",
|
|
20
|
+
"maroon",
|
|
21
|
+
"olive",
|
|
22
|
+
"aqua",
|
|
23
|
+
"fuchsia"
|
|
24
|
+
]), i = (i) => {
|
|
25
|
+
if (!i || typeof i != "string") return !1;
|
|
26
|
+
let a = i.trim().toLowerCase();
|
|
27
|
+
return e.test(a) || t.test(a) || n.test(a) || r.has(a);
|
|
28
|
+
}, a = (e) => e ? Object.keys(e).filter((t) => typeof e[t] == "string" || typeof e[t] == "number").map((t) => {
|
|
29
|
+
let n = e[t];
|
|
30
|
+
return i(n) ? `--${t}:${n};` : `--${t}:"${n}";`;
|
|
31
|
+
}).join("\n") : "", o = (e, t = ":root", n = 2, r = !0) => {
|
|
32
|
+
let i = [], a = [], o = [], s = " ".repeat(n), c = " ".repeat(n * 2);
|
|
33
|
+
for (let [, t] of Object.entries(e)) for (let [e, n] of Object.entries(t)) {
|
|
34
|
+
let t = `--${e}`;
|
|
35
|
+
typeof n == "object" ? (i.push(`${c}${t}: ${n.default};`), a.push(`${c}${t}: ${n.light};`), o.push(`${c}${t}: ${n.dark};`)) : i.push(`${c}${t}: ${n};`);
|
|
36
|
+
}
|
|
37
|
+
let l = "";
|
|
38
|
+
return r && (l = `${t} {\n${i.join("\n")}\n}`), a.length && (l += `\n\n@media (prefers-color-scheme: light) {\n${s}${t} {\n${a.join("\n")}\n }\n}`), o.length && (l += `\n\n@media (prefers-color-scheme: dark) {\n${s}${t} {\n${o.join("\n")}\n }\n}`), l;
|
|
39
|
+
}, s = (e, t, n = 2, r = !0) => o(e, t, n, r);
|
|
40
|
+
//#endregion
|
|
41
|
+
export { a as schemaVariablesToCss, s as styleSelectorVariablesToCss, o as styleVariablesToCss };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.defineProperty, t = (t, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in t) e(r, i, {
|
|
5
|
+
get: t[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as __exportAll };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Environment, QueryParams, RouteParams, SchemaVariable as TSchemaVariable } from '@plitzi/sdk-shared';
|
|
2
|
+
export type SchemaVariableProps = {
|
|
3
|
+
name?: string;
|
|
4
|
+
category?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
type?: TSchemaVariable['type'];
|
|
7
|
+
subValues?: TSchemaVariable['subValues'];
|
|
8
|
+
whenData?: {
|
|
9
|
+
routeParams: RouteParams;
|
|
10
|
+
queryParams: QueryParams;
|
|
11
|
+
hostname?: string;
|
|
12
|
+
environment: Environment;
|
|
13
|
+
};
|
|
14
|
+
onChange?: (name: string, value: Omit<TSchemaVariable, 'name'>) => void;
|
|
15
|
+
onRemove: (name: string) => void;
|
|
16
|
+
onParentRefresh?: (identifier: string, segment: object) => void;
|
|
17
|
+
};
|
|
18
|
+
declare const SchemaVariable: ({ name, value, type, category, subValues, whenData, onChange, onRemove }: SchemaVariableProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export default SchemaVariable;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import e from "./VariableActions.mjs";
|
|
2
|
+
import t from "./VariableValue.mjs";
|
|
3
|
+
import n from "./VariableDetails.mjs";
|
|
4
|
+
import r from "../../models/SchemaVariableForm/index.mjs";
|
|
5
|
+
import { useCallback as i, useState as a } from "react";
|
|
6
|
+
import { omit as o } from "@plitzi/plitzi-ui/helpers";
|
|
7
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/SchemaVariables/SchemaVariable.tsx
|
|
9
|
+
var l = ({ name: l = "variable", value: u = "", type: d = "text", category: f = "", subValues: p, whenData: m, onChange: h, onRemove: g }) => {
|
|
10
|
+
let [_, v] = a(!1), [y, b] = a(!1), x = i((e) => {
|
|
11
|
+
e.stopPropagation(), g(l);
|
|
12
|
+
}, [g, l]), S = i((e) => {
|
|
13
|
+
e.stopPropagation(), v(!0);
|
|
14
|
+
}, []), C = i(() => v(!1), [v]), w = i((e) => {
|
|
15
|
+
h?.(l, o(e, ["name"])), v(!1);
|
|
16
|
+
}, [
|
|
17
|
+
h,
|
|
18
|
+
l,
|
|
19
|
+
v
|
|
20
|
+
]), T = i(() => b((e) => !e), []);
|
|
21
|
+
return _ ? /* @__PURE__ */ s("div", {
|
|
22
|
+
className: "rounded-sm border border-gray-300 p-2 dark:border-zinc-700",
|
|
23
|
+
children: /* @__PURE__ */ s(r, {
|
|
24
|
+
name: l,
|
|
25
|
+
category: f,
|
|
26
|
+
type: d,
|
|
27
|
+
value: u,
|
|
28
|
+
subValues: p,
|
|
29
|
+
whenData: m,
|
|
30
|
+
onSubmit: w,
|
|
31
|
+
onClose: C
|
|
32
|
+
})
|
|
33
|
+
}) : /* @__PURE__ */ c("div", {
|
|
34
|
+
className: "group flex flex-col gap-1 rounded-sm border border-gray-300 bg-white px-2 py-0.5 text-sm text-zinc-700 dark:border-zinc-700 dark:bg-zinc-800/50 dark:text-zinc-300",
|
|
35
|
+
children: [/* @__PURE__ */ c("div", {
|
|
36
|
+
className: "flex w-full cursor-pointer items-center gap-2",
|
|
37
|
+
onClick: T,
|
|
38
|
+
children: [/* @__PURE__ */ c("div", {
|
|
39
|
+
className: "flex w-full overflow-hidden",
|
|
40
|
+
children: [p && p.length > 0 && /* @__PURE__ */ s("i", {
|
|
41
|
+
className: "fa-solid fa-code-merge px-1 text-sm",
|
|
42
|
+
title: "Has Variations"
|
|
43
|
+
}), /* @__PURE__ */ c("div", {
|
|
44
|
+
className: "flex min-w-0 grow basis-0 justify-between gap-2",
|
|
45
|
+
children: [/* @__PURE__ */ s("div", {
|
|
46
|
+
className: "font-bold",
|
|
47
|
+
title: l,
|
|
48
|
+
children: l
|
|
49
|
+
}), /* @__PURE__ */ s(t, {
|
|
50
|
+
className: "truncate text-xs",
|
|
51
|
+
type: d,
|
|
52
|
+
value: u
|
|
53
|
+
})]
|
|
54
|
+
})]
|
|
55
|
+
}), /* @__PURE__ */ s(e, {
|
|
56
|
+
selected: y,
|
|
57
|
+
onUpdate: S,
|
|
58
|
+
onRemove: x
|
|
59
|
+
})]
|
|
60
|
+
}), y && /* @__PURE__ */ s(n, {
|
|
61
|
+
name: l,
|
|
62
|
+
type: d,
|
|
63
|
+
subValues: p
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { l as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Environment, QueryParams, RouteParams, SchemaVariable as TSchemaVariable } from '@plitzi/sdk-shared';
|
|
2
|
+
export type SchemaVariablesProps = {
|
|
3
|
+
className?: string;
|
|
4
|
+
variables?: TSchemaVariable[];
|
|
5
|
+
whenData?: {
|
|
6
|
+
routeParams: RouteParams;
|
|
7
|
+
queryParams: QueryParams;
|
|
8
|
+
hostname?: string;
|
|
9
|
+
environment: Environment;
|
|
10
|
+
};
|
|
11
|
+
onAdd?: (variable: TSchemaVariable) => void;
|
|
12
|
+
onUpdate?: (variable: TSchemaVariable) => void;
|
|
13
|
+
onRemove?: (name: string) => void;
|
|
14
|
+
};
|
|
15
|
+
declare const SchemaVariables: ({ className, variables, whenData, onAdd, onUpdate, onRemove }: SchemaVariablesProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export default SchemaVariables;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import e from "../../models/SchemaVariableForm/index.mjs";
|
|
2
|
+
import t from "./SchemaVariable.mjs";
|
|
3
|
+
import n from "@plitzi/plitzi-ui/Button";
|
|
4
|
+
import r from "clsx";
|
|
5
|
+
import { useCallback as i, useState as a } from "react";
|
|
6
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/SchemaVariables/SchemaVariables.tsx
|
|
8
|
+
var c = ({ className: c, variables: l, whenData: u, onAdd: d, onUpdate: f, onRemove: p }) => {
|
|
9
|
+
let [m, h] = a(), g = i((e) => {
|
|
10
|
+
d?.(e), h(void 0);
|
|
11
|
+
}, [d]), _ = i((e, t) => f?.({
|
|
12
|
+
...t,
|
|
13
|
+
name: e
|
|
14
|
+
}), [f]), v = i((e) => p?.(e), [p]), y = i(() => {
|
|
15
|
+
h({
|
|
16
|
+
name: "variable",
|
|
17
|
+
type: "text",
|
|
18
|
+
category: "",
|
|
19
|
+
value: "",
|
|
20
|
+
subValues: []
|
|
21
|
+
});
|
|
22
|
+
}, []), b = i(() => h(void 0), []);
|
|
23
|
+
return /* @__PURE__ */ s("div", {
|
|
24
|
+
className: r("flex w-full flex-col gap-3", c),
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ o("div", {
|
|
27
|
+
className: "flex min-h-0 grow basis-0 flex-col gap-1 overflow-y-auto",
|
|
28
|
+
children: l?.map((e) => {
|
|
29
|
+
let { name: n, type: r, value: i, category: a, subValues: s } = e;
|
|
30
|
+
return /* @__PURE__ */ o(t, {
|
|
31
|
+
name: n,
|
|
32
|
+
category: a,
|
|
33
|
+
type: r,
|
|
34
|
+
value: i,
|
|
35
|
+
subValues: s,
|
|
36
|
+
whenData: u,
|
|
37
|
+
onChange: _,
|
|
38
|
+
onRemove: v
|
|
39
|
+
}, n);
|
|
40
|
+
})
|
|
41
|
+
}),
|
|
42
|
+
!m && /* @__PURE__ */ o("div", {
|
|
43
|
+
className: "flex w-full px-1",
|
|
44
|
+
children: /* @__PURE__ */ s(n, {
|
|
45
|
+
className: "w-full",
|
|
46
|
+
size: "xs",
|
|
47
|
+
onClick: y,
|
|
48
|
+
iconPlacement: "before",
|
|
49
|
+
children: [/* @__PURE__ */ o(n.Icon, { icon: "fa-solid fa-plus" }), "Add Space Variable"]
|
|
50
|
+
})
|
|
51
|
+
}),
|
|
52
|
+
m && /* @__PURE__ */ o(e, {
|
|
53
|
+
...m,
|
|
54
|
+
isNewRecord: !0,
|
|
55
|
+
onSubmit: g,
|
|
56
|
+
onClose: b
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { c as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
export type VariableActionsProps = {
|
|
3
|
+
onUpdate?: (e: MouseEvent) => void;
|
|
4
|
+
onRemove?: (e: MouseEvent) => void;
|
|
5
|
+
selected?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const VariableActions: ({ onUpdate, onRemove, selected }: VariableActionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default VariableActions;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import e from "@plitzi/plitzi-ui/Button";
|
|
2
|
+
import t from "clsx";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/SchemaVariables/VariableActions.tsx
|
|
5
|
+
var i = ({ onUpdate: i, onRemove: a, selected: o = !1 }) => /* @__PURE__ */ r("div", {
|
|
6
|
+
className: t("flex items-center gap-2 text-xs", {
|
|
7
|
+
flex: o,
|
|
8
|
+
"hidden group-hover:flex": !o
|
|
9
|
+
}),
|
|
10
|
+
children: [/* @__PURE__ */ n(e, {
|
|
11
|
+
intent: "custom",
|
|
12
|
+
size: "custom",
|
|
13
|
+
border: "none",
|
|
14
|
+
onClick: i,
|
|
15
|
+
title: "Update",
|
|
16
|
+
children: /* @__PURE__ */ n(e.Icon, {
|
|
17
|
+
intent: "primary",
|
|
18
|
+
icon: "fas fa-pen"
|
|
19
|
+
})
|
|
20
|
+
}), /* @__PURE__ */ n(e, {
|
|
21
|
+
intent: "custom",
|
|
22
|
+
border: "none",
|
|
23
|
+
size: "custom",
|
|
24
|
+
onClick: a,
|
|
25
|
+
title: "Remove",
|
|
26
|
+
children: /* @__PURE__ */ n(e.Icon, {
|
|
27
|
+
intent: "danger",
|
|
28
|
+
icon: "fas fa-trash-alt"
|
|
29
|
+
})
|
|
30
|
+
})]
|
|
31
|
+
});
|
|
32
|
+
//#endregion
|
|
33
|
+
export { i as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SchemaVariable } from '@plitzi/sdk-shared';
|
|
2
|
+
export type VariableDetailsProps = {
|
|
3
|
+
name?: SchemaVariable['name'];
|
|
4
|
+
type?: SchemaVariable['type'];
|
|
5
|
+
subValues?: SchemaVariable['subValues'];
|
|
6
|
+
};
|
|
7
|
+
declare const VariableDetails: ({ name, subValues, type }: VariableDetailsProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default VariableDetails;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import e from "./VariableValue.mjs";
|
|
2
|
+
import { useCallback as t } from "react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
import { QueryBuilderFormatter as i } from "@plitzi/plitzi-ui/QueryBuilder";
|
|
5
|
+
import { useToast as a } from "@plitzi/plitzi-ui/Toast";
|
|
6
|
+
//#region src/components/SchemaVariables/VariableDetails.tsx
|
|
7
|
+
var o = ({ name: o, subValues: s = [], type: c = "text" }) => {
|
|
8
|
+
let { addToast: l } = a(), u = t(() => {
|
|
9
|
+
navigator.clipboard.writeText(`{{${o}}}`), l("Variable copied into the clipboard", {
|
|
10
|
+
appeareance: "success",
|
|
11
|
+
autoDismiss: !0,
|
|
12
|
+
placement: "top-right"
|
|
13
|
+
});
|
|
14
|
+
}, [l, o]);
|
|
15
|
+
return /* @__PURE__ */ r("div", {
|
|
16
|
+
className: "flex w-full flex-col gap-2",
|
|
17
|
+
children: [s.length > 0 && /* @__PURE__ */ n("div", {
|
|
18
|
+
className: "flex w-full flex-col gap-1",
|
|
19
|
+
children: s.map((t, a) => /* @__PURE__ */ r("div", {
|
|
20
|
+
className: "flex w-full flex-col rounded-sm border border-gray-300 text-xs",
|
|
21
|
+
children: [/* @__PURE__ */ r("div", {
|
|
22
|
+
className: "flex items-center gap-1 px-1 py-0.5",
|
|
23
|
+
children: [/* @__PURE__ */ n("div", {
|
|
24
|
+
className: "font-bold",
|
|
25
|
+
children: "Value:"
|
|
26
|
+
}), /* @__PURE__ */ n(e, {
|
|
27
|
+
className: "text-xs",
|
|
28
|
+
value: t.value,
|
|
29
|
+
type: c
|
|
30
|
+
})]
|
|
31
|
+
}), /* @__PURE__ */ r("div", {
|
|
32
|
+
className: "flex gap-1 border-t border-gray-300 px-1 py-0.5",
|
|
33
|
+
children: [/* @__PURE__ */ n("div", {
|
|
34
|
+
className: "font-bold",
|
|
35
|
+
children: "When:"
|
|
36
|
+
}), i(t.when)]
|
|
37
|
+
})]
|
|
38
|
+
}, a))
|
|
39
|
+
}), /* @__PURE__ */ r("div", {
|
|
40
|
+
className: "flex items-center justify-between gap-2",
|
|
41
|
+
children: [/* @__PURE__ */ r("div", {
|
|
42
|
+
className: "flex gap-1",
|
|
43
|
+
children: ["Token:", /* @__PURE__ */ n("div", {
|
|
44
|
+
className: "truncate font-bold",
|
|
45
|
+
title: o,
|
|
46
|
+
children: `{{${o}}}`
|
|
47
|
+
})]
|
|
48
|
+
}), /* @__PURE__ */ n("i", {
|
|
49
|
+
className: "fa-solid fa-copy cursor-pointer hover:text-blue-400",
|
|
50
|
+
onClick: u,
|
|
51
|
+
title: "Copy"
|
|
52
|
+
})]
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { o as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
//#region src/components/SchemaVariables/VariableValue.tsx
|
|
3
|
+
var n = ({ type: n, value: r }) => /* @__PURE__ */ t("div", {
|
|
4
|
+
className: "flex items-center gap-1 truncate text-xs",
|
|
5
|
+
children: [n === "color" && /* @__PURE__ */ e("div", {
|
|
6
|
+
className: "min-h-3 min-w-3 rounded-sm border border-gray-300",
|
|
7
|
+
title: r,
|
|
8
|
+
style: { backgroundColor: r }
|
|
9
|
+
}), /* @__PURE__ */ e("div", {
|
|
10
|
+
className: "truncate",
|
|
11
|
+
title: r,
|
|
12
|
+
children: r
|
|
13
|
+
})]
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { n as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StyleVariableCategory, StyleVariableValue } from '@plitzi/sdk-shared';
|
|
2
|
+
import { TStyleVariable } from './StyleVariables';
|
|
3
|
+
export type StyleVariableProps = {
|
|
4
|
+
category: StyleVariableCategory;
|
|
5
|
+
name: string;
|
|
6
|
+
value?: StyleVariableValue;
|
|
7
|
+
onUpdate?: (name: string, values: Omit<TStyleVariable, 'name'>) => void;
|
|
8
|
+
onRemove?: (category: StyleVariableCategory, name: string) => void;
|
|
9
|
+
};
|
|
10
|
+
declare const StyleVariable: ({ category, name, value, onUpdate, onRemove }: StyleVariableProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default StyleVariable;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import e from "./VariableActions.mjs";
|
|
2
|
+
import t from "./VariableDetails.mjs";
|
|
3
|
+
import n from "./VariableValue.mjs";
|
|
4
|
+
import r from "../../models/StyleVariableForm/index.mjs";
|
|
5
|
+
import { useCallback as i, useState as a } from "react";
|
|
6
|
+
import { omit as o } from "@plitzi/plitzi-ui/helpers";
|
|
7
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
+
import { StyleVariableCategory as l } from "@plitzi/sdk-shared";
|
|
9
|
+
//#region src/components/StyleVariables/StyleVariable.tsx
|
|
10
|
+
var u = ({ category: u, name: d, value: f, onUpdate: p, onRemove: m }) => {
|
|
11
|
+
let [h, g] = a(!1), [_, v] = a(!1), y = i((e) => {
|
|
12
|
+
e.stopPropagation(), g(!0);
|
|
13
|
+
}, []), b = i((e) => {
|
|
14
|
+
e.stopPropagation(), m?.(u, d);
|
|
15
|
+
}, [
|
|
16
|
+
m,
|
|
17
|
+
u,
|
|
18
|
+
d
|
|
19
|
+
]), x = i(() => v((e) => !e), []), S = i(() => g(!1), [g]), C = i((e) => {
|
|
20
|
+
p?.(d, o(e, ["name"])), g(!1);
|
|
21
|
+
}, [
|
|
22
|
+
p,
|
|
23
|
+
d,
|
|
24
|
+
g
|
|
25
|
+
]);
|
|
26
|
+
return h ? /* @__PURE__ */ s("div", {
|
|
27
|
+
className: "rounded-sm border border-gray-300 bg-white p-2 text-zinc-700 dark:border-zinc-700 dark:bg-zinc-800/50 dark:text-zinc-300",
|
|
28
|
+
children: /* @__PURE__ */ s(r, {
|
|
29
|
+
name: d,
|
|
30
|
+
category: u,
|
|
31
|
+
value: f,
|
|
32
|
+
onSubmit: C,
|
|
33
|
+
onClose: S
|
|
34
|
+
})
|
|
35
|
+
}) : /* @__PURE__ */ c("div", {
|
|
36
|
+
className: "group flex flex-col gap-1 rounded-sm border border-gray-300 bg-white px-1 py-0.5 text-sm text-zinc-700 dark:border-zinc-700 dark:bg-zinc-800/50 dark:text-zinc-300",
|
|
37
|
+
children: [/* @__PURE__ */ c("div", {
|
|
38
|
+
className: "flex w-full cursor-pointer items-center gap-2",
|
|
39
|
+
onClick: x,
|
|
40
|
+
children: [/* @__PURE__ */ s("div", {
|
|
41
|
+
className: "flex w-full overflow-hidden",
|
|
42
|
+
children: /* @__PURE__ */ c("div", {
|
|
43
|
+
className: "flex min-w-0 grow basis-0 justify-between gap-2",
|
|
44
|
+
children: [/* @__PURE__ */ s("div", {
|
|
45
|
+
className: "truncate font-bold",
|
|
46
|
+
title: d,
|
|
47
|
+
children: d
|
|
48
|
+
}), /* @__PURE__ */ s(n, {
|
|
49
|
+
className: "truncate text-xs",
|
|
50
|
+
type: u === l.COLOR ? "color" : "text",
|
|
51
|
+
value: f
|
|
52
|
+
})]
|
|
53
|
+
})
|
|
54
|
+
}), /* @__PURE__ */ s(e, {
|
|
55
|
+
selected: _,
|
|
56
|
+
onUpdate: y,
|
|
57
|
+
onRemove: b
|
|
58
|
+
})]
|
|
59
|
+
}), _ && /* @__PURE__ */ s(t, { name: d })]
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { u as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StyleVariableCategory, StyleVariables as TStyleVariables, StyleVariableValue } from '@plitzi/sdk-shared';
|
|
2
|
+
export type TStyleVariable = {
|
|
3
|
+
name: string;
|
|
4
|
+
category: StyleVariableCategory;
|
|
5
|
+
value: StyleVariableValue;
|
|
6
|
+
};
|
|
7
|
+
export type StyleVariablesProps = {
|
|
8
|
+
className?: string;
|
|
9
|
+
variables?: Partial<TStyleVariables>;
|
|
10
|
+
onAdd?: (variable: TStyleVariable) => void;
|
|
11
|
+
onUpdate?: (variable: TStyleVariable) => void;
|
|
12
|
+
onRemove?: (category: StyleVariableCategory, name: string) => void;
|
|
13
|
+
};
|
|
14
|
+
declare const StyleVariables: ({ className, variables, onAdd, onUpdate, onRemove }: StyleVariablesProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export default StyleVariables;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import e from "../../models/StyleVariableForm/index.mjs";
|
|
2
|
+
import t from "./VariableList.mjs";
|
|
3
|
+
import n from "@plitzi/plitzi-ui/Button";
|
|
4
|
+
import r from "clsx";
|
|
5
|
+
import { useCallback as i, useState as a } from "react";
|
|
6
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
import { StyleVariableCategory as c } from "@plitzi/sdk-shared";
|
|
8
|
+
//#region src/components/StyleVariables/StyleVariables.tsx
|
|
9
|
+
var l = ({ className: l, variables: u = {
|
|
10
|
+
color: {},
|
|
11
|
+
spacing: {},
|
|
12
|
+
shadow: {}
|
|
13
|
+
}, onAdd: d, onUpdate: f, onRemove: p }) => {
|
|
14
|
+
let [m, h] = a(), g = i((e) => {
|
|
15
|
+
d?.(e), h(void 0);
|
|
16
|
+
}, [d]), _ = i((e, t) => f?.({
|
|
17
|
+
...t,
|
|
18
|
+
name: e
|
|
19
|
+
}), [f]), v = i((e, t) => p?.(e, t), [p]), y = i(() => {
|
|
20
|
+
h({
|
|
21
|
+
name: "",
|
|
22
|
+
category: c.COLOR,
|
|
23
|
+
value: {
|
|
24
|
+
light: "",
|
|
25
|
+
dark: "",
|
|
26
|
+
default: ""
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}, []), b = i(() => h(void 0), []);
|
|
30
|
+
return /* @__PURE__ */ s("div", {
|
|
31
|
+
className: r("flex flex-col gap-2", l),
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ o(t, {
|
|
34
|
+
variables: u,
|
|
35
|
+
onUpdate: _,
|
|
36
|
+
onRemove: v
|
|
37
|
+
}),
|
|
38
|
+
!m && /* @__PURE__ */ o("div", {
|
|
39
|
+
className: "flex w-full px-1",
|
|
40
|
+
children: /* @__PURE__ */ s(n, {
|
|
41
|
+
className: "w-full",
|
|
42
|
+
size: "xs",
|
|
43
|
+
onClick: y,
|
|
44
|
+
iconPlacement: "before",
|
|
45
|
+
children: [/* @__PURE__ */ o(n.Icon, { icon: "fa-solid fa-plus" }), "Add Style Variable"]
|
|
46
|
+
})
|
|
47
|
+
}),
|
|
48
|
+
m && /* @__PURE__ */ o(e, {
|
|
49
|
+
...m,
|
|
50
|
+
isNewRecord: !0,
|
|
51
|
+
onSubmit: g,
|
|
52
|
+
onClose: b
|
|
53
|
+
})
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { l as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
export type VariableActionsProps = {
|
|
3
|
+
onUpdate?: (e: MouseEvent) => void;
|
|
4
|
+
onRemove?: (e: MouseEvent) => void;
|
|
5
|
+
selected?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const VariableActions: ({ onUpdate, onRemove, selected }: VariableActionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default VariableActions;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import e from "@plitzi/plitzi-ui/Button";
|
|
2
|
+
import t from "clsx";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/StyleVariables/VariableActions.tsx
|
|
5
|
+
var i = ({ onUpdate: i, onRemove: a, selected: o = !1 }) => /* @__PURE__ */ r("div", {
|
|
6
|
+
className: t("flex items-center gap-2 text-xs", {
|
|
7
|
+
flex: o,
|
|
8
|
+
"hidden group-hover:flex": !o
|
|
9
|
+
}),
|
|
10
|
+
children: [/* @__PURE__ */ n(e, {
|
|
11
|
+
intent: "custom",
|
|
12
|
+
size: "custom",
|
|
13
|
+
border: "none",
|
|
14
|
+
onClick: i,
|
|
15
|
+
title: "Update",
|
|
16
|
+
children: /* @__PURE__ */ n(e.Icon, {
|
|
17
|
+
intent: "primary",
|
|
18
|
+
icon: "fas fa-pen"
|
|
19
|
+
})
|
|
20
|
+
}), /* @__PURE__ */ n(e, {
|
|
21
|
+
intent: "custom",
|
|
22
|
+
border: "none",
|
|
23
|
+
size: "custom",
|
|
24
|
+
onClick: a,
|
|
25
|
+
title: "Remove",
|
|
26
|
+
children: /* @__PURE__ */ n(e.Icon, {
|
|
27
|
+
intent: "danger",
|
|
28
|
+
icon: "fas fa-trash-alt"
|
|
29
|
+
})
|
|
30
|
+
})]
|
|
31
|
+
});
|
|
32
|
+
//#endregion
|
|
33
|
+
export { i as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SchemaVariable } from '@plitzi/sdk-shared';
|
|
2
|
+
export type VariableDetailsProps = {
|
|
3
|
+
name?: SchemaVariable['name'];
|
|
4
|
+
type?: SchemaVariable['type'];
|
|
5
|
+
};
|
|
6
|
+
declare const VariableDetails: ({ name }: VariableDetailsProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default VariableDetails;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useCallback as e } from "react";
|
|
2
|
+
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
3
|
+
import { useToast as r } from "@plitzi/plitzi-ui/Toast";
|
|
4
|
+
//#region src/components/StyleVariables/VariableDetails.tsx
|
|
5
|
+
var i = ({ name: i }) => {
|
|
6
|
+
let { addToast: a } = r(), o = e(() => {
|
|
7
|
+
navigator.clipboard.writeText(`var(--${i})`), a("Variable copied into the clipboard", {
|
|
8
|
+
appeareance: "success",
|
|
9
|
+
autoDismiss: !0,
|
|
10
|
+
placement: "top-right"
|
|
11
|
+
});
|
|
12
|
+
}, [a, i]);
|
|
13
|
+
return /* @__PURE__ */ n("div", {
|
|
14
|
+
className: "flex w-full items-center justify-between gap-2",
|
|
15
|
+
children: [/* @__PURE__ */ n("div", {
|
|
16
|
+
className: "flex gap-1",
|
|
17
|
+
children: ["Token:", /* @__PURE__ */ t("div", {
|
|
18
|
+
className: "truncate font-bold",
|
|
19
|
+
title: i,
|
|
20
|
+
children: `var(--${i})`
|
|
21
|
+
})]
|
|
22
|
+
}), /* @__PURE__ */ t("i", {
|
|
23
|
+
className: "fa-solid fa-copy cursor-pointer hover:text-blue-400",
|
|
24
|
+
onClick: o,
|
|
25
|
+
title: "Copy"
|
|
26
|
+
})]
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { i as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TStyleVariable } from './StyleVariables';
|
|
2
|
+
import { StyleVariableCategory, StyleVariableGroup } from '@plitzi/sdk-shared';
|
|
3
|
+
export type VariableGroupProps = {
|
|
4
|
+
category: StyleVariableCategory;
|
|
5
|
+
variables?: StyleVariableGroup;
|
|
6
|
+
onUpdate?: (name: string, values: Omit<TStyleVariable, 'name'>) => void;
|
|
7
|
+
onRemove?: (category: StyleVariableCategory, name: string) => void;
|
|
8
|
+
};
|
|
9
|
+
declare const VariableGroup: ({ category, variables, onUpdate, onRemove }: VariableGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default VariableGroup;
|