@craftile/editor 0.2.0 → 0.3.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/ui.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { default as Button } from './components/ui/Button.vue';
2
+ export { default as PropertyField } from './components/PropertyField.vue';
package/dist/ui.js CHANGED
@@ -1,4 +1,5 @@
1
- import { _ as r } from "./Button.vue_vue_type_script_setup_true_lang-C_TGGfLr.js";
1
+ import { _ as t, a } from "./PropertyField.vue_vue_type_script_setup_true_lang-D1Yv2X4j.js";
2
2
  export {
3
- r as Button
3
+ t as Button,
4
+ a as PropertyField
4
5
  };
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.2.0",
3
+ "version": "0.3.0",
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/core": "0.2.0",
42
- "@craftile/event-bus": "0.2.0",
43
- "@craftile/messenger": "0.2.0",
44
- "@craftile/types": "0.2.0"
41
+ "@craftile/core": "0.3.0",
42
+ "@craftile/event-bus": "0.3.0",
43
+ "@craftile/messenger": "0.3.0",
44
+ "@craftile/types": "0.3.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@ark-ui/vue": "^5.24.1",
@@ -1,70 +0,0 @@
1
- import { defineComponent as p, computed as f, createElementBlock as a, openBlock as n, unref as g, normalizeClass as r, createCommentVNode as b, createElementVNode as s, renderSlot as m } from "vue";
2
- const y = ["type", "disabled"], h = {
3
- key: 0,
4
- class: "animate-spin h-4 w-4 absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",
5
- xmlns: "http://www.w3.org/2000/svg",
6
- fill: "none",
7
- viewBox: "0 0 24 24"
8
- }, x = /* @__PURE__ */ p({
9
- __name: "Button",
10
- props: {
11
- variant: { default: "default" },
12
- size: { default: "md" },
13
- type: { default: "button" },
14
- disabled: { type: Boolean, default: !1 },
15
- fullWidth: { type: Boolean, default: !1 },
16
- square: { type: Boolean, default: !1 },
17
- loading: { type: Boolean, default: !1 }
18
- },
19
- setup(l) {
20
- const i = {
21
- default: "bg-white text-gray-900 hover:bg-gray-50 border border-gray-200",
22
- primary: "bg-primary text-primary-foreground hover:bg-primary/90",
23
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/90",
24
- accent: "bg-accent text-accent-foreground hover:bg-accent/90",
25
- sutble: "bg-accent-foreground text-accent",
26
- destructive: "bg-red-600 text-white hover:bg-red-700"
27
- }, d = {
28
- sm: "h-6 px-3 text-xs",
29
- md: "h-8 px-4",
30
- lg: "h-10 px-6 text-base"
31
- }, c = {
32
- sm: "w-6 h-6 text-xs p-0",
33
- md: "w-8 h-8 p-0",
34
- lg: "w-10 h-10 text-base p-0"
35
- }, t = l, u = f(() => t.disabled || t.loading);
36
- return (e, o) => (n(), a("button", {
37
- class: r(["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", [
38
- i[e.variant],
39
- t.square ? c[e.size] : d[e.size],
40
- e.fullWidth && "w-full"
41
- ]]),
42
- type: e.type,
43
- disabled: g(u)
44
- }, [
45
- e.loading ? (n(), a("svg", h, [...o[0] || (o[0] = [
46
- s("circle", {
47
- class: "opacity-25",
48
- cx: "12",
49
- cy: "12",
50
- r: "10",
51
- stroke: "currentColor",
52
- "stroke-width": "4"
53
- }, null, -1),
54
- s("path", {
55
- class: "opacity-75",
56
- fill: "currentColor",
57
- 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"
58
- }, null, -1)
59
- ])])) : b("", !0),
60
- s("span", {
61
- class: r(["inline-flex items-center gap-2", { invisible: e.loading }])
62
- }, [
63
- m(e.$slots, "default")
64
- ], 2)
65
- ], 10, y));
66
- }
67
- });
68
- export {
69
- x as _
70
- };