@plitzi/sdk-style 0.33.2 → 0.34.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/CHANGELOG.md +26 -0
- package/dist/BuilderStyleContextProvider.d.ts +11 -2
- package/dist/BuilderStyleContextProvider.mjs +76 -54
- package/dist/SdkStyleContextProvider.mjs +4 -4
- package/dist/StyleAdvanceEditor.mjs +30 -30
- package/dist/StyleMap/StyleMap.d.ts +14 -1
- package/dist/StyleMap/StyleMap.mjs +24 -2
- package/dist/StyleMap/helpers/isValueValid.mjs +1 -1
- package/dist/StyleReducer.d.ts +15 -4
- package/dist/StyleReducer.mjs +39 -18
- package/dist/components/InputEasing/InputEasing.mjs +21 -21
- package/dist/components/InputEasing/InputEasingButton.mjs +5 -5
- package/dist/components/InputEasing/InputEasingList.mjs +76 -76
- package/dist/components/Selector/Selector.mjs +29 -29
- package/dist/components/Selector/SelectorItem/ItemOptions.mjs +16 -16
- package/dist/components/Selector/SelectorItem/SelectorItem.mjs +10 -10
- package/dist/components/StyleInspector/Inspector.mjs +33 -33
- package/dist/components/StyleInspector/StyleInspector.mjs +45 -45
- package/dist/components/StyleInspector/StyleInspectorProvider.mjs +14 -14
- package/dist/components/StyleInspector/categories/Background/components/BackgroundLayer/BackgroundLayer.mjs +46 -46
- package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopBar.mjs +20 -20
- package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopHandle.mjs +11 -11
- package/dist/components/StyleInspector/categories/Border/BorderPlacements.mjs +20 -20
- package/dist/components/StyleInspector/categories/DisplayFlexChild/DisplayAlignSelf.mjs +12 -12
- package/dist/components/StyleInspector/categories/Effects/BoxShadow/BoxShadow.mjs +22 -21
- package/dist/components/StyleInspector/categories/Effects/BoxShadow/BoxShadowItem.mjs +66 -65
- package/dist/components/StyleInspector/categories/Effects/BoxShadow/helpers.d.ts +2 -0
- package/dist/components/StyleInspector/categories/Effects/BoxShadow/helpers.mjs +18 -0
- package/dist/components/StyleInspector/categories/Effects/Transition/TransitionItem.mjs +15 -15
- package/dist/components/StyleInspector/categories/RawStyle/RawStyle.mjs +16 -16
- package/dist/components/StyleInspector/categories/Spacing/SpacingEditor.mjs +12 -12
- package/dist/components/StyleInspector/categories/Spacing/SpacingNumber.mjs +5 -5
- package/dist/components/StyleInspector/categories/Typography/Typography.d.ts +1 -5
- package/dist/components/StyleInspector/categories/Typography/Typography.mjs +58 -57
- package/dist/components/StyleInspector/categories/Typography/TypographyConstants.d.ts +0 -4
- package/dist/components/StyleInspector/categories/Typography/TypographyConstants.mjs +2 -160
- package/dist/components/StyleInspector/categories/Typography/TypographyFont.d.ts +1 -4
- package/dist/components/StyleInspector/categories/Typography/TypographyFont.mjs +24 -17
- package/dist/components/StyleInspector/components/CategoryContainer/CategoryContainer.mjs +15 -15
- package/dist/components/StyleInspector/components/CategoryOption/categoryTypes/OptionIconGroup.mjs +17 -17
- package/dist/components/StyleInspector/components/CategoryOption/categoryTypes/OptionMetricInput.mjs +8 -8
- package/dist/components/StyleInspector/components/CategoryOption/categoryTypes/OptionSelect.mjs +4 -4
- package/dist/components/StyleInspector/components/InspectorLabel/InspectorLabel.mjs +13 -13
- package/dist/components/StyleInspector/hooks/useInspectorValues.mjs +13 -13
- package/dist/components/StyleInspector/hooks/useStyleBinding.mjs +12 -12
- package/dist/components/StyleInspector/hooks/useStyleInherit.mjs +3 -3
- package/dist/components/StyleManager/ManagerSelector.mjs +35 -35
- package/dist/components/StyleManager/StyleManager.mjs +12 -12
- package/dist/components/StyleManager/StyleSelectorTag.mjs +20 -20
- package/dist/helpers/calculateInheriting.mjs +2 -2
- package/dist/helpers/generateStyleSelector.mjs +1 -1
- package/dist/helpers/processSelectorAttributes.mjs +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.mjs +2 -0
- package/dist/hooks/useSpaceFonts.d.ts +10 -0
- package/dist/hooks/useSpaceFonts.mjs +10 -0
- package/dist/index.mjs +16 -16
- package/package.json +26 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @plitzi/sdk-style
|
|
2
2
|
|
|
3
|
+
## 0.34.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- v0.34.1
|
|
8
|
+
- Updated dependencies [cba7b8b]
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @plitzi/sdk-variables@0.34.1
|
|
11
|
+
- @plitzi/sdk-plugins@0.34.1
|
|
12
|
+
- @plitzi/sdk-shared@0.34.1
|
|
13
|
+
|
|
14
|
+
## 0.34.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- v0.34.0
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [5aceda0]
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
- Updated dependencies [5aceda0]
|
|
25
|
+
- @plitzi/sdk-shared@0.34.0
|
|
26
|
+
- @plitzi/sdk-plugins@0.34.0
|
|
27
|
+
- @plitzi/sdk-variables@0.34.0
|
|
28
|
+
|
|
3
29
|
## 0.33.2
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { StyleReducerActions } from './StyleReducer';
|
|
3
|
-
import { ReducerMiddlewareCallback } from '@plitzi/plitzi-ui/hooks/useReducerWithMiddleware';
|
|
3
|
+
import { ReducerFilterCallback, ReducerMiddlewareCallback } from '@plitzi/plitzi-ui/hooks/useReducerWithMiddleware';
|
|
4
4
|
import { Style } from '@plitzi/sdk-shared';
|
|
5
|
+
/**
|
|
6
|
+
* A middleware and what it is shown. The filter belongs to the caller, not here: a save queue must never see another
|
|
7
|
+
* session's edit, and an undo history has to see it — it is how it learns its snapshots no longer describe the space.
|
|
8
|
+
* This provider deciding for both is what silently taught the history to ignore them.
|
|
9
|
+
*/
|
|
10
|
+
export type BuilderStyleMiddleware = {
|
|
11
|
+
middleware: ReducerMiddlewareCallback<Style, [action: StyleReducerActions]>;
|
|
12
|
+
filterCallback?: ReducerFilterCallback<[action: StyleReducerActions]>;
|
|
13
|
+
};
|
|
5
14
|
export type BuilderStyleContextProviderProps = {
|
|
6
15
|
children: React.ReactNode;
|
|
7
16
|
style?: Style;
|
|
8
17
|
includeSubscriptions?: boolean;
|
|
9
|
-
middlewares?:
|
|
18
|
+
middlewares?: BuilderStyleMiddleware[];
|
|
10
19
|
};
|
|
11
20
|
declare const BuilderStyleContextProvider: ({ children, style: styleProp, includeSubscriptions, middlewares: middlewaresProp }: BuilderStyleContextProviderProps) => React.JSX.Element;
|
|
12
21
|
export default BuilderStyleContextProvider;
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import t from "./
|
|
1
|
+
import e from "./StyleContext.mjs";
|
|
2
|
+
import { makeSelector as t } from "./StyleHelper.mjs";
|
|
3
3
|
import n, { StyleActions as r } from "./StyleReducer.mjs";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import u from "@plitzi/
|
|
8
|
-
import d from "@plitzi/sdk-
|
|
9
|
-
import f from "@plitzi/sdk-shared/
|
|
10
|
-
import {
|
|
4
|
+
import i from "@plitzi/plitzi-ui/hooks/useReducerWithMiddleware";
|
|
5
|
+
import { use as a, useCallback as o, useEffect as s, useMemo as c } from "react";
|
|
6
|
+
import l from "@plitzi/sdk-event-bridge/hooks/useEventBridge";
|
|
7
|
+
import u from "@plitzi/sdk-shared/network/NetworkContext";
|
|
8
|
+
import { useCommonStoreSync as d } from "@plitzi/sdk-shared/store";
|
|
9
|
+
import { EMPTY_STYLE_SCHEMA as f } from "@plitzi/sdk-shared/style/styleConstants";
|
|
10
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
11
11
|
//#region src/BuilderStyleContextProvider.tsx
|
|
12
12
|
var m = ({ children: m, style: h, includeSubscriptions: g = !0, middlewares: _ = [] }) => {
|
|
13
|
-
let { subscriptionManager: v } =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})), [_]), [b, x] = u(n, h ?? p, y);
|
|
17
|
-
l("style", b);
|
|
18
|
-
let S = a((e, t = !1) => x({
|
|
13
|
+
let { subscriptionManager: v } = a(u), [y, b] = i(n, h ?? f, _);
|
|
14
|
+
d("style", y);
|
|
15
|
+
let x = o((e, t = !1) => b({
|
|
19
16
|
type: r.STYLE_UPDATE,
|
|
20
17
|
style: e,
|
|
21
18
|
fromSubscriptions: t
|
|
22
|
-
}), [
|
|
23
|
-
n ||=
|
|
19
|
+
}), [b]), S = o((e, n, i, a, o, s, c = !1) => {
|
|
20
|
+
n ||= t(i), b({
|
|
24
21
|
type: r.STYLE_ADD_SELECTOR,
|
|
25
|
-
displayMode:
|
|
22
|
+
displayMode: e,
|
|
26
23
|
selector: n,
|
|
27
24
|
selectorType: i,
|
|
28
25
|
path: a,
|
|
@@ -30,7 +27,7 @@ var m = ({ children: m, style: h, includeSubscriptions: g = !0, middlewares: _ =
|
|
|
30
27
|
params: s,
|
|
31
28
|
fromSubscriptions: c
|
|
32
29
|
});
|
|
33
|
-
}, [
|
|
30
|
+
}, [b]), C = o((e, t, n, i, a, o = !1) => b({
|
|
34
31
|
type: r.STYLE_UPDATE_SELECTOR,
|
|
35
32
|
displayMode: e,
|
|
36
33
|
selector: t,
|
|
@@ -38,18 +35,18 @@ var m = ({ children: m, style: h, includeSubscriptions: g = !0, middlewares: _ =
|
|
|
38
35
|
value: i,
|
|
39
36
|
params: a,
|
|
40
37
|
fromSubscriptions: o
|
|
41
|
-
}), [
|
|
38
|
+
}), [b]), w = o((e, t, n = !1) => b({
|
|
42
39
|
type: r.STYLE_REMOVE_SELECTOR,
|
|
43
40
|
displayMode: e,
|
|
44
41
|
selector: t,
|
|
45
42
|
fromSubscriptions: n
|
|
46
|
-
}), [
|
|
43
|
+
}), [b]), T = o((e, t, n = !1) => b({
|
|
47
44
|
type: r.STYLE_REMOVE_SELECTORS,
|
|
48
45
|
displayMode: e,
|
|
49
46
|
selectors: t,
|
|
50
47
|
fromSubscriptions: n
|
|
51
|
-
}), [
|
|
52
|
-
|
|
48
|
+
}), [b]), E = o((e, t, n, i, a, o = !1) => {
|
|
49
|
+
b({
|
|
53
50
|
type: r.STYLE_ADD_SELECTOR_VARIABLE,
|
|
54
51
|
displayMode: e,
|
|
55
52
|
selector: t,
|
|
@@ -58,8 +55,8 @@ var m = ({ children: m, style: h, includeSubscriptions: g = !0, middlewares: _ =
|
|
|
58
55
|
value: a,
|
|
59
56
|
fromSubscriptions: o
|
|
60
57
|
});
|
|
61
|
-
}, [
|
|
62
|
-
|
|
58
|
+
}, [b]), D = o((e, t, n, i, a, o = !1) => {
|
|
59
|
+
b({
|
|
63
60
|
type: r.STYLE_UPDATE_SELECTOR_VARIABLE,
|
|
64
61
|
displayMode: e,
|
|
65
62
|
selector: t,
|
|
@@ -68,8 +65,8 @@ var m = ({ children: m, style: h, includeSubscriptions: g = !0, middlewares: _ =
|
|
|
68
65
|
value: a,
|
|
69
66
|
fromSubscriptions: o
|
|
70
67
|
});
|
|
71
|
-
}, [
|
|
72
|
-
|
|
68
|
+
}, [b]), O = o((e, t, n, i, a = !1) => {
|
|
69
|
+
b({
|
|
73
70
|
type: r.STYLE_REMOVE_SELECTOR_VARIABLE,
|
|
74
71
|
displayMode: e,
|
|
75
72
|
selector: t,
|
|
@@ -77,37 +74,50 @@ var m = ({ children: m, style: h, includeSubscriptions: g = !0, middlewares: _ =
|
|
|
77
74
|
name: i,
|
|
78
75
|
fromSubscriptions: a
|
|
79
76
|
});
|
|
80
|
-
}, [
|
|
77
|
+
}, [b]), k = o((e, t, n, i = !1) => b({
|
|
81
78
|
type: r.STYLE_ADD_VARIABLE,
|
|
82
79
|
category: e,
|
|
83
80
|
name: t,
|
|
84
81
|
value: n,
|
|
85
82
|
fromSubscriptions: i
|
|
86
|
-
}), [
|
|
83
|
+
}), [b]), A = o((e, t, n, i = !1) => b({
|
|
87
84
|
type: r.STYLE_UPDATE_VARIABLE,
|
|
88
85
|
category: e,
|
|
89
86
|
name: t,
|
|
90
87
|
value: n,
|
|
91
88
|
fromSubscriptions: i
|
|
92
|
-
}), [
|
|
89
|
+
}), [b]), j = o((e, t, n = !1) => b({
|
|
93
90
|
type: r.STYLE_REMOVE_VARIABLE,
|
|
94
91
|
category: e,
|
|
95
92
|
name: t,
|
|
96
93
|
fromSubscriptions: n
|
|
97
|
-
}), [
|
|
94
|
+
}), [b]), M = o((e, t = !1) => b({
|
|
95
|
+
type: r.STYLE_ADD_FONT,
|
|
96
|
+
font: e,
|
|
97
|
+
fromSubscriptions: t
|
|
98
|
+
}), [b]), N = o((e, t, n = !1) => b({
|
|
99
|
+
type: r.STYLE_UPDATE_FONT,
|
|
100
|
+
family: e,
|
|
101
|
+
font: t,
|
|
102
|
+
fromSubscriptions: n
|
|
103
|
+
}), [b]), P = o((e, t = !1) => b({
|
|
104
|
+
type: r.STYLE_REMOVE_FONT,
|
|
105
|
+
family: e,
|
|
106
|
+
fromSubscriptions: t
|
|
107
|
+
}), [b]), F = o((e, t = !1) => b({
|
|
98
108
|
type: r.STYLE_ADD_TEMPLATE,
|
|
99
109
|
platform: e,
|
|
100
110
|
fromSubscriptions: t
|
|
101
|
-
}), [
|
|
102
|
-
|
|
111
|
+
}), [b]), I = o((e, t, n = !1) => {
|
|
112
|
+
b({
|
|
103
113
|
type: r.STYLE_UPDATE_SETTINGS,
|
|
104
114
|
path: e,
|
|
105
115
|
value: t,
|
|
106
116
|
fromSubscriptions: n
|
|
107
117
|
});
|
|
108
|
-
}, [
|
|
109
|
-
|
|
110
|
-
if (g) return v.subscribe("STYLE_UPDATED", (e) =>
|
|
118
|
+
}, [b]);
|
|
119
|
+
s(() => {
|
|
120
|
+
if (g) return v.subscribe("STYLE_UPDATED", (e) => x(e, !0)), v.subscribe("STYLE_ADD_SELECTOR", ({ displayMode: e, selector: t, type: n, path: r, style: i, params: a }) => S(e, t, n, r, i, a, !0)), v.subscribe("STYLE_UPDATE_SELECTOR", ({ displayMode: e, selector: t, path: n, style: r, params: i }) => C(e, t, n, r, i, !0)), v.subscribe("STYLE_REMOVE_SELECTOR", ({ displayMode: e, selector: t }) => w(e, t, !0)), v.subscribe("STYLE_REMOVE_SELECTORS", ({ displayMode: e, selectors: t }) => T(e, t, !0)), v.subscribe("STYLE_ADD_SELECTOR_VARIABLE", ({ displayMode: e, selector: t, category: n, name: r, value: i }) => E(e, t, n, r, i, !0)), v.subscribe("STYLE_UPDATE_SELECTOR_VARIABLE", ({ displayMode: e, selector: t, category: n, name: r, value: i }) => D(e, t, n, r, i, !0)), v.subscribe("STYLE_REMOVE_SELECTOR_VARIABLE", ({ displayMode: e, selector: t, category: n, name: r }) => O(e, t, n, r, !0)), v.subscribe("STYLE_ADD_VARIABLE", ({ category: e, name: t, value: n }) => k(e, t, n, !0)), v.subscribe("STYLE_UPDATE_VARIABLE", ({ category: e, name: t, value: n }) => A(e, t, n, !0)), v.subscribe("STYLE_REMOVE_VARIABLE", ({ category: e, name: t }) => j(e, t, !0)), v.subscribe("STYLE_ADD_FONT", ({ font: e }) => M(e, !0)), v.subscribe("STYLE_UPDATE_FONT", ({ family: e, font: t }) => N(e, t, !0)), v.subscribe("STYLE_REMOVE_FONT", ({ family: e }) => P(e, !0)), v.subscribe("STYLE_UPDATE_SETTINGS", ({ path: e, value: t }) => I(e, t, !0)), () => v.unsubscribe([
|
|
111
121
|
"STYLE_UPDATED",
|
|
112
122
|
"STYLE_ADD_SELECTOR",
|
|
113
123
|
"STYLE_UPDATE_SELECTOR",
|
|
@@ -119,11 +129,15 @@ var m = ({ children: m, style: h, includeSubscriptions: g = !0, middlewares: _ =
|
|
|
119
129
|
"STYLE_ADD_VARIABLE",
|
|
120
130
|
"STYLE_UPDATE_VARIABLE",
|
|
121
131
|
"STYLE_REMOVE_VARIABLE",
|
|
132
|
+
"STYLE_ADD_FONT",
|
|
133
|
+
"STYLE_UPDATE_FONT",
|
|
134
|
+
"STYLE_REMOVE_FONT",
|
|
122
135
|
"STYLE_UPDATE_SETTINGS"
|
|
123
136
|
], !0);
|
|
124
137
|
}, [
|
|
125
138
|
v,
|
|
126
139
|
g,
|
|
140
|
+
x,
|
|
127
141
|
S,
|
|
128
142
|
C,
|
|
129
143
|
w,
|
|
@@ -135,23 +149,29 @@ var m = ({ children: m, style: h, includeSubscriptions: g = !0, middlewares: _ =
|
|
|
135
149
|
A,
|
|
136
150
|
j,
|
|
137
151
|
M,
|
|
138
|
-
|
|
152
|
+
N,
|
|
153
|
+
P,
|
|
154
|
+
I
|
|
139
155
|
]);
|
|
140
|
-
let
|
|
141
|
-
styleUpdate:
|
|
142
|
-
styleAddSelector:
|
|
143
|
-
styleUpdateSelector:
|
|
144
|
-
styleRemoveSelector:
|
|
145
|
-
styleRemoveSelectors:
|
|
146
|
-
styleAddSelectorVariable:
|
|
147
|
-
styleUpdateSelectorVariable:
|
|
148
|
-
styleRemoveSelectorVariable:
|
|
149
|
-
styleAddVariable:
|
|
150
|
-
styleUpdateVariable:
|
|
151
|
-
styleRemoveVariable:
|
|
152
|
-
|
|
153
|
-
|
|
156
|
+
let L = c(() => ({
|
|
157
|
+
styleUpdate: x,
|
|
158
|
+
styleAddSelector: S,
|
|
159
|
+
styleUpdateSelector: C,
|
|
160
|
+
styleRemoveSelector: w,
|
|
161
|
+
styleRemoveSelectors: T,
|
|
162
|
+
styleAddSelectorVariable: E,
|
|
163
|
+
styleUpdateSelectorVariable: D,
|
|
164
|
+
styleRemoveSelectorVariable: O,
|
|
165
|
+
styleAddVariable: k,
|
|
166
|
+
styleUpdateVariable: A,
|
|
167
|
+
styleRemoveVariable: j,
|
|
168
|
+
styleAddFont: M,
|
|
169
|
+
styleUpdateFont: N,
|
|
170
|
+
styleRemoveFont: P,
|
|
171
|
+
styleAddTemplate: F,
|
|
172
|
+
styleUpdateSettings: I
|
|
154
173
|
}), [
|
|
174
|
+
x,
|
|
155
175
|
S,
|
|
156
176
|
C,
|
|
157
177
|
w,
|
|
@@ -164,10 +184,12 @@ var m = ({ children: m, style: h, includeSubscriptions: g = !0, middlewares: _ =
|
|
|
164
184
|
j,
|
|
165
185
|
M,
|
|
166
186
|
N,
|
|
167
|
-
P
|
|
187
|
+
P,
|
|
188
|
+
F,
|
|
189
|
+
I
|
|
168
190
|
]);
|
|
169
|
-
return
|
|
170
|
-
value:
|
|
191
|
+
return l("main", L), /* @__PURE__ */ p(e, {
|
|
192
|
+
value: L,
|
|
171
193
|
children: m
|
|
172
194
|
});
|
|
173
195
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import e from "./StyleContext.mjs";
|
|
2
2
|
import { use as t, useMemo as n } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { useBuilderStoreSync as r } from "@plitzi/sdk-shared/store";
|
|
4
|
+
import { EMPTY_STYLE_SCHEMA as i } from "@plitzi/sdk-shared/style/styleConstants";
|
|
5
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
6
6
|
import o from "@plitzi/sdk-shared/network/NetworkInternalContext";
|
|
7
7
|
//#region src/SdkStyleContextProvider.tsx
|
|
8
8
|
var s = ({ children: s, style: c }) => {
|
|
9
9
|
let { style: l } = t(o), u = n(() => ({}), []);
|
|
10
|
-
return
|
|
10
|
+
return r("style", c ?? (l || i)), /* @__PURE__ */ a(e, {
|
|
11
11
|
value: u,
|
|
12
12
|
children: s
|
|
13
13
|
});
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import l from "
|
|
6
|
-
import
|
|
1
|
+
import { use as e, useCallback as t, useMemo as n, useState as r } from "react";
|
|
2
|
+
import i from "@plitzi/sdk-shared/network/NetworkContext";
|
|
3
|
+
import { useCommonStore as a } from "@plitzi/sdk-shared/store";
|
|
4
|
+
import { debounce as o, get as s } from "@plitzi/plitzi-ui/helpers";
|
|
5
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
6
|
+
import u from "@plitzi/plitzi-ui/Button";
|
|
7
7
|
import d from "@plitzi/plitzi-ui/CodeMirror";
|
|
8
|
-
import
|
|
9
|
-
import p from "@plitzi/sdk-shared/
|
|
10
|
-
import m from "@plitzi/sdk-shared/
|
|
11
|
-
import h from "@plitzi/sdk-shared/
|
|
8
|
+
import f from "@plitzi/plitzi-ui/ContainerFloating";
|
|
9
|
+
import p from "@plitzi/sdk-shared/hooks/useNetwork";
|
|
10
|
+
import m from "@plitzi/sdk-shared/schema/SchemaContext";
|
|
11
|
+
import h from "@plitzi/sdk-shared/theme/useTheme";
|
|
12
12
|
//#region src/StyleAdvanceEditor.tsx
|
|
13
13
|
var g = () => {
|
|
14
|
-
let {
|
|
14
|
+
let { resolvedTheme: g } = h(), [[_ = "", v = void 0]] = a(["schema.settings.customCss", "style.variables"]), { schemaUpdateSettings: y } = e(m), [b, x] = r(() => typeof _ == "string" ? _ : ""), S = n(() => y && o(y, 500), [y]), { server: C, webKey: w } = e(i), { networkQuery: T, networkLoading: E } = p({
|
|
15
15
|
initLoading: !1,
|
|
16
16
|
server: C,
|
|
17
17
|
webKey: w
|
|
18
|
-
}), D =
|
|
18
|
+
}), D = t((e) => {
|
|
19
19
|
S?.(e, "customCss"), x(e);
|
|
20
|
-
}, [x, S]), O =
|
|
20
|
+
}, [x, S]), O = t(async () => {
|
|
21
21
|
let e = await T("/utils/prettier-parser", {
|
|
22
22
|
data: b,
|
|
23
23
|
parser: "css"
|
|
24
24
|
}, "post");
|
|
25
25
|
if (!e || !e.data) return;
|
|
26
|
-
let
|
|
27
|
-
|
|
26
|
+
let t = s(e, "data", b);
|
|
27
|
+
t !== b && (x(t), S?.(t, "customCss"));
|
|
28
28
|
}, [
|
|
29
29
|
T,
|
|
30
30
|
b,
|
|
31
31
|
S
|
|
32
|
-
]), k =
|
|
32
|
+
]), k = n(() => v ? Object.keys(v).flatMap((e) => Object.keys(v[e] ?? {})).map((e) => ({
|
|
33
33
|
type: "css-token",
|
|
34
34
|
value: e
|
|
35
35
|
})) : [], [v]);
|
|
36
|
-
return /* @__PURE__ */
|
|
36
|
+
return /* @__PURE__ */ l("div", {
|
|
37
37
|
className: "relative flex h-full w-full flex-col",
|
|
38
|
-
children: [/* @__PURE__ */
|
|
38
|
+
children: [/* @__PURE__ */ c(d, {
|
|
39
39
|
className: "h-full",
|
|
40
40
|
value: b,
|
|
41
41
|
autoComplete: k,
|
|
42
|
-
theme: g
|
|
42
|
+
theme: g,
|
|
43
43
|
lineWrapping: !0,
|
|
44
44
|
onChange: D
|
|
45
|
-
}), /* @__PURE__ */
|
|
45
|
+
}), /* @__PURE__ */ l("div", {
|
|
46
46
|
className: "absolute top-3 right-3 flex",
|
|
47
|
-
children: [/* @__PURE__ */
|
|
47
|
+
children: [/* @__PURE__ */ c(u, {
|
|
48
48
|
intent: "custom",
|
|
49
49
|
size: "custom",
|
|
50
50
|
className: "mr-2 rounded-sm bg-white p-2 text-zinc-800 shadow dark:bg-zinc-700 dark:text-zinc-200",
|
|
51
51
|
onClick: O,
|
|
52
52
|
title: "Auto format",
|
|
53
53
|
disabled: E,
|
|
54
|
-
children: /* @__PURE__ */
|
|
55
|
-
}), /* @__PURE__ */
|
|
54
|
+
children: /* @__PURE__ */ c("i", { className: "fa-solid fa-wand-magic-sparkles" })
|
|
55
|
+
}), /* @__PURE__ */ l(f, {
|
|
56
56
|
containerLeftOffset: -208,
|
|
57
57
|
containerTopOffset: 4,
|
|
58
|
-
children: [/* @__PURE__ */
|
|
58
|
+
children: [/* @__PURE__ */ c(f.Trigger, { children: /* @__PURE__ */ c(u, {
|
|
59
59
|
intent: "custom",
|
|
60
60
|
size: "custom",
|
|
61
61
|
className: "rounded-sm bg-white p-2 text-zinc-800 shadow dark:bg-zinc-700 dark:text-zinc-200",
|
|
62
|
-
children: /* @__PURE__ */
|
|
63
|
-
}) }), /* @__PURE__ */
|
|
62
|
+
children: /* @__PURE__ */ c("i", { className: "fa-solid fa-circle-info" })
|
|
63
|
+
}) }), /* @__PURE__ */ c(f.Content, { children: /* @__PURE__ */ l("div", {
|
|
64
64
|
className: "flex w-60 flex-col items-center justify-center p-4 text-center text-zinc-700 dark:text-zinc-300",
|
|
65
65
|
children: [
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
/* @__PURE__ */
|
|
66
|
+
/* @__PURE__ */ c("p", { children: "Add your own CSS code here to customize the appearance and layout of your site." }),
|
|
67
|
+
/* @__PURE__ */ l("a", {
|
|
68
68
|
href: "https://codex.wordpress.org/CSS",
|
|
69
69
|
target: "_blank",
|
|
70
70
|
rel: "noopener noreferrer",
|
|
71
71
|
className: "text-blue-400 underline",
|
|
72
|
-
children: ["Learn more about CSS", /* @__PURE__ */
|
|
72
|
+
children: ["Learn more about CSS", /* @__PURE__ */ c("span", {
|
|
73
73
|
className: "text-sm",
|
|
74
74
|
children: " (opens in a new tab)"
|
|
75
75
|
})]
|
|
76
76
|
}),
|
|
77
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ l("p", { children: [/* @__PURE__ */ c("span", {
|
|
78
78
|
className: "font-bold",
|
|
79
79
|
children: "Ctrl + Space"
|
|
80
80
|
}), " to autocomplete."] })
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { DisplayMode, Style, StyleCategory, StyleItem, StyleObject, StyleState, StyleValue, StyleVariableCategory, StyleVariableValue, TagType } from '@plitzi/sdk-shared';
|
|
1
|
+
import { DisplayMode, SpaceFont, Style, StyleCategory, StyleItem, StyleObject, StyleState, StyleValue, StyleVariableCategory, StyleVariableValue, TagType } from '@plitzi/sdk-shared';
|
|
2
2
|
export type StyleMapProps = {
|
|
3
3
|
platform: Style['platform'];
|
|
4
4
|
variables?: Style['variables'];
|
|
5
|
+
fonts?: Style['fonts'];
|
|
5
6
|
};
|
|
6
7
|
declare class StyleMap {
|
|
7
8
|
platform: Style['platform'];
|
|
8
9
|
variables: Style['variables'];
|
|
10
|
+
fonts: SpaceFont[];
|
|
9
11
|
constructor(props: StyleMapProps);
|
|
10
12
|
static getInstance: (props: StyleMapProps) => StyleMap;
|
|
11
13
|
addSelector(displayMode: DisplayMode, selector: string, type: TagType, path: StyleCategory | undefined, value: StyleItem['attributes'] | Partial<StyleObject> | StyleValue | undefined, params: {
|
|
@@ -48,5 +50,16 @@ declare class StyleMap {
|
|
|
48
50
|
static updateVariable: (style: Pick<Style, "platform" | "variables">, category: StyleVariableCategory, name: string, value: StyleVariableValue) => boolean;
|
|
49
51
|
removeVariable: (category: StyleVariableCategory, name: string) => boolean;
|
|
50
52
|
static removeVariable: (style: Pick<Style, "platform" | "variables">, category: StyleVariableCategory, name: string) => boolean;
|
|
53
|
+
/** A family is the key: it is what `font-family` names, so a space cannot hold two of the same. */
|
|
54
|
+
addFont: (font: SpaceFont) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The write-back is what makes this work on a document that predates the manifest: there was no array to mutate,
|
|
57
|
+
* so the instance made one, and without this line the font would be added to something nobody holds.
|
|
58
|
+
*/
|
|
59
|
+
static addFont: (style: Pick<Style, "platform" | "variables" | "fonts">, font: SpaceFont) => boolean;
|
|
60
|
+
updateFont: (family: string, font: SpaceFont) => boolean;
|
|
61
|
+
static updateFont: (style: Pick<Style, "platform" | "variables" | "fonts">, family: string, font: SpaceFont) => boolean;
|
|
62
|
+
removeFont: (family: string) => boolean;
|
|
63
|
+
static removeFont: (style: Pick<Style, "platform" | "variables" | "fonts">, family: string) => boolean;
|
|
51
64
|
}
|
|
52
65
|
export default StyleMap;
|
|
@@ -7,10 +7,11 @@ import { get as i, set as a } from "@plitzi/plitzi-ui/helpers";
|
|
|
7
7
|
var o = class {
|
|
8
8
|
platform;
|
|
9
9
|
variables;
|
|
10
|
+
fonts;
|
|
10
11
|
constructor(e) {
|
|
11
|
-
let { platform: t, variables: n } = e;
|
|
12
|
+
let { platform: t, variables: n, fonts: r } = e;
|
|
12
13
|
if (!t) throw Error("Platform Required");
|
|
13
|
-
this.platform = t, this.variables = n ?? {};
|
|
14
|
+
this.platform = t, this.variables = n ?? {}, this.fonts = r ?? [];
|
|
14
15
|
}
|
|
15
16
|
static getInstance = (e) => new this(e);
|
|
16
17
|
addSelector(e, t, r, i, a, o) {
|
|
@@ -56,6 +57,27 @@ var o = class {
|
|
|
56
57
|
static updateVariable = (e, t, n, r) => this.getInstance(e).updateVariable(t, n, r);
|
|
57
58
|
removeVariable = (e, t) => !this.variables[e] || !this.variables[e][t] ? !1 : (delete this.variables[e][t], Object.keys(this.variables[e]).length === 0 && delete this.variables[e], !0);
|
|
58
59
|
static removeVariable = (e, t, n) => this.getInstance(e).removeVariable(t, n);
|
|
60
|
+
addFont = (e) => !this.fonts.some((t) => t.family === e.family) && (this.fonts.push(e), !0);
|
|
61
|
+
static addFont = (e, t) => {
|
|
62
|
+
let n = this.getInstance(e), r = n.addFont(t);
|
|
63
|
+
return e.fonts = n.fonts, r;
|
|
64
|
+
};
|
|
65
|
+
updateFont = (e, t) => {
|
|
66
|
+
let n = this.fonts.findIndex((t) => t.family === e);
|
|
67
|
+
return n === -1 || t.family !== e && this.fonts.some((e) => e.family === t.family) ? !1 : (this.fonts[n] = t, !0);
|
|
68
|
+
};
|
|
69
|
+
static updateFont = (e, t, n) => {
|
|
70
|
+
let r = this.getInstance(e), i = r.updateFont(t, n);
|
|
71
|
+
return e.fonts = r.fonts, i;
|
|
72
|
+
};
|
|
73
|
+
removeFont = (e) => {
|
|
74
|
+
let t = this.fonts.findIndex((t) => t.family === e);
|
|
75
|
+
return t !== -1 && (this.fonts.splice(t, 1), !0);
|
|
76
|
+
};
|
|
77
|
+
static removeFont = (e, t) => {
|
|
78
|
+
let n = this.getInstance(e), r = n.removeFont(t);
|
|
79
|
+
return e.fonts = n.fonts, r;
|
|
80
|
+
};
|
|
59
81
|
};
|
|
60
82
|
//#endregion
|
|
61
83
|
export { o as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/StyleMap/helpers/isValueValid.ts
|
|
2
2
|
var e = (e) => typeof e == "string" || typeof e == "number" || e === void 0, t = (e) => typeof e == "object" && !!e && !Array.isArray(e), n = (n) => t(n) && Object.values(n).every(e), r = (e) => t(e) && Object.values(e).every(n), i = (e) => t(e) && Object.values(e).every((e) => !(!t(e) || "variants" in e || "default" in e && e.default && !n(e.default) || "states" in e && e.states && !r(e.states))), a = (e) => !(!t(e) || !e.default || !n(e.default) || e.states && !r(e.states) || e.variants && !i(e.variants)), o = (e) => e === void 0 || t(e) && !Object.keys(e).length || t(e) && "base" in e && Object.values(e).every(a), s = (s, c, l) => {
|
|
3
3
|
let { styleSelector: u, styleVariant: d, styleState: f } = l ?? {};
|
|
4
|
-
return !s && !u && !d && !f ? o(c) : !s && !u && d && f ? !1 : !s && !u && d ? i(c) : !s && !u && f ? r(c) : s ? e(c) : u ? c === void 0 ? !0 : e(c) || !t(c) ? !1 : n(c) || a(c) : !1;
|
|
4
|
+
return !s && !u && !d && !f ? o(c) : !s && !u && d && f ? !1 : !s && !u && d ? i(c) : !s && !u && f ? r(c) : s ? e(c) : u ? c === void 0 ? !0 : e(c) || !t(c) ? !1 : n(c) || a(c) || a(c[u]) : !1;
|
|
5
5
|
};
|
|
6
6
|
//#endregion
|
|
7
7
|
export { s as default, o as isStyleAttributes, a as isStyleBlock, n as isStyleObject, r as isStyleStates, i as isStyleVariants };
|
package/dist/StyleReducer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DisplayMode, Style, StyleCategory, StyleItem, StyleState, StyleVariableCategory, StyleVariableValue, TagType } from '@plitzi/sdk-shared';
|
|
1
|
+
import { DisplayMode, ReducerActionOrigin, Style, StyleCategory, StyleItem, StyleState, SpaceFont, StyleVariableCategory, StyleVariableValue, TagType } from '@plitzi/sdk-shared';
|
|
2
2
|
export declare const StyleActions: {
|
|
3
3
|
readonly STYLE_UPDATE: "STYLE_UPDATE";
|
|
4
4
|
readonly STYLE_ADD_SELECTOR: "STYLE_ADD_SELECTOR";
|
|
@@ -11,12 +11,13 @@ export declare const StyleActions: {
|
|
|
11
11
|
readonly STYLE_ADD_VARIABLE: "STYLE_ADD_VARIABLE";
|
|
12
12
|
readonly STYLE_UPDATE_VARIABLE: "STYLE_UPDATE_VARIABLE";
|
|
13
13
|
readonly STYLE_REMOVE_VARIABLE: "STYLE_REMOVE_VARIABLE";
|
|
14
|
+
readonly STYLE_ADD_FONT: "STYLE_ADD_FONT";
|
|
15
|
+
readonly STYLE_UPDATE_FONT: "STYLE_UPDATE_FONT";
|
|
16
|
+
readonly STYLE_REMOVE_FONT: "STYLE_REMOVE_FONT";
|
|
14
17
|
readonly STYLE_ADD_TEMPLATE: "STYLE_ADD_TEMPLATE";
|
|
15
18
|
readonly STYLE_UPDATE_SETTINGS: "STYLE_UPDATE_SETTINGS";
|
|
16
19
|
};
|
|
17
|
-
export type StyleReducerActionsBase =
|
|
18
|
-
fromSubscriptions?: boolean;
|
|
19
|
-
};
|
|
20
|
+
export type StyleReducerActionsBase = ReducerActionOrigin;
|
|
20
21
|
export type StyleReducerActions = StyleReducerActionsBase & ({
|
|
21
22
|
type: 'STYLE_UPDATE';
|
|
22
23
|
style: Partial<Style>;
|
|
@@ -75,6 +76,16 @@ export type StyleReducerActions = StyleReducerActionsBase & ({
|
|
|
75
76
|
type: 'STYLE_REMOVE_VARIABLE';
|
|
76
77
|
category: StyleVariableCategory;
|
|
77
78
|
name: string;
|
|
79
|
+
} | {
|
|
80
|
+
type: 'STYLE_ADD_FONT';
|
|
81
|
+
font: SpaceFont;
|
|
82
|
+
} | {
|
|
83
|
+
type: 'STYLE_UPDATE_FONT';
|
|
84
|
+
family: string;
|
|
85
|
+
font: SpaceFont;
|
|
86
|
+
} | {
|
|
87
|
+
type: 'STYLE_REMOVE_FONT';
|
|
88
|
+
family: string;
|
|
78
89
|
} | {
|
|
79
90
|
type: 'STYLE_ADD_TEMPLATE';
|
|
80
91
|
platform: Style['platform'];
|