@plitzi/sdk-style 0.38.10 → 0.38.11

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.
Files changed (149) hide show
  1. package/CHANGELOG.md +180 -0
  2. package/dist/components/InputEasing/InputEasingButton.mjs +1 -1
  3. package/dist/components/InputEasing/InputEasingList.mjs +5 -5
  4. package/dist/components/Selector/Selector.mjs +2 -1
  5. package/dist/components/Selector/SelectorItem/ItemOptions.mjs +45 -41
  6. package/dist/components/Selector/SelectorItem/SelectorItem.mjs +4 -4
  7. package/dist/components/Selector/SelectorItem/helpers.d.ts +2 -0
  8. package/dist/components/Selector/SelectorItem/helpers.mjs +4 -0
  9. package/dist/components/StyleInspector/Inspector.mjs +185 -171
  10. package/dist/components/StyleInspector/InspectorSearchContext.d.ts +3 -0
  11. package/dist/components/StyleInspector/InspectorSearchContext.mjs +6 -0
  12. package/dist/components/StyleInspector/StyleInspector.mjs +154 -128
  13. package/dist/components/StyleInspector/categories/Background/Background.mjs +82 -114
  14. package/dist/components/StyleInspector/categories/Background/components/BackgroundAttachment/BackgroundAttachment.d.ts +8 -0
  15. package/dist/components/StyleInspector/categories/Background/components/BackgroundAttachment/BackgroundAttachment.mjs +53 -0
  16. package/dist/components/StyleInspector/categories/Background/components/BackgroundAttachment/index.d.ts +3 -0
  17. package/dist/components/StyleInspector/categories/Background/components/BackgroundAttachment/index.mjs +5 -0
  18. package/dist/components/StyleInspector/categories/Background/components/BackgroundLayer/BackgroundLayer.mjs +159 -153
  19. package/dist/components/StyleInspector/categories/Background/components/BackgroundLayer/helpers.d.ts +11 -0
  20. package/dist/components/StyleInspector/categories/Background/components/BackgroundLayer/helpers.mjs +45 -0
  21. package/dist/components/StyleInspector/categories/Background/components/BackgroundPosition/BackgroundPosition.mjs +26 -23
  22. package/dist/components/StyleInspector/categories/Background/components/BackgroundSize/BackgroundSize.mjs +65 -56
  23. package/dist/components/StyleInspector/categories/Background/components/BackgroundSize/helpers.d.ts +4 -0
  24. package/dist/components/StyleInspector/categories/Background/components/BackgroundSize/helpers.mjs +8 -0
  25. package/dist/components/StyleInspector/categories/Background/components/BackgroundTile/BackgroundTile.mjs +28 -27
  26. package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/GradientPreviewBar.d.ts +4 -2
  27. package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/GradientPreviewBar.mjs +19 -18
  28. package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopBar.d.ts +4 -0
  29. package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopBar.mjs +48 -80
  30. package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopEditor.d.ts +5 -3
  31. package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopEditor.mjs +51 -41
  32. package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopHandle.d.ts +5 -1
  33. package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopHandle.mjs +54 -32
  34. package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopTrack.d.ts +3 -1
  35. package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopTrack.mjs +14 -13
  36. package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/helpers.d.ts +8 -0
  37. package/dist/components/StyleInspector/categories/Background/components/GradientStopBar/helpers.mjs +8 -0
  38. package/dist/components/StyleInspector/categories/Background/components/LayerGroup/LayerGroup.d.ts +8 -0
  39. package/dist/components/StyleInspector/categories/Background/components/LayerGroup/LayerGroup.mjs +11 -0
  40. package/dist/components/StyleInspector/categories/Background/components/LayerGroup/index.d.ts +3 -0
  41. package/dist/components/StyleInspector/categories/Background/components/LayerGroup/index.mjs +5 -0
  42. package/dist/components/StyleInspector/categories/Background/helpers/backgroundParser.d.ts +21 -7
  43. package/dist/components/StyleInspector/categories/Background/helpers/backgroundParser.mjs +114 -113
  44. package/dist/components/StyleInspector/categories/Background/helpers/layerValues.d.ts +8 -0
  45. package/dist/components/StyleInspector/categories/Background/helpers/layerValues.mjs +11 -0
  46. package/dist/components/StyleInspector/categories/Background/modes/ConicGradientMode.mjs +52 -87
  47. package/dist/components/StyleInspector/categories/Background/modes/ImageMode.mjs +16 -77
  48. package/dist/components/StyleInspector/categories/Background/modes/LinearGradientMode.mjs +19 -62
  49. package/dist/components/StyleInspector/categories/Background/modes/RadialGradientMode.mjs +79 -97
  50. package/dist/components/StyleInspector/categories/Background/modes/RawMode.d.ts +8 -0
  51. package/dist/components/StyleInspector/categories/Background/modes/RawMode.mjs +22 -0
  52. package/dist/components/StyleInspector/categories/Background/modes/helpers.d.ts +19 -0
  53. package/dist/components/StyleInspector/categories/Background/modes/helpers.mjs +54 -0
  54. package/dist/components/StyleInspector/categories/Border/Border.mjs +26 -43
  55. package/dist/components/StyleInspector/categories/Border/BorderPlacements.mjs +60 -51
  56. package/dist/components/StyleInspector/categories/Display/Display.mjs +32 -49
  57. package/dist/components/StyleInspector/categories/DisplayFlexChild/DisplayFlexChild.mjs +33 -38
  58. package/dist/components/StyleInspector/categories/Effects/BoxShadow/BoxShadow.mjs +21 -33
  59. package/dist/components/StyleInspector/categories/Effects/Effects.mjs +131 -154
  60. package/dist/components/StyleInspector/categories/Effects/Filters/Filter.mjs +23 -31
  61. package/dist/components/StyleInspector/categories/Effects/Filters/FilterItem.d.ts +9 -5
  62. package/dist/components/StyleInspector/categories/Effects/Filters/FilterItem.mjs +57 -124
  63. package/dist/components/StyleInspector/categories/Effects/Filters/helpers.d.ts +25 -0
  64. package/dist/components/StyleInspector/categories/Effects/Filters/helpers.mjs +87 -0
  65. package/dist/components/StyleInspector/categories/Effects/Transform/Transform.mjs +18 -28
  66. package/dist/components/StyleInspector/categories/Effects/Transform/TransformItem.d.ts +1 -2
  67. package/dist/components/StyleInspector/categories/Effects/Transform/TransformItem.mjs +52 -76
  68. package/dist/components/StyleInspector/categories/Effects/Transform/transformFunctions.d.ts +5 -0
  69. package/dist/components/StyleInspector/categories/Effects/Transform/transformFunctions.mjs +8 -2
  70. package/dist/components/StyleInspector/categories/Effects/Transition/Transition.mjs +21 -37
  71. package/dist/components/StyleInspector/categories/Effects/Transition/TransitionEasing.d.ts +10 -0
  72. package/dist/components/StyleInspector/categories/Effects/Transition/TransitionEasing.mjs +92 -0
  73. package/dist/components/StyleInspector/categories/Effects/Transition/TransitionItem.d.ts +4 -4
  74. package/dist/components/StyleInspector/categories/Effects/Transition/TransitionItem.mjs +78 -359
  75. package/dist/components/StyleInspector/categories/Effects/Transition/helpers.d.ts +39 -0
  76. package/dist/components/StyleInspector/categories/Effects/Transition/helpers.mjs +268 -0
  77. package/dist/components/StyleInspector/categories/List/List.mjs +39 -38
  78. package/dist/components/StyleInspector/categories/ListItem/ListItem.mjs +29 -29
  79. package/dist/components/StyleInspector/categories/Others/Others.mjs +66 -88
  80. package/dist/components/StyleInspector/categories/Position/Position.mjs +67 -75
  81. package/dist/components/StyleInspector/categories/RawStyle/RawStyle.mjs +19 -18
  82. package/dist/components/StyleInspector/categories/Size/Size.mjs +68 -88
  83. package/dist/components/StyleInspector/categories/Spacing/Spacing.mjs +18 -27
  84. package/dist/components/StyleInspector/categories/Spacing/SpacingMargin.mjs +2 -2
  85. package/dist/components/StyleInspector/categories/Spacing/SpacingPadding.mjs +4 -3
  86. package/dist/components/StyleInspector/categories/Typography/Typography.mjs +88 -98
  87. package/dist/components/StyleInspector/categories/Typography/TypographyFont.mjs +1 -1
  88. package/dist/components/StyleInspector/categories/Typography/TypographyStyle.mjs +1 -1
  89. package/dist/components/StyleInspector/categories/Typography/TypographyTextShadow.mjs +26 -39
  90. package/dist/components/StyleInspector/categories/Variables/Variables.mjs +38 -37
  91. package/dist/components/StyleInspector/categoryKeys.d.ts +45 -0
  92. package/dist/components/StyleInspector/categoryKeys.mjs +220 -0
  93. package/dist/components/StyleInspector/components/CategoryContainer/CategoryContainer.mjs +43 -38
  94. package/dist/components/StyleInspector/components/CategoryOption/categoryTypes/OptionIconGroup.mjs +2 -1
  95. package/dist/components/StyleInspector/components/CategorySection/CategorySection.mjs +30 -15
  96. package/dist/components/StyleInspector/components/ColorSwatch/ColorSwatch.d.ts +8 -0
  97. package/dist/components/StyleInspector/components/ColorSwatch/ColorSwatch.mjs +23 -0
  98. package/dist/components/StyleInspector/components/ColorSwatch/helpers.d.ts +3 -0
  99. package/dist/components/StyleInspector/components/ColorSwatch/helpers.mjs +9 -0
  100. package/dist/components/StyleInspector/components/ColorSwatch/index.d.ts +3 -0
  101. package/dist/components/StyleInspector/components/ColorSwatch/index.mjs +5 -0
  102. package/dist/components/StyleInspector/components/InspectorDots/InspectorDots.d.ts +1 -0
  103. package/dist/components/StyleInspector/components/InspectorDots/InspectorDots.mjs +11 -11
  104. package/dist/components/StyleInspector/components/InspectorFooter/InspectorFooter.d.ts +11 -0
  105. package/dist/components/StyleInspector/components/InspectorFooter/InspectorFooter.mjs +38 -0
  106. package/dist/components/StyleInspector/components/InspectorFooter/helpers.d.ts +2 -0
  107. package/dist/components/StyleInspector/components/InspectorFooter/helpers.mjs +11 -0
  108. package/dist/components/StyleInspector/components/InspectorFooter/index.d.ts +3 -0
  109. package/dist/components/StyleInspector/components/InspectorFooter/index.mjs +5 -0
  110. package/dist/components/StyleInspector/components/InspectorLabel/InspectorLabel.mjs +34 -31
  111. package/dist/components/StyleInspector/components/InspectorLabel/helpers.d.ts +17 -0
  112. package/dist/components/StyleInspector/components/InspectorLabel/helpers.mjs +16 -0
  113. package/dist/components/StyleInspector/components/InspectorSearch/InspectorSearch.d.ts +7 -0
  114. package/dist/components/StyleInspector/components/InspectorSearch/InspectorSearch.mjs +24 -0
  115. package/dist/components/StyleInspector/components/InspectorSearch/index.d.ts +3 -0
  116. package/dist/components/StyleInspector/components/InspectorSearch/index.mjs +5 -0
  117. package/dist/components/StyleInspector/components/ShadowItem/ShadowItem.d.ts +9 -0
  118. package/dist/components/StyleInspector/components/ShadowItem/ShadowItem.mjs +110 -0
  119. package/dist/components/StyleInspector/components/ShadowItem/index.d.ts +3 -0
  120. package/dist/components/StyleInspector/components/ShadowItem/index.mjs +5 -0
  121. package/dist/components/StyleInspector/components/TargetSummary/TargetSummary.d.ts +7 -0
  122. package/dist/components/StyleInspector/components/TargetSummary/TargetSummary.mjs +24 -0
  123. package/dist/components/StyleInspector/components/TargetSummary/index.d.ts +3 -0
  124. package/dist/components/StyleInspector/components/TargetSummary/index.mjs +5 -0
  125. package/dist/components/StyleInspector/components/ValueList/ValueList.d.ts +12 -0
  126. package/dist/components/StyleInspector/components/ValueList/ValueList.mjs +25 -0
  127. package/dist/components/StyleInspector/components/ValueList/index.d.ts +3 -0
  128. package/dist/components/StyleInspector/components/ValueList/index.mjs +5 -0
  129. package/dist/components/StyleInspector/components/ValueListItem/ValueListItem.d.ts +16 -0
  130. package/dist/components/StyleInspector/components/ValueListItem/ValueListItem.mjs +71 -0
  131. package/dist/components/StyleInspector/components/ValueListItem/index.d.ts +3 -0
  132. package/dist/components/StyleInspector/components/ValueListItem/index.mjs +5 -0
  133. package/dist/components/StyleInspector/cssValues.d.ts +15 -0
  134. package/dist/components/StyleInspector/cssValues.mjs +27 -0
  135. package/dist/components/StyleInspector/helpers.d.ts +17 -1
  136. package/dist/components/StyleInspector/helpers.mjs +9 -2
  137. package/dist/components/StyleInspector/hooks/useInspectorValues.mjs +42 -45
  138. package/dist/components/StyleInspector/search.d.ts +11 -0
  139. package/dist/components/StyleInspector/search.mjs +14 -0
  140. package/dist/components/StyleInspector/shadowValue.d.ts +20 -0
  141. package/dist/components/StyleInspector/shadowValue.mjs +36 -0
  142. package/dist/components/StyleManager/StyleSelectorTag.mjs +1 -1
  143. package/package.json +185 -17
  144. package/dist/components/StyleInspector/categories/Effects/BoxShadow/BoxShadowItem.d.ts +0 -8
  145. package/dist/components/StyleInspector/categories/Effects/BoxShadow/BoxShadowItem.mjs +0 -132
  146. package/dist/components/StyleInspector/categories/Effects/BoxShadow/helpers.d.ts +0 -2
  147. package/dist/components/StyleInspector/categories/Effects/BoxShadow/helpers.mjs +0 -18
  148. package/dist/components/StyleInspector/categories/Typography/TypographyTextShadowItem.d.ts +0 -8
  149. package/dist/components/StyleInspector/categories/Typography/TypographyTextShadowItem.mjs +0 -83
@@ -1,16 +1,27 @@
1
1
  export type GradientStop = {
2
2
  id: string;
3
3
  color: string;
4
+ /** Empty, one position or two (`10% 20%`, a hard band) — as written. */
4
5
  position: string;
5
6
  };
6
- export type BackgroundLayerType = 'none' | 'url' | 'linear-gradient' | 'radial-gradient' | 'conic-gradient';
7
+ /**
8
+ * What a layer is. `raw` is any image the editor has no controls for — a token standing for it, `image-set()`,
9
+ * `cross-fade()` — kept word for word, so editing another layer never rewrites it into something else.
10
+ */
11
+ export type BackgroundLayerType = 'none' | 'url' | 'linear-gradient' | 'radial-gradient' | 'conic-gradient' | 'raw';
7
12
  export type BackgroundLayer = {
8
13
  id: string;
9
14
  type: BackgroundLayerType;
10
15
  url: string;
16
+ raw: string;
17
+ /** A gradient's `repeating-` form. */
18
+ repeating: boolean;
19
+ /** Empty for CSS's default (to bottom), which is then not written. */
11
20
  angle: string;
12
21
  radialShape: 'circle' | 'ellipse';
22
+ /** A keyword (`closest-side`…) or an explicit size (`100px`, `40% 20%`). */
13
23
  radialExtent: string;
24
+ /** Empty for CSS's default (center). */
14
25
  radialPosition: string;
15
26
  conicAngle: string;
16
27
  conicPosition: string;
@@ -23,8 +34,17 @@ export type BackgroundLayer = {
23
34
  clip: string;
24
35
  };
25
36
  export declare const DEFAULT_STOPS: GradientStop[];
37
+ /** What a layer added in the editor starts as — a gradient or a picture placed once, not tiled. */
26
38
  export declare const DEFAULT_LAYER_PROPS: {
39
+ repeat: string;
40
+ size: string;
41
+ positionX: string;
42
+ positionY: string;
43
+ attachment: string;
44
+ clip: string;
27
45
  url: string;
46
+ raw: string;
47
+ repeating: boolean;
28
48
  angle: string;
29
49
  radialShape: "ellipse";
30
50
  radialExtent: string;
@@ -32,12 +52,6 @@ export declare const DEFAULT_LAYER_PROPS: {
32
52
  conicAngle: string;
33
53
  conicPosition: string;
34
54
  stops: GradientStop[];
35
- size: string;
36
- positionX: string;
37
- positionY: string;
38
- repeat: string;
39
- attachment: string;
40
- clip: string;
41
55
  };
42
56
  export declare const newLayerId: () => string;
43
57
  export declare const newStopId: () => string;
@@ -1,5 +1,6 @@
1
+ import { splitBySpaceOutsideParens as e } from "../../../cssValues.mjs";
1
2
  //#region src/components/StyleInspector/categories/Background/helpers/backgroundParser.ts
2
- var e = [{
3
+ var t = [{
3
4
  id: "stop-default-0",
4
5
  color: "#000000",
5
6
  position: "0%"
@@ -7,161 +8,161 @@ var e = [{
7
8
  id: "stop-default-1",
8
9
  color: "#ffffff",
9
10
  position: "100%"
10
- }], t = {
11
- url: "",
12
- angle: "180deg",
13
- radialShape: "ellipse",
14
- radialExtent: "farthest-corner",
15
- radialPosition: "50% 50%",
16
- conicAngle: "0deg",
17
- conicPosition: "50% 50%",
18
- stops: e,
11
+ }], n = {
19
12
  size: "auto",
20
13
  positionX: "0%",
21
14
  positionY: "0%",
22
- repeat: "no-repeat",
15
+ repeat: "repeat",
23
16
  attachment: "scroll",
24
17
  clip: "border-box"
25
- }, n = 0, r = () => `layer-${++n}`, i = () => `stop-${++n}`;
26
- function a(e) {
18
+ }, r = {
19
+ url: "",
20
+ raw: "",
21
+ repeating: !1,
22
+ angle: "",
23
+ radialShape: "ellipse",
24
+ radialExtent: "farthest-corner",
25
+ radialPosition: "",
26
+ conicAngle: "0deg",
27
+ conicPosition: "",
28
+ stops: t,
29
+ ...n,
30
+ repeat: "no-repeat"
31
+ }, i = 0, a = () => `layer-${++i}`, o = () => `stop-${++i}`;
32
+ function s(e) {
27
33
  let t = [], n = 0, r = "";
28
34
  for (let i of e) i === "(" ? n++ : i === ")" && n--, i === "," && n === 0 ? (t.push(r.trim()), r = "") : r += i;
29
35
  return r.trim() && t.push(r.trim()), t;
30
36
  }
31
- function o(e) {
32
- let t = e.trim(), n = 0, r = -1;
33
- for (let e = 0; e < t.length; e++) t[e] === "(" ? n++ : t[e] === ")" ? n-- : t[e] === " " && n === 0 && (r = e);
34
- if (r !== -1) {
35
- let e = t.slice(r + 1).trim();
36
- if (/^-?[\d.]/.test(e) || /\d(px|em|rem|%|vw|vh|dvh|dvw|lvh|lvw|fr|ch|ex)$/.test(e)) return {
37
- color: t.slice(0, r).trim(),
38
- position: e
39
- };
40
- }
37
+ var c = /^[-+]?(\d|\.\d)[\w.%]*$|^calc\(/i, l = /^[-+]?(\d|\.\d)[\d.]*(deg|rad|turn|grad)?$/i, u = (e) => c.test(e);
38
+ function d(t) {
39
+ let n = e(t.trim()), r = n.length;
40
+ for (; r > 1 && u(n[r - 1]);) r--;
41
41
  return {
42
- color: t,
43
- position: ""
42
+ color: n.slice(0, r).join(" "),
43
+ position: n.slice(r).join(" ")
44
44
  };
45
45
  }
46
- function s(e) {
47
- return a(e).map((e) => ({
48
- id: i(),
49
- ...o(e)
46
+ function f(e) {
47
+ return e.map((e) => ({
48
+ id: o(),
49
+ ...d(e)
50
50
  }));
51
51
  }
52
- function c(e) {
53
- let n = a(e), r = (n[0] ?? "").trim(), i = /^\d/.test(r) || r.startsWith("to ");
52
+ function p(e) {
53
+ let t = s(e), n = (t[0] ?? "").trim(), r = l.test(n) || n.startsWith("to ");
54
54
  return {
55
- angle: i ? r : t.angle,
56
- stops: s(n.slice(+!!i).join(", "))
55
+ angle: r ? n : "",
56
+ stops: f(t.slice(+!!r))
57
57
  };
58
58
  }
59
- function l(e) {
60
- let n = a(e), r = (n[0] ?? "").trim(), i = t.radialShape, o = t.radialExtent, c = t.radialPosition, l = 0;
61
- if (/circle|ellipse|closest|farthest|at\s/.test(r)) {
62
- l = 1, r.includes("circle") && (i = "circle"), r.includes("ellipse") && (i = "ellipse"), r.includes("closest-side") ? o = "closest-side" : r.includes("closest-corner") ? o = "closest-corner" : r.includes("farthest-side") ? o = "farthest-side" : r.includes("farthest-corner") && (o = "farthest-corner");
63
- let e = r.match(/at\s+(.+)$/);
64
- e && (c = e[1].trim());
65
- }
66
- let u = n.slice(l).join(", ");
59
+ var m = /^(circle|ellipse|closest-|farthest-|at\s)|\sat\s/;
60
+ function h(t) {
61
+ let n = s(t), i = (n[0] ?? "").trim();
62
+ if (!(m.test(i) || u(e(i)[0] ?? ""))) return { stops: f(n) };
63
+ let [a, o = ""] = i.startsWith("at ") ? ["", i.slice(3)] : i.split(/\s+at\s+/), c = e(a), l = c.find((e) => e === "circle" || e === "ellipse"), d = c.filter((e) => e !== "circle" && e !== "ellipse").join(" ");
67
64
  return {
68
- radialShape: i,
69
- radialExtent: o,
70
- radialPosition: c,
71
- stops: s(u)
65
+ radialShape: l === "circle" ? "circle" : "ellipse",
66
+ radialExtent: d || r.radialExtent,
67
+ radialPosition: o.trim(),
68
+ stops: f(n.slice(1))
72
69
  };
73
70
  }
74
- function u(e) {
75
- let n = a(e), r = (n[0] ?? "").trim(), i = t.conicAngle, o = t.conicPosition, c = 0;
76
- if (r.startsWith("from ") || r.startsWith("at ")) {
77
- c = 1;
78
- let e = r.match(/from\s+([\d.]+(?:deg|rad|turn|grad))/);
79
- e && (i = e[1]);
80
- let t = r.match(/at\s+(.+?)(?:\s+from|$)/);
81
- t && (o = t[1].trim());
82
- }
83
- let l = n.slice(c).join(", ");
84
- return {
85
- conicAngle: i,
86
- conicPosition: o,
87
- stops: s(l)
71
+ function g(e) {
72
+ let t = s(e), n = (t[0] ?? "").trim();
73
+ return !n.startsWith("from ") && !n.startsWith("at ") ? { stops: f(t) } : {
74
+ conicAngle: /from\s+(\S+)/.exec(n)?.[1] ?? r.conicAngle,
75
+ conicPosition: /at\s+(.+?)(?:\s+from\s|$)/.exec(n)?.[1].trim() ?? "",
76
+ stops: f(t.slice(1))
88
77
  };
89
78
  }
90
- function d(e) {
79
+ var _ = /^(repeating-)?(linear|radial|conic)-gradient\(([\s\S]+)\)$/i, v = /^url\(\s*(?:"(.*)"|'(.*)'|(.*?))\s*\)$/i;
80
+ function y(e) {
91
81
  let t = e.trim();
92
82
  if (!t || t === "none") return { type: "none" };
93
- let n = t.match(/^url\("(.*)"\)$/i);
83
+ let n = v.exec(t);
94
84
  if (n) return {
95
85
  type: "url",
96
- url: n[1]
97
- };
98
- let r = t.match(/^url\('(.*)'\)$/i);
99
- if (r) return {
100
- type: "url",
101
- url: r[1]
86
+ url: n.slice(1).find(Boolean) ?? ""
102
87
  };
103
- let i = t.match(/^url\((.*)\)$/i);
104
- if (i) return {
105
- type: "url",
106
- url: i[1]
88
+ let r = _.exec(t);
89
+ if (!r) return {
90
+ type: "raw",
91
+ raw: t
107
92
  };
108
- let a = t.match(/^linear-gradient\(([\s\S]+)\)$/i);
109
- if (a) return {
93
+ let i = !!r[1], a = r[2].toLowerCase();
94
+ return a === "linear" ? {
110
95
  type: "linear-gradient",
111
- ...c(a[1])
112
- };
113
- let o = t.match(/^radial-gradient\(([\s\S]+)\)$/i);
114
- if (o) return {
96
+ repeating: i,
97
+ ...p(r[3])
98
+ } : a === "radial" ? {
115
99
  type: "radial-gradient",
116
- ...l(o[1])
117
- };
118
- let s = t.match(/^conic-gradient\(([\s\S]+)\)$/i);
119
- return s ? {
100
+ repeating: i,
101
+ ...h(r[3])
102
+ } : {
120
103
  type: "conic-gradient",
121
- ...u(s[1])
122
- } : { type: "none" };
104
+ repeating: i,
105
+ ...g(r[3])
106
+ };
123
107
  }
124
- function f(e) {
125
- let n = (e["background-image"] ?? "").trim();
126
- if (!n || n === "none") return [];
127
- let i = a(n), o = a(e["background-size"] ?? ""), s = a(e["background-position"] ?? ""), c = a(e["background-repeat"] ?? ""), l = a(e["background-attachment"] ?? ""), u = a(e["background-clip"] ?? "");
128
- return i.map((e, n) => {
129
- let i = d(e), a = (s[n] ?? "").split(" ").filter(Boolean);
108
+ var b = /* @__PURE__ */ new Set(["top", "bottom"]), x = /* @__PURE__ */ new Set(["left", "right"]), S = (t) => {
109
+ let r = e(t ?? "");
110
+ if (r.length === 0) return [n.positionX, n.positionY];
111
+ if (r.length === 1) return b.has(r[0]) ? ["center", r[0]] : [r[0], "center"];
112
+ if (r.length === 2) {
113
+ let [e, t] = r;
114
+ return b.has(e) || x.has(t) ? [t, e] : [e, t];
115
+ }
116
+ return r.length === 3 ? u(r[1]) ? [`${r[0]} ${r[1]}`, r[2]] : [r[0], `${r[1]} ${r[2]}`] : [`${r[0]} ${r[1]}`, r.slice(2).join(" ")];
117
+ }, C = (e, t) => e.length > 0 ? e[t % e.length] : void 0;
118
+ function w(e) {
119
+ let t = (e["background-image"] ?? "").trim();
120
+ if (!t || t === "none") return [];
121
+ let i = s(t), o = s(e["background-size"] ?? ""), c = s(e["background-position"] ?? ""), l = s(e["background-repeat"] ?? ""), u = s(e["background-attachment"] ?? ""), d = s(e["background-clip"] ?? "");
122
+ return i.map((e, t) => {
123
+ let [i, s] = S(C(c, t));
130
124
  return {
131
- ...t,
132
- ...i,
133
- id: r(),
134
- size: o[n] ?? t.size,
135
- positionX: a.at(0) ?? t.positionX,
136
- positionY: a.at(1) ?? a.at(0) ?? t.positionY,
137
- repeat: c[n] ?? t.repeat,
138
- attachment: l[n] ?? t.attachment,
139
- clip: u[n] ?? t.clip
125
+ ...r,
126
+ ...y(e),
127
+ id: a(),
128
+ size: C(o, t) ?? n.size,
129
+ positionX: i,
130
+ positionY: s,
131
+ repeat: C(l, t) ?? n.repeat,
132
+ attachment: C(u, t) ?? n.attachment,
133
+ clip: C(d, t) ?? n.clip
140
134
  };
141
135
  });
142
136
  }
143
- function p(e) {
137
+ function T(e) {
144
138
  return e.position ? `${e.color} ${e.position}` : e.color;
145
139
  }
146
- function m(e) {
140
+ var E = (e) => {
141
+ switch (e.type) {
142
+ case "linear-gradient": return e.angle;
143
+ case "radial-gradient": return [
144
+ e.radialShape === "ellipse" ? "" : e.radialShape,
145
+ e.radialExtent === "farthest-corner" ? "" : e.radialExtent,
146
+ e.radialPosition ? `at ${e.radialPosition}` : ""
147
+ ].filter(Boolean).join(" ");
148
+ case "conic-gradient": return [e.conicAngle && e.conicAngle !== "0deg" ? `from ${e.conicAngle}` : "", e.conicPosition ? `at ${e.conicPosition}` : ""].filter(Boolean).join(" ");
149
+ default: return "";
150
+ }
151
+ };
152
+ function D(e) {
147
153
  switch (e.type) {
148
154
  case "url": return `url("${e.url}")`;
149
- case "linear-gradient": {
150
- let t = e.stops.map(p).join(", ");
151
- return `linear-gradient(${e.angle}, ${t})`;
152
- }
153
- case "radial-gradient": {
154
- let t = e.stops.map(p).join(", "), n = e.radialShape === "ellipse" ? "" : `${e.radialShape} `, r = e.radialExtent === "farthest-corner" ? "" : `${e.radialExtent} `, i = `at ${e.radialPosition}`;
155
- return `radial-gradient(${n || r ? `${n}${r}${i}` : i}, ${t})`;
156
- }
155
+ case "raw": return e.raw || "none";
156
+ case "linear-gradient":
157
+ case "radial-gradient":
157
158
  case "conic-gradient": {
158
- let t = e.stops.map(p).join(", ");
159
- return `conic-gradient(${e.conicAngle === "0deg" ? "" : `from ${e.conicAngle} `}${`at ${e.conicPosition}`}, ${t})`;
159
+ let t = E(e), n = e.stops.map(T).join(", ");
160
+ return `${e.repeating ? "repeating-" : ""}${e.type}(${t ? `${t}, ` : ""}${n})`;
160
161
  }
161
162
  default: return "none";
162
163
  }
163
164
  }
164
- function h(e) {
165
+ function O(e) {
165
166
  return e.length === 0 ? {
166
167
  "background-image": void 0,
167
168
  "background-size": void 0,
@@ -170,7 +171,7 @@ function h(e) {
170
171
  "background-attachment": void 0,
171
172
  "background-clip": void 0
172
173
  } : {
173
- "background-image": e.map(m).join(", "),
174
+ "background-image": e.map(D).join(", "),
174
175
  "background-size": e.map((e) => e.size).join(", "),
175
176
  "background-position": e.map((e) => `${e.positionX} ${e.positionY}`).join(", "),
176
177
  "background-repeat": e.map((e) => e.repeat).join(", "),
@@ -179,4 +180,4 @@ function h(e) {
179
180
  };
180
181
  }
181
182
  //#endregion
182
- export { t as DEFAULT_LAYER_PROPS, e as DEFAULT_STOPS, r as newLayerId, i as newStopId, f as parseBackgroundLayers, m as serializeLayerImage, h as serializeLayersToCSS, p as serializeStop, a as splitTopLevelCommas };
183
+ export { r as DEFAULT_LAYER_PROPS, t as DEFAULT_STOPS, a as newLayerId, o as newStopId, w as parseBackgroundLayers, D as serializeLayerImage, O as serializeLayersToCSS, T as serializeStop, s as splitTopLevelCommas };
@@ -0,0 +1,8 @@
1
+ import { StyleCategory, StyleValue } from '@plitzi/sdk-shared';
2
+ /** The properties a background's layers are written across, one comma-separated list each. */
3
+ export declare const BG_LAYER_KEYS: StyleCategory[];
4
+ /**
5
+ * The layers' properties as one string — what tells a change made elsewhere (undo, another collaborator) from the one
6
+ * the editor just wrote, which it already shows.
7
+ */
8
+ export declare const layerValuesKey: (record: Partial<Record<StyleCategory, StyleValue>>) => string;
@@ -0,0 +1,11 @@
1
+ //#region src/components/StyleInspector/categories/Background/helpers/layerValues.ts
2
+ var e = [
3
+ "background-image",
4
+ "background-size",
5
+ "background-position",
6
+ "background-repeat",
7
+ "background-attachment",
8
+ "background-clip"
9
+ ], t = (t) => e.map((e) => String(t[e])).join("||");
10
+ //#endregion
11
+ export { e as BG_LAYER_KEYS, t as layerValuesKey };
@@ -1,100 +1,65 @@
1
- import e from "../../../components/CategoryOption/index.mjs";
2
- import t from "../../../components/CategorySection/index.mjs";
3
- import n from "../components/BackgroundPosition/index.mjs";
4
- import r from "../components/BackgroundSize/index.mjs";
5
- import i from "../components/BackgroundTile/index.mjs";
6
- import a from "../components/GradientStopBar/index.mjs";
7
- import { useCallback as o } from "react";
8
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
1
+ import { asText as e } from "../../../cssValues.mjs";
2
+ import t from "../../../components/CategoryOption/index.mjs";
3
+ import n from "../../../components/CategorySection/index.mjs";
4
+ import { ANGLE_UNITS as r, CENTER_X_WORDS as i, CENTER_Y_WORDS as a, centerParts as o, joinCenter as s } from "./helpers.mjs";
5
+ import c from "../components/GradientStopBar/index.mjs";
6
+ import { useCallback as l } from "react";
7
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
9
8
  //#region src/components/StyleInspector/categories/Background/modes/ConicGradientMode.tsx
10
- var u = ({ layer: u, onChange: d }) => {
11
- let f = o((e) => d?.({
12
- ...u,
13
- conicAngle: String(e)
14
- }), [u, d]), p = o((e) => {
15
- let t = u.conicPosition.split(" ");
16
- d?.({
17
- ...u,
18
- conicPosition: `${String(e)} ${t[1] ?? "50%"}`
19
- });
20
- }, [u, d]), m = o((e) => {
21
- let t = u.conicPosition.split(" ");
22
- d?.({
23
- ...u,
24
- conicPosition: `${t[0] ?? "50%"} ${String(e)}`
25
- });
26
- }, [u, d]), h = o((e) => d?.({
27
- ...u,
9
+ var p = ({ layer: p, onChange: m }) => {
10
+ let [h, g] = o(p.conicPosition), _ = l((t) => m?.({
11
+ ...p,
12
+ conicAngle: e(t)
13
+ }), [p, m]), v = l((t) => m?.({
14
+ ...p,
15
+ conicPosition: s(e(t), g)
16
+ }), [
17
+ g,
18
+ p,
19
+ m
20
+ ]), y = l((t) => m?.({
21
+ ...p,
22
+ conicPosition: s(h, e(t))
23
+ }), [
24
+ h,
25
+ p,
26
+ m
27
+ ]), b = l((e) => m?.({
28
+ ...p,
28
29
  stops: e
29
- }), [u, d]);
30
- return /* @__PURE__ */ l(s, { children: [
31
- /* @__PURE__ */ c(t, {
32
- label: "Start Angle",
33
- children: /* @__PURE__ */ c(e, {
30
+ }), [p, m]);
31
+ return /* @__PURE__ */ f(u, { children: [
32
+ /* @__PURE__ */ d(n, {
33
+ label: "Start angle",
34
+ children: /* @__PURE__ */ d(t, {
34
35
  type: "metric",
35
- value: u.conicAngle,
36
- units: [
37
- {
38
- label: "deg",
39
- value: "deg"
40
- },
41
- {
42
- label: "rad",
43
- value: "rad"
44
- },
45
- {
46
- label: "turn",
47
- value: "turn"
48
- }
49
- ],
50
- min: 0,
51
- max: 360,
52
- onChange: f
36
+ value: p.conicAngle,
37
+ units: r,
38
+ min: -Infinity,
39
+ onChange: _
53
40
  })
54
41
  }),
55
- /* @__PURE__ */ l(t, {
56
- label: "Position",
57
- children: [/* @__PURE__ */ c(e, {
42
+ /* @__PURE__ */ f(n, {
43
+ label: "Center",
44
+ children: [/* @__PURE__ */ d(t, {
58
45
  type: "metric",
59
- value: u.conicPosition.split(" ")[0] ?? "50%",
60
- allowedWords: [
61
- "center",
62
- "left",
63
- "right"
64
- ],
65
- onChange: p
66
- }), /* @__PURE__ */ c(e, {
46
+ value: h,
47
+ allowedWords: i,
48
+ min: -Infinity,
49
+ onChange: v
50
+ }), /* @__PURE__ */ d(t, {
67
51
  type: "metric",
68
- value: u.conicPosition.split(" ")[1] ?? "50%",
69
- allowedWords: [
70
- "center",
71
- "top",
72
- "bottom"
73
- ],
74
- onChange: m
52
+ value: g,
53
+ allowedWords: a,
54
+ min: -Infinity,
55
+ onChange: y
75
56
  })]
76
57
  }),
77
- /* @__PURE__ */ c(t, {
78
- label: "Gradient",
79
- direction: "column",
80
- children: /* @__PURE__ */ c(a, {
81
- stops: u.stops,
82
- onChange: h
83
- })
84
- }),
85
- /* @__PURE__ */ c(r, {
86
- layer: u,
87
- onChange: d
88
- }),
89
- /* @__PURE__ */ c(n, {
90
- layer: u,
91
- onChange: d
92
- }),
93
- /* @__PURE__ */ c(i, {
94
- layer: u,
95
- onChange: d
58
+ /* @__PURE__ */ d(c, {
59
+ stops: p.stops,
60
+ onChange: b
96
61
  })
97
62
  ] });
98
63
  };
99
64
  //#endregion
100
- export { u as default };
65
+ export { p as default };
@@ -1,80 +1,19 @@
1
- import e from "../../../components/CategoryOption/index.mjs";
2
- import t from "../../../components/CategorySection/index.mjs";
3
- import n from "../components/BackgroundPosition/index.mjs";
4
- import r from "../components/BackgroundSize/index.mjs";
5
- import i from "../components/BackgroundTile/index.mjs";
6
- import { useCallback as a, useMemo as o } from "react";
7
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
1
+ import { asText as e } from "../../../cssValues.mjs";
2
+ import t from "../../../components/CategoryOption/index.mjs";
3
+ import { useCallback as n } from "react";
4
+ import { jsx as r } from "react/jsx-runtime";
8
5
  //#region src/components/StyleInspector/categories/Background/modes/ImageMode.tsx
9
- var u = ({ layer: u, onChange: d }) => {
10
- let f = a((e) => d?.({
11
- ...u,
12
- url: String(e)
13
- }), [u, d]), p = a((e) => d?.({
14
- ...u,
15
- attachment: String(e)
16
- }), [u, d]), m = o(() => [
17
- {
18
- value: "fixed",
19
- icon: /* @__PURE__ */ c("div", {
20
- className: "px-1 text-xs select-none",
21
- children: "Fixed"
22
- }),
23
- description: "Fixed to viewport",
24
- active: u.attachment === "fixed",
25
- size: "custom"
26
- },
27
- {
28
- value: "local",
29
- icon: /* @__PURE__ */ c("div", {
30
- className: "px-1 text-xs select-none",
31
- children: "Local"
32
- }),
33
- description: "Scrolls with content",
34
- active: u.attachment === "local",
35
- size: "custom"
36
- },
37
- {
38
- value: "scroll",
39
- icon: /* @__PURE__ */ c("div", {
40
- className: "px-1 text-xs select-none",
41
- children: "Scroll"
42
- }),
43
- description: "Scrolls with element",
44
- active: u.attachment === "scroll",
45
- size: "custom"
46
- }
47
- ], [u.attachment]);
48
- return /* @__PURE__ */ l(s, { children: [
49
- /* @__PURE__ */ c(t, {
50
- label: "URL",
51
- children: /* @__PURE__ */ c(e, {
52
- type: "input",
53
- value: u.url,
54
- onChange: f
55
- })
56
- }),
57
- /* @__PURE__ */ c(r, {
58
- layer: u,
59
- onChange: d
60
- }),
61
- /* @__PURE__ */ c(n, {
62
- layer: u,
63
- onChange: d
64
- }),
65
- /* @__PURE__ */ c(i, {
66
- layer: u,
67
- onChange: d
68
- }),
69
- /* @__PURE__ */ c(t, {
70
- label: "Attachment",
71
- children: /* @__PURE__ */ c(e, {
72
- type: "iconGroup",
73
- items: m,
74
- onChange: p
75
- })
76
- })
77
- ] });
6
+ var i = ({ layer: i, onChange: a }) => {
7
+ let o = n((t) => a?.({
8
+ ...i,
9
+ url: e(t)
10
+ }), [i, a]);
11
+ return /* @__PURE__ */ r(t, {
12
+ label: "URL",
13
+ type: "input",
14
+ value: i.url,
15
+ onChange: o
16
+ });
78
17
  };
79
18
  //#endregion
80
- export { u as default };
19
+ export { i as default };