@craftile/editor 0.2.1 → 0.3.1
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/PropertyField.vue_vue_type_script_setup_true_lang-D1Yv2X4j.js +245 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3538 -3410
- package/dist/ui.js +1 -1
- package/dist/utils.d.ts +27 -0
- package/package.json +5 -5
- package/dist/PropertyField.vue_vue_type_script_setup_true_lang-DgXjnxE2.js +0 -197
package/dist/ui.js
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
|
+
import { VisibilityRule, BlockProperties } from '@craftile/types';
|
|
2
3
|
/**
|
|
3
4
|
* Check if a render value is a Vue component
|
|
4
5
|
*/
|
|
5
6
|
export declare function isVueComponent(render: any): render is Component;
|
|
6
7
|
export declare function isComponentString(render: any): render is string;
|
|
7
8
|
export declare function isHtmlRenderFunction(render: any): render is (context: any) => HTMLElement;
|
|
9
|
+
/**
|
|
10
|
+
* Evaluate a JSON visibility rule against a context object (block properties).
|
|
11
|
+
*
|
|
12
|
+
* @param rule - Rule object, logic group, or array (array === implicit AND)
|
|
13
|
+
* @param context - Block properties object
|
|
14
|
+
* @returns boolean indicating whether the field should be visible
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* // Simple condition
|
|
19
|
+
* evaluateVisibilityRule(
|
|
20
|
+
* { field: 'layout', operator: 'equals', value: 'grid' },
|
|
21
|
+
* { layout: 'grid' }
|
|
22
|
+
* ) // true
|
|
23
|
+
*
|
|
24
|
+
* // Logical AND
|
|
25
|
+
* evaluateVisibilityRule(
|
|
26
|
+
* { and: [
|
|
27
|
+
* { field: 'type', operator: 'equals', value: 'image' },
|
|
28
|
+
* { field: 'status', operator: 'equals', value: 'published' }
|
|
29
|
+
* ]},
|
|
30
|
+
* { type: 'image', status: 'published' }
|
|
31
|
+
* ) // true
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function evaluateVisibilityRule(rule: VisibilityRule | VisibilityRule[], context?: BlockProperties): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@craftile/editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Vue.js-based editor UI components for craftile blocks engine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"craftile",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"vue": "^3.5.17",
|
|
40
40
|
"vue-draggable-plus": "^0.6.0",
|
|
41
|
-
"@craftile/
|
|
42
|
-
"@craftile/
|
|
43
|
-
"@craftile/messenger": "0.
|
|
44
|
-
"@craftile/types": "0.
|
|
41
|
+
"@craftile/event-bus": "0.3.1",
|
|
42
|
+
"@craftile/core": "0.3.1",
|
|
43
|
+
"@craftile/messenger": "0.3.1",
|
|
44
|
+
"@craftile/types": "0.3.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@ark-ui/vue": "^5.24.1",
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { inject as h, computed as a, defineComponent as m, createElementBlock as p, openBlock as u, unref as s, normalizeClass as f, createCommentVNode as C, createElementVNode as c, renderSlot as P, ref as _, onMounted as F, watch as S, createBlock as y, resolveDynamicComponent as w, createTextVNode as x, toDisplayString as k } from "vue";
|
|
2
|
-
const B = Symbol.for("craftile-editor");
|
|
3
|
-
function g(e) {
|
|
4
|
-
return e && typeof e == "object" && (e.setup || e.render || e.__vccOpts || e.name || e.__v_skip);
|
|
5
|
-
}
|
|
6
|
-
function A(e) {
|
|
7
|
-
return typeof e == "string";
|
|
8
|
-
}
|
|
9
|
-
function V(e) {
|
|
10
|
-
return typeof e == "function" && !g(e);
|
|
11
|
-
}
|
|
12
|
-
function M() {
|
|
13
|
-
const e = h(B);
|
|
14
|
-
if (!e)
|
|
15
|
-
throw new Error("useUI must be used within a component that has access to CraftileEditor");
|
|
16
|
-
const r = (t) => {
|
|
17
|
-
e.ui.state.activeSidebarPanel = t;
|
|
18
|
-
};
|
|
19
|
-
return {
|
|
20
|
-
toaster: e.ui.toaster,
|
|
21
|
-
sidebarPanels: a(
|
|
22
|
-
() => Array.from(e.ui.state.sidebarPanels.values()).sort((t, o) => (t.order ?? 0) - (o.order ?? 0))
|
|
23
|
-
),
|
|
24
|
-
activeSidebarPanel: a(() => e.ui.state.activeSidebarPanel),
|
|
25
|
-
registerSidebarPanel: e.ui.registerSidebarPanel.bind(e.ui),
|
|
26
|
-
removeSidebarPanel: e.ui.removeSidebarPanel.bind(e.ui),
|
|
27
|
-
setActiveSidebarPanel: r,
|
|
28
|
-
headerActions: a(
|
|
29
|
-
() => Array.from(e.ui.state.headerActions.values()).sort((t, o) => (t.order ?? 0) - (o.order ?? 0))
|
|
30
|
-
),
|
|
31
|
-
registerHeaderAction: e.ui.registerHeaderAction.bind(e.ui),
|
|
32
|
-
removeHeaderAction: e.ui.removeHeaderAction.bind(e.ui),
|
|
33
|
-
configurationPanels: a(
|
|
34
|
-
() => Array.from(e.ui.state.configurationPanels.values()).sort((t, o) => (t.order ?? 0) - (o.order ?? 0))
|
|
35
|
-
),
|
|
36
|
-
registerConfigurationPanel: e.ui.registerConfigurationPanel.bind(e.ui),
|
|
37
|
-
removeConfigurationPanel: e.ui.removeConfigurationPanel.bind(e.ui),
|
|
38
|
-
modals: a(() => e.ui.state.modals),
|
|
39
|
-
openModals: a(() => e.ui.state.openModals),
|
|
40
|
-
openModal: e.ui.openModal.bind(e.ui),
|
|
41
|
-
closeModal: e.ui.closeModal.bind(e.ui),
|
|
42
|
-
propertyFields: a(() => e.ui.state.propertyFields),
|
|
43
|
-
registerPropertyField: e.ui.registerPropertyField.bind(e.ui),
|
|
44
|
-
removePropertyField: e.ui.removePropertyField.bind(e.ui),
|
|
45
|
-
keyboardShortcuts: a(() => e.ui.state.keyboardShortcuts),
|
|
46
|
-
registerKeyboardShortcut: e.ui.registerKeyboardShortcut.bind(e.ui),
|
|
47
|
-
removeKeyboardShortcut: e.ui.removeKeyboardShortcut.bind(e.ui)
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const z = ["type", "disabled"], R = {
|
|
51
|
-
key: 0,
|
|
52
|
-
class: "animate-spin h-4 w-4 absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",
|
|
53
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
54
|
-
fill: "none",
|
|
55
|
-
viewBox: "0 0 24 24"
|
|
56
|
-
}, K = /* @__PURE__ */ m({
|
|
57
|
-
__name: "Button",
|
|
58
|
-
props: {
|
|
59
|
-
variant: { default: "default" },
|
|
60
|
-
size: { default: "md" },
|
|
61
|
-
type: { default: "button" },
|
|
62
|
-
disabled: { type: Boolean, default: !1 },
|
|
63
|
-
fullWidth: { type: Boolean, default: !1 },
|
|
64
|
-
square: { type: Boolean, default: !1 },
|
|
65
|
-
loading: { type: Boolean, default: !1 }
|
|
66
|
-
},
|
|
67
|
-
setup(e) {
|
|
68
|
-
const r = {
|
|
69
|
-
default: "bg-white text-gray-900 hover:bg-gray-50 border border-gray-200",
|
|
70
|
-
primary: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
71
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/90",
|
|
72
|
-
accent: "bg-accent text-accent-foreground hover:bg-accent/90",
|
|
73
|
-
sutble: "bg-accent-foreground text-accent",
|
|
74
|
-
destructive: "bg-red-600 text-white hover:bg-red-700"
|
|
75
|
-
}, t = {
|
|
76
|
-
sm: "h-6 px-3 text-xs",
|
|
77
|
-
md: "h-8 px-4",
|
|
78
|
-
lg: "h-10 px-6 text-base"
|
|
79
|
-
}, o = {
|
|
80
|
-
sm: "w-6 h-6 text-xs p-0",
|
|
81
|
-
md: "w-8 h-8 p-0",
|
|
82
|
-
lg: "w-10 h-10 text-base p-0"
|
|
83
|
-
}, l = e, d = a(() => l.disabled || l.loading);
|
|
84
|
-
return (n, i) => (u(), p("button", {
|
|
85
|
-
class: f(["inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none cursor-pointer relative", [
|
|
86
|
-
r[n.variant],
|
|
87
|
-
l.square ? o[n.size] : t[n.size],
|
|
88
|
-
n.fullWidth && "w-full"
|
|
89
|
-
]]),
|
|
90
|
-
type: n.type,
|
|
91
|
-
disabled: s(d)
|
|
92
|
-
}, [
|
|
93
|
-
n.loading ? (u(), p("svg", R, [...i[0] || (i[0] = [
|
|
94
|
-
c("circle", {
|
|
95
|
-
class: "opacity-25",
|
|
96
|
-
cx: "12",
|
|
97
|
-
cy: "12",
|
|
98
|
-
r: "10",
|
|
99
|
-
stroke: "currentColor",
|
|
100
|
-
"stroke-width": "4"
|
|
101
|
-
}, null, -1),
|
|
102
|
-
c("path", {
|
|
103
|
-
class: "opacity-75",
|
|
104
|
-
fill: "currentColor",
|
|
105
|
-
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
106
|
-
}, null, -1)
|
|
107
|
-
])])) : C("", !0),
|
|
108
|
-
c("span", {
|
|
109
|
-
class: f(["inline-flex items-center gap-2", { invisible: n.loading }])
|
|
110
|
-
}, [
|
|
111
|
-
P(n.$slots, "default")
|
|
112
|
-
], 2)
|
|
113
|
-
], 10, z));
|
|
114
|
-
}
|
|
115
|
-
}), H = /* @__PURE__ */ m({
|
|
116
|
-
__name: "PropertyFieldRenderWrapper",
|
|
117
|
-
props: {
|
|
118
|
-
renderFn: { type: Function },
|
|
119
|
-
field: {},
|
|
120
|
-
value: {},
|
|
121
|
-
onChange: { type: Function },
|
|
122
|
-
onBlur: { type: Function },
|
|
123
|
-
class: {}
|
|
124
|
-
},
|
|
125
|
-
setup(e) {
|
|
126
|
-
const r = e, t = _(), o = () => {
|
|
127
|
-
if (t.value && r.renderFn) {
|
|
128
|
-
t.value.innerHTML = "";
|
|
129
|
-
const l = r.renderFn({
|
|
130
|
-
field: r.field,
|
|
131
|
-
value: r.value,
|
|
132
|
-
onChange: r.onChange,
|
|
133
|
-
onBlur: r.onBlur
|
|
134
|
-
});
|
|
135
|
-
t.value.appendChild(l);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
return F(() => {
|
|
139
|
-
o();
|
|
140
|
-
}), S(
|
|
141
|
-
() => r.value,
|
|
142
|
-
() => {
|
|
143
|
-
o();
|
|
144
|
-
}
|
|
145
|
-
), (l, d) => (u(), p("div", {
|
|
146
|
-
ref_key: "containerRef",
|
|
147
|
-
ref: t,
|
|
148
|
-
class: f(r.class)
|
|
149
|
-
}, null, 2));
|
|
150
|
-
}
|
|
151
|
-
}), E = {
|
|
152
|
-
key: 2,
|
|
153
|
-
class: "mb-4 p-3 bg-red-50 border border-red-200 rounded-md"
|
|
154
|
-
}, I = { class: "text-sm text-red-600" }, $ = { class: "font-mono" }, T = /* @__PURE__ */ m({
|
|
155
|
-
__name: "PropertyField",
|
|
156
|
-
props: {
|
|
157
|
-
field: {},
|
|
158
|
-
modelValue: {}
|
|
159
|
-
},
|
|
160
|
-
emits: ["update:modelValue"],
|
|
161
|
-
setup(e, { emit: r }) {
|
|
162
|
-
const t = e, o = r, { propertyFields: l } = M(), d = a(() => l.value.get(t.field.type)?.render), n = (i) => {
|
|
163
|
-
o("update:modelValue", i);
|
|
164
|
-
};
|
|
165
|
-
return (i, b) => {
|
|
166
|
-
const v = H;
|
|
167
|
-
return u(), p("div", null, [
|
|
168
|
-
s(g)(s(d)) || s(A)(s(d)) ? (u(), y(w(s(d)), {
|
|
169
|
-
key: 0,
|
|
170
|
-
field: i.field,
|
|
171
|
-
"model-value": i.modelValue,
|
|
172
|
-
"onUpdate:modelValue": n
|
|
173
|
-
}, null, 8, ["field", "model-value"])) : s(V)(s(d)) ? (u(), y(v, {
|
|
174
|
-
key: 1,
|
|
175
|
-
"render-fn": s(d),
|
|
176
|
-
field: i.field,
|
|
177
|
-
value: i.modelValue,
|
|
178
|
-
"on-change": n
|
|
179
|
-
}, null, 8, ["render-fn", "field", "value"])) : (u(), p("div", E, [
|
|
180
|
-
c("p", I, [
|
|
181
|
-
b[0] || (b[0] = x(" Unknown field type: ", -1)),
|
|
182
|
-
c("code", $, k(i.field.type), 1)
|
|
183
|
-
])
|
|
184
|
-
]))
|
|
185
|
-
]);
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
export {
|
|
190
|
-
B as C,
|
|
191
|
-
K as _,
|
|
192
|
-
T as a,
|
|
193
|
-
A as b,
|
|
194
|
-
V as c,
|
|
195
|
-
g as i,
|
|
196
|
-
M as u
|
|
197
|
-
};
|