@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,150 @@
|
|
|
1
|
+
import e from "@plitzi/plitzi-ui/Button";
|
|
2
|
+
import { useCallback as t, useState as n } from "react";
|
|
3
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
import a, { useForm as o, useFormWatch as s } from "@plitzi/plitzi-ui/Form";
|
|
5
|
+
import { z as c } from "zod";
|
|
6
|
+
import { StyleVariableCategory as l } from "@plitzi/sdk-shared";
|
|
7
|
+
//#region src/models/StyleVariableForm/StyleVariableForm.tsx
|
|
8
|
+
var u = c.string().min(3, "Too Short").max(20, "Too Long").regex(/^(?:\w+\s+|)([a-zA-Z_][a-zA-Z0-9_-]+)$/i, "Invalid Name"), d = c.discriminatedUnion("category", [
|
|
9
|
+
c.object({
|
|
10
|
+
name: u,
|
|
11
|
+
category: c.literal(l.COLOR),
|
|
12
|
+
value: c.object({
|
|
13
|
+
light: c.string().min(1),
|
|
14
|
+
dark: c.string().min(1),
|
|
15
|
+
default: c.string().min(1)
|
|
16
|
+
})
|
|
17
|
+
}),
|
|
18
|
+
c.object({
|
|
19
|
+
name: u,
|
|
20
|
+
category: c.literal(l.SHADOW),
|
|
21
|
+
value: c.string().min(1)
|
|
22
|
+
}),
|
|
23
|
+
c.object({
|
|
24
|
+
name: u,
|
|
25
|
+
category: c.literal(l.SPACING),
|
|
26
|
+
value: c.string().trim().refine((e) => !!(e === "0" || e === "auto" || /^-?\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|dvh|svh|lvh|ch|ex|cm|mm|in|pt|pc)$/i.test(e) || /^(calc|min|max|clamp)\(.+\)$/i.test(e)), "Invalid CSS value")
|
|
27
|
+
}),
|
|
28
|
+
c.object({
|
|
29
|
+
name: u,
|
|
30
|
+
category: c.literal(l.CUSTOM),
|
|
31
|
+
value: c.string().min(1)
|
|
32
|
+
})
|
|
33
|
+
]), f = (e, t, n) => {
|
|
34
|
+
switch (e) {
|
|
35
|
+
case l.COLOR: {
|
|
36
|
+
let { default: r = "", light: i = "", dark: a = "" } = n;
|
|
37
|
+
return {
|
|
38
|
+
name: t,
|
|
39
|
+
category: e,
|
|
40
|
+
value: {
|
|
41
|
+
light: i,
|
|
42
|
+
dark: a,
|
|
43
|
+
default: r
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
case l.SPACING:
|
|
48
|
+
case l.SHADOW:
|
|
49
|
+
case l.CUSTOM:
|
|
50
|
+
default: return {
|
|
51
|
+
name: t,
|
|
52
|
+
category: e,
|
|
53
|
+
value: typeof n == "string" ? n : ""
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}, p = ({ name: c = "New Page", category: u = l.COLOR, value: p, isNewRecord: m = !1, onClose: h, onSubmit: g }) => {
|
|
57
|
+
let [_, v] = n(f(u, c, p)), y = o({
|
|
58
|
+
defaultValues: _,
|
|
59
|
+
config: { schema: d }
|
|
60
|
+
}), b = s(y.formMethods, "category"), x = t((e) => {
|
|
61
|
+
y.formMethods.setValue("value", e === l.COLOR ? {
|
|
62
|
+
default: "",
|
|
63
|
+
light: "",
|
|
64
|
+
dark: ""
|
|
65
|
+
} : ""), v(f(e, c, e));
|
|
66
|
+
}, [y.formMethods, c]);
|
|
67
|
+
return /* @__PURE__ */ i(a, {
|
|
68
|
+
form: y,
|
|
69
|
+
onSubmit: t((e) => g?.(e), [g]),
|
|
70
|
+
className: "w-full gap-4 rounded border border-gray-300 bg-white p-2 text-zinc-700 dark:border-zinc-700 dark:bg-zinc-800/50 dark:text-zinc-300",
|
|
71
|
+
children: [/* @__PURE__ */ i(a.Body, {
|
|
72
|
+
gap: 2,
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ r(a.Input, {
|
|
75
|
+
name: "name",
|
|
76
|
+
placeholder: "Name",
|
|
77
|
+
size: "xs",
|
|
78
|
+
disabled: !m
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ i(a.Select, {
|
|
81
|
+
name: "category",
|
|
82
|
+
size: "xs",
|
|
83
|
+
onChange: x,
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ r("option", {
|
|
86
|
+
value: l.COLOR,
|
|
87
|
+
children: "Colors"
|
|
88
|
+
}),
|
|
89
|
+
/* @__PURE__ */ r("option", {
|
|
90
|
+
value: l.SPACING,
|
|
91
|
+
children: "Spacing"
|
|
92
|
+
}),
|
|
93
|
+
/* @__PURE__ */ r("option", {
|
|
94
|
+
value: l.SHADOW,
|
|
95
|
+
children: "Shadow"
|
|
96
|
+
}),
|
|
97
|
+
/* @__PURE__ */ r("option", {
|
|
98
|
+
value: l.CUSTOM,
|
|
99
|
+
children: "Custom"
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
}),
|
|
103
|
+
b === l.COLOR && /* @__PURE__ */ i("div", {
|
|
104
|
+
className: "flex w-full gap-2",
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ r(a.Color, {
|
|
107
|
+
name: "value.default",
|
|
108
|
+
placeholder: "Default Value",
|
|
109
|
+
size: "xs",
|
|
110
|
+
allowVariables: !0,
|
|
111
|
+
className: "min-w-0 grow basis-0"
|
|
112
|
+
}),
|
|
113
|
+
/* @__PURE__ */ r(a.Color, {
|
|
114
|
+
name: "value.light",
|
|
115
|
+
placeholder: "Light Value",
|
|
116
|
+
size: "xs",
|
|
117
|
+
allowVariables: !0,
|
|
118
|
+
className: "min-w-0 grow basis-0"
|
|
119
|
+
}),
|
|
120
|
+
/* @__PURE__ */ r(a.Color, {
|
|
121
|
+
name: "value.dark",
|
|
122
|
+
placeholder: "Dark Value",
|
|
123
|
+
size: "xs",
|
|
124
|
+
allowVariables: !0,
|
|
125
|
+
className: "min-w-0 grow basis-0"
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
}),
|
|
129
|
+
b !== l.COLOR && /* @__PURE__ */ r(a.Input, {
|
|
130
|
+
name: "value",
|
|
131
|
+
placeholder: "Value",
|
|
132
|
+
size: "xs",
|
|
133
|
+
className: "grow basis-0"
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
}), /* @__PURE__ */ i(a.Footer, { children: [/* @__PURE__ */ r(e, {
|
|
137
|
+
onClick: h,
|
|
138
|
+
size: "xs",
|
|
139
|
+
className: "grow basis-0",
|
|
140
|
+
children: "Cancel"
|
|
141
|
+
}), /* @__PURE__ */ r(e, {
|
|
142
|
+
type: "submit",
|
|
143
|
+
size: "xs",
|
|
144
|
+
className: "grow basis-0",
|
|
145
|
+
children: m ? "Add" : "Update"
|
|
146
|
+
})] })]
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
//#endregion
|
|
150
|
+
export { p as default, d as styleVariableFormSchema };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __exportAll as e } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { schemaVariableFormSchema as t } from "./SchemaVariableForm/SchemaVariableForm.mjs";
|
|
3
|
+
import n from "./SchemaVariableForm/index.mjs";
|
|
4
|
+
import { styleVariableFormSchema as r } from "./StyleVariableForm/StyleVariableForm.mjs";
|
|
5
|
+
import i from "./StyleVariableForm/index.mjs";
|
|
6
|
+
//#region src/models/index.ts
|
|
7
|
+
var a = /* @__PURE__ */ e({
|
|
8
|
+
SchemaVariableForm: () => n,
|
|
9
|
+
StyleVariableForm: () => i,
|
|
10
|
+
schemaVariableFormSchema: () => t,
|
|
11
|
+
styleVariableFormSchema: () => r
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
export { n as SchemaVariableForm, i as StyleVariableForm, a as models_exports, t as schemaVariableFormSchema, r as styleVariableFormSchema };
|
package/package.json
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plitzi/sdk-variables",
|
|
3
|
+
"version": "0.30.19",
|
|
4
|
+
"license": "AGPL-3.0",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs"
|
|
12
|
+
},
|
|
13
|
+
"./VariablesContext": {
|
|
14
|
+
"types": "./dist/VariablesContext.d.ts",
|
|
15
|
+
"import": "./dist/VariablesContext.mjs"
|
|
16
|
+
},
|
|
17
|
+
"./VariablesHelper": {
|
|
18
|
+
"types": "./dist/VariablesHelper.d.ts",
|
|
19
|
+
"import": "./dist/VariablesHelper.mjs"
|
|
20
|
+
},
|
|
21
|
+
"./components": {
|
|
22
|
+
"types": "./dist/components/index.d.ts",
|
|
23
|
+
"import": "./dist/components/index.mjs"
|
|
24
|
+
},
|
|
25
|
+
"./components/SchemaVariables": {
|
|
26
|
+
"types": "./dist/components/SchemaVariables/index.d.ts",
|
|
27
|
+
"import": "./dist/components/SchemaVariables/index.mjs"
|
|
28
|
+
},
|
|
29
|
+
"./components/SchemaVariables/SchemaVariable": {
|
|
30
|
+
"types": "./dist/components/SchemaVariables/SchemaVariable.d.ts",
|
|
31
|
+
"import": "./dist/components/SchemaVariables/SchemaVariable.mjs"
|
|
32
|
+
},
|
|
33
|
+
"./components/SchemaVariables/SchemaVariables": {
|
|
34
|
+
"types": "./dist/components/SchemaVariables/SchemaVariables.d.ts",
|
|
35
|
+
"import": "./dist/components/SchemaVariables/SchemaVariables.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./components/SchemaVariables/VariableActions": {
|
|
38
|
+
"types": "./dist/components/SchemaVariables/VariableActions.d.ts",
|
|
39
|
+
"import": "./dist/components/SchemaVariables/VariableActions.mjs"
|
|
40
|
+
},
|
|
41
|
+
"./components/SchemaVariables/VariableDetails": {
|
|
42
|
+
"types": "./dist/components/SchemaVariables/VariableDetails.d.ts",
|
|
43
|
+
"import": "./dist/components/SchemaVariables/VariableDetails.mjs"
|
|
44
|
+
},
|
|
45
|
+
"./components/SchemaVariables/VariableValue": {
|
|
46
|
+
"types": "./dist/components/SchemaVariables/VariableValue.d.ts",
|
|
47
|
+
"import": "./dist/components/SchemaVariables/VariableValue.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./components/SchemaVariables/index": {
|
|
50
|
+
"types": "./dist/components/SchemaVariables/index.d.ts",
|
|
51
|
+
"import": "./dist/components/SchemaVariables/index.mjs"
|
|
52
|
+
},
|
|
53
|
+
"./components/StyleVariables": {
|
|
54
|
+
"types": "./dist/components/StyleVariables/index.d.ts",
|
|
55
|
+
"import": "./dist/components/StyleVariables/index.mjs"
|
|
56
|
+
},
|
|
57
|
+
"./components/StyleVariables/StyleVariable": {
|
|
58
|
+
"types": "./dist/components/StyleVariables/StyleVariable.d.ts",
|
|
59
|
+
"import": "./dist/components/StyleVariables/StyleVariable.mjs"
|
|
60
|
+
},
|
|
61
|
+
"./components/StyleVariables/StyleVariables": {
|
|
62
|
+
"types": "./dist/components/StyleVariables/StyleVariables.d.ts",
|
|
63
|
+
"import": "./dist/components/StyleVariables/StyleVariables.mjs"
|
|
64
|
+
},
|
|
65
|
+
"./components/StyleVariables/VariableActions": {
|
|
66
|
+
"types": "./dist/components/StyleVariables/VariableActions.d.ts",
|
|
67
|
+
"import": "./dist/components/StyleVariables/VariableActions.mjs"
|
|
68
|
+
},
|
|
69
|
+
"./components/StyleVariables/VariableDetails": {
|
|
70
|
+
"types": "./dist/components/StyleVariables/VariableDetails.d.ts",
|
|
71
|
+
"import": "./dist/components/StyleVariables/VariableDetails.mjs"
|
|
72
|
+
},
|
|
73
|
+
"./components/StyleVariables/VariableGroup": {
|
|
74
|
+
"types": "./dist/components/StyleVariables/VariableGroup.d.ts",
|
|
75
|
+
"import": "./dist/components/StyleVariables/VariableGroup.mjs"
|
|
76
|
+
},
|
|
77
|
+
"./components/StyleVariables/VariableList": {
|
|
78
|
+
"types": "./dist/components/StyleVariables/VariableList.d.ts",
|
|
79
|
+
"import": "./dist/components/StyleVariables/VariableList.mjs"
|
|
80
|
+
},
|
|
81
|
+
"./components/StyleVariables/VariableValue": {
|
|
82
|
+
"types": "./dist/components/StyleVariables/VariableValue.d.ts",
|
|
83
|
+
"import": "./dist/components/StyleVariables/VariableValue.mjs"
|
|
84
|
+
},
|
|
85
|
+
"./components/StyleVariables/index": {
|
|
86
|
+
"types": "./dist/components/StyleVariables/index.d.ts",
|
|
87
|
+
"import": "./dist/components/StyleVariables/index.mjs"
|
|
88
|
+
},
|
|
89
|
+
"./components/index": {
|
|
90
|
+
"types": "./dist/components/index.d.ts",
|
|
91
|
+
"import": "./dist/components/index.mjs"
|
|
92
|
+
},
|
|
93
|
+
"./index": {
|
|
94
|
+
"types": "./dist/index.d.ts",
|
|
95
|
+
"import": "./dist/index.mjs"
|
|
96
|
+
},
|
|
97
|
+
"./models": {
|
|
98
|
+
"types": "./dist/models/index.d.ts",
|
|
99
|
+
"import": "./dist/models/index.mjs"
|
|
100
|
+
},
|
|
101
|
+
"./models/SchemaVariableForm": {
|
|
102
|
+
"types": "./dist/models/SchemaVariableForm/index.d.ts",
|
|
103
|
+
"import": "./dist/models/SchemaVariableForm/index.mjs"
|
|
104
|
+
},
|
|
105
|
+
"./models/SchemaVariableForm/SchemaVariableForm": {
|
|
106
|
+
"types": "./dist/models/SchemaVariableForm/SchemaVariableForm.d.ts",
|
|
107
|
+
"import": "./dist/models/SchemaVariableForm/SchemaVariableForm.mjs"
|
|
108
|
+
},
|
|
109
|
+
"./models/SchemaVariableForm/VariableSubValue": {
|
|
110
|
+
"types": "./dist/models/SchemaVariableForm/VariableSubValue.d.ts",
|
|
111
|
+
"import": "./dist/models/SchemaVariableForm/VariableSubValue.mjs"
|
|
112
|
+
},
|
|
113
|
+
"./models/SchemaVariableForm/VariableSubValueActions": {
|
|
114
|
+
"types": "./dist/models/SchemaVariableForm/VariableSubValueActions.d.ts",
|
|
115
|
+
"import": "./dist/models/SchemaVariableForm/VariableSubValueActions.mjs"
|
|
116
|
+
},
|
|
117
|
+
"./models/SchemaVariableForm/VariableValue": {
|
|
118
|
+
"types": "./dist/models/SchemaVariableForm/VariableValue.d.ts",
|
|
119
|
+
"import": "./dist/models/SchemaVariableForm/VariableValue.mjs"
|
|
120
|
+
},
|
|
121
|
+
"./models/SchemaVariableForm/index": {
|
|
122
|
+
"types": "./dist/models/SchemaVariableForm/index.d.ts",
|
|
123
|
+
"import": "./dist/models/SchemaVariableForm/index.mjs"
|
|
124
|
+
},
|
|
125
|
+
"./models/StyleVariableForm": {
|
|
126
|
+
"types": "./dist/models/StyleVariableForm/index.d.ts",
|
|
127
|
+
"import": "./dist/models/StyleVariableForm/index.mjs"
|
|
128
|
+
},
|
|
129
|
+
"./models/StyleVariableForm/StyleVariableForm": {
|
|
130
|
+
"types": "./dist/models/StyleVariableForm/StyleVariableForm.d.ts",
|
|
131
|
+
"import": "./dist/models/StyleVariableForm/StyleVariableForm.mjs"
|
|
132
|
+
},
|
|
133
|
+
"./models/StyleVariableForm/index": {
|
|
134
|
+
"types": "./dist/models/StyleVariableForm/index.d.ts",
|
|
135
|
+
"import": "./dist/models/StyleVariableForm/index.mjs"
|
|
136
|
+
},
|
|
137
|
+
"./models/index": {
|
|
138
|
+
"types": "./dist/models/index.d.ts",
|
|
139
|
+
"import": "./dist/models/index.mjs"
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"type": "module",
|
|
143
|
+
"sideEffects": false,
|
|
144
|
+
"scripts": {
|
|
145
|
+
"lint": "eslint ./src",
|
|
146
|
+
"typecheck": "tsc -p tsconfig.app.json --noEmit",
|
|
147
|
+
"build:dev": "vite build --mode development --minify false && node ../sdk-shared/scripts/generate-exports.mjs",
|
|
148
|
+
"build:dev-watch": "vite build --mode development --watch --minify false",
|
|
149
|
+
"build:prod": "vite build && node ../sdk-shared/scripts/generate-exports.mjs"
|
|
150
|
+
},
|
|
151
|
+
"dependencies": {
|
|
152
|
+
"@plitzi/plitzi-ui": "^1.6.2",
|
|
153
|
+
"@plitzi/sdk-shared": "0.30.19",
|
|
154
|
+
"clsx": "^2.1.1",
|
|
155
|
+
"eslint": "^9.39.4",
|
|
156
|
+
"zod": "^4.4.1"
|
|
157
|
+
},
|
|
158
|
+
"devDependencies": {
|
|
159
|
+
"eslint": "^9.39.4",
|
|
160
|
+
"typescript": "^6.0.3",
|
|
161
|
+
"vite": "^8.0.10"
|
|
162
|
+
}
|
|
163
|
+
}
|