@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,50 +1,51 @@
1
- import e from "../../../../components/CategoryOption/index.mjs";
2
- import t from "../../../../components/CategorySection/index.mjs";
3
- import { useCallback as n, useMemo as r } from "react";
4
- import { jsx as i } from "react/jsx-runtime";
5
- import a from "@plitzi/plitzi-ui/icons/BackgroundTileX";
6
- import o from "@plitzi/plitzi-ui/icons/BackgroundTileXY";
7
- import s from "@plitzi/plitzi-ui/icons/BackgroundTileY";
8
- import c from "@plitzi/plitzi-ui/icons/XMark";
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 { useCallback as r, useMemo as i } from "react";
5
+ import { jsx as a } from "react/jsx-runtime";
6
+ import o from "@plitzi/plitzi-ui/icons/BackgroundTileX";
7
+ import s from "@plitzi/plitzi-ui/icons/BackgroundTileXY";
8
+ import c from "@plitzi/plitzi-ui/icons/BackgroundTileY";
9
+ import l from "@plitzi/plitzi-ui/icons/XMark";
9
10
  //#region src/components/StyleInspector/categories/Background/components/BackgroundTile/BackgroundTile.tsx
10
- var l = ({ layer: l, onChange: u }) => {
11
- let d = r(() => [
11
+ var u = ({ layer: u, onChange: d }) => {
12
+ let f = i(() => [
12
13
  {
13
14
  value: "repeat",
14
- icon: /* @__PURE__ */ i(o, {}),
15
+ icon: /* @__PURE__ */ a(s, {}),
15
16
  description: "Horizontally and Vertically",
16
- active: l.repeat === "repeat"
17
+ active: u.repeat === "repeat"
17
18
  },
18
19
  {
19
20
  value: "repeat-x",
20
- icon: /* @__PURE__ */ i(a, {}),
21
+ icon: /* @__PURE__ */ a(o, {}),
21
22
  description: "Horizontally",
22
- active: l.repeat === "repeat-x"
23
+ active: u.repeat === "repeat-x"
23
24
  },
24
25
  {
25
26
  value: "repeat-y",
26
- icon: /* @__PURE__ */ i(s, {}),
27
+ icon: /* @__PURE__ */ a(c, {}),
27
28
  description: "Vertically",
28
- active: l.repeat === "repeat-y"
29
+ active: u.repeat === "repeat-y"
29
30
  },
30
31
  {
31
32
  value: "no-repeat",
32
- icon: /* @__PURE__ */ i(c, {}),
33
+ icon: /* @__PURE__ */ a(l, {}),
33
34
  description: "Don't tile",
34
- active: l.repeat === "no-repeat"
35
+ active: u.repeat === "no-repeat"
35
36
  }
36
- ], [l.repeat]), f = n((e) => u?.({
37
- ...l,
38
- repeat: String(e)
39
- }), [l, u]);
40
- return /* @__PURE__ */ i(t, {
37
+ ], [u.repeat]), p = r((t) => d?.({
38
+ ...u,
39
+ repeat: e(t)
40
+ }), [u, d]);
41
+ return /* @__PURE__ */ a(n, {
41
42
  label: "Tile",
42
- children: /* @__PURE__ */ i(e, {
43
+ children: /* @__PURE__ */ a(t, {
43
44
  type: "iconGroup",
44
- items: d,
45
- onChange: f
45
+ items: f,
46
+ onChange: p
46
47
  })
47
48
  });
48
49
  };
49
50
  //#endregion
50
- export { l as default };
51
+ export { u as default };
@@ -1,7 +1,9 @@
1
- import { MouseEvent } from 'react';
1
+ import { MouseEvent, ReactNode } from 'react';
2
2
  type GradientPreviewBarProps = {
3
3
  gradientCSS: string;
4
+ children?: ReactNode;
4
5
  onClick: (e: MouseEvent<HTMLDivElement>) => void;
5
6
  };
6
- declare const GradientPreviewBar: ({ gradientCSS, onClick }: GradientPreviewBarProps) => import('react').JSX.Element;
7
+ /** The stops drawn on a bar over a checkerboard, with their handles on it; a click on the bar adds a stop there. */
8
+ declare const GradientPreviewBar: ({ gradientCSS, children, onClick }: GradientPreviewBarProps) => import('react').JSX.Element;
7
9
  export default GradientPreviewBar;
@@ -1,20 +1,21 @@
1
- import { jsx as e, jsxs as t } from "react/jsx-runtime";
1
+ import { resolveTokens as e } from "../../../../cssValues.mjs";
2
+ import t from "../../../../StyleInspectorContext.mjs";
3
+ import { CHECKERBOARD as n } from "../../../../components/ColorSwatch/helpers.mjs";
4
+ import { use as r, useMemo as i } from "react";
5
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
2
6
  //#region src/components/StyleInspector/categories/Background/components/GradientStopBar/GradientPreviewBar.tsx
3
- var n = ({ gradientCSS: n, onClick: r }) => /* @__PURE__ */ t("div", {
4
- className: "relative h-6 w-full cursor-crosshair overflow-hidden rounded-sm border border-gray-300 dark:border-zinc-600",
5
- onClick: r,
6
- title: "Click to add a color stop",
7
- children: [/* @__PURE__ */ e("div", {
8
- className: "absolute inset-0",
9
- style: {
10
- backgroundImage: "linear-gradient(45deg,#ccc 25%,transparent 25%),linear-gradient(-45deg,#ccc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ccc 75%),linear-gradient(-45deg,transparent 75%,#ccc 75%)",
11
- backgroundSize: "10px 10px",
12
- backgroundPosition: "0 0,0 5px,5px -5px,-5px 0"
13
- }
14
- }), /* @__PURE__ */ e("div", {
15
- className: "absolute inset-0",
16
- style: { background: n }
17
- })]
18
- });
7
+ var s = ({ gradientCSS: s, children: c, onClick: l }) => {
8
+ let { variables: u } = r(t), d = i(() => ({ background: e(s, u) }), [s, u]);
9
+ return /* @__PURE__ */ o("div", {
10
+ className: "relative h-7 w-full cursor-copy rounded-md ring-1 ring-black/15 ring-inset dark:ring-white/20",
11
+ style: n,
12
+ title: "Click the bar to add a stop",
13
+ onClick: l,
14
+ children: [/* @__PURE__ */ a("div", {
15
+ className: "absolute inset-0 rounded-md",
16
+ style: d
17
+ }), c]
18
+ });
19
+ };
19
20
  //#endregion
20
- export { n as default };
21
+ export { s as default };
@@ -3,5 +3,9 @@ export type GradientStopBarProps = {
3
3
  stops: GradientStop[];
4
4
  onChange?: (stops: GradientStop[]) => void;
5
5
  };
6
+ /**
7
+ * A gradient's stops: the bar that draws them with a handle per stop, and the selected stop's color and position. A
8
+ * click on the bar adds a stop there in the color around it; a gradient keeps at least two.
9
+ */
6
10
  declare const GradientStopBar: ({ stops, onChange }: GradientStopBarProps) => import('react').JSX.Element;
7
11
  export default GradientStopBar;
@@ -1,94 +1,62 @@
1
1
  import { newStopId as e } from "../../helpers/backgroundParser.mjs";
2
2
  import t from "./GradientPreviewBar.mjs";
3
3
  import n from "./GradientStopEditor.mjs";
4
- import r from "./GradientStopTrack.mjs";
5
- import { useCallback as i, useMemo as a, useRef as o, useState as s } from "react";
6
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
7
- import u from "clsx";
8
- import d from "@plitzi/plitzi-ui/Icon";
4
+ import { colorNear as r, sortStops as i, stopsPreview as a } from "./helpers.mjs";
5
+ import o from "./GradientStopTrack.mjs";
6
+ import { useCallback as s, useMemo as c, useRef as l, useState as u } from "react";
7
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
9
8
  //#region src/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopBar.tsx
10
- function f(e) {
11
- let t = parseFloat(e);
12
- return isNaN(t) ? 0 : Math.max(0, Math.min(100, t));
13
- }
14
- var p = ({ stops: p, onChange: m }) => {
15
- let h = o(p);
16
- h.current = p;
17
- let [g, _] = s(p[0]?.id ?? ""), v = a(() => [...p].sort((e, t) => f(e.position) - f(t.position)), [p]), y = a(() => `linear-gradient(90deg, ${v.map((e) => e.position ? `${e.color} ${e.position}` : e.color).join(", ")})`, [v]), b = p.find((e) => e.id === g) ?? p[0], x = i((t) => {
18
- let { left: n, width: r } = t.currentTarget.getBoundingClientRect(), i = Math.round(Math.max(0, Math.min(100, (t.clientX - n) / r * 100))), a = h.current, o = [...a].sort((e, t) => Math.abs(f(e.position) - i) - Math.abs(f(t.position) - i)).at(0), s = {
9
+ var p = 10, m = ({ stops: m, onChange: h }) => {
10
+ let g = l(m);
11
+ g.current = m;
12
+ let [_, v] = u(m[0]?.id ?? ""), y = c(() => a(m), [m]), b = m.find((e) => e.id === _) ?? m.at(0), x = s((t) => {
13
+ let n = g.current, a = {
19
14
  id: e(),
20
- color: o?.color ?? "#808080",
21
- position: `${i}%`
22
- }, c = [...a, s].sort((e, t) => f(e.position) - f(t.position));
23
- m?.(c), _(s.id);
24
- }, [m]), S = i((e) => {
25
- b && m?.(h.current.map((t) => t.id === b.id ? {
15
+ color: r(n, t),
16
+ position: `${t}%`
17
+ };
18
+ h?.(i([...n, a])), v(a.id);
19
+ }, [h]), S = s((e) => {
20
+ let { left: t, width: n } = e.currentTarget.getBoundingClientRect(), r = n - p * 2;
21
+ x(Math.round(Math.max(0, Math.min(100, (e.clientX - t - p) / r * 100))));
22
+ }, [x]), C = s(() => x(50), [x]), w = s((e) => {
23
+ b && h?.(g.current.map((t) => t.id === b.id ? {
26
24
  ...t,
27
25
  color: e
28
26
  } : t));
29
- }, [m, b]), C = i((e) => {
30
- m?.(e.sort((e, t) => f(e.position) - f(t.position)));
31
- }, [m]), w = i((e) => {
32
- b && m?.(h.current.map((t) => t.id === b.id ? {
27
+ }, [h, b]), T = s((e) => {
28
+ b && h?.(i(g.current.map((t) => t.id === b.id ? {
33
29
  ...t,
34
- position: String(e)
35
- } : t).sort((e, t) => f(e.position) - f(t.position)));
36
- }, [m, b]), T = i(() => {
37
- if (!b || h.current.length <= 2) return;
38
- let e = h.current.filter((e) => e.id !== b.id);
39
- m?.(e), _(e[0]?.id ?? "");
40
- }, [m, b]), E = i(() => {
41
- let t = {
42
- id: e(),
43
- color: "#808080",
44
- position: "50%"
45
- }, n = [...h.current, t].sort((e, t) => f(e.position) - f(t.position));
46
- m?.(n), _(t.id);
47
- }, [m]);
48
- return /* @__PURE__ */ l("div", {
30
+ position: e
31
+ } : t)));
32
+ }, [h, b]), E = s((e) => h?.(i(e)), [h]), D = s((e) => {
33
+ if (g.current.length <= 2) return;
34
+ let t = g.current.filter((t) => t.id !== e);
35
+ h?.(t), v(t[0]?.id ?? "");
36
+ }, [h]), O = s(() => {
37
+ b && D(b.id);
38
+ }, [D, b]);
39
+ return /* @__PURE__ */ f("div", {
49
40
  className: "flex flex-col gap-2",
50
- children: [
51
- /* @__PURE__ */ c(t, {
52
- gradientCSS: y,
53
- onClick: x
54
- }),
55
- /* @__PURE__ */ c("div", {
56
- className: "flex px-2",
57
- children: /* @__PURE__ */ c(r, {
58
- stops: p,
59
- selectedId: g,
60
- onChange: C,
61
- onSelect: _
62
- })
63
- }),
64
- b && /* @__PURE__ */ c(n, {
65
- stop: b,
66
- showRemove: p.length > 2,
67
- onColorChange: S,
68
- onPositionChange: w,
69
- onRemove: T
70
- }),
71
- /* @__PURE__ */ l("div", {
72
- className: "flex flex-wrap gap-1",
73
- children: [v.map((e) => /* @__PURE__ */ c("button", {
74
- type: "button",
75
- className: u("h-5 w-5 cursor-pointer rounded-sm border shadow-sm", g === e.id ? "border-blue-500 ring-1 ring-blue-300 dark:ring-blue-700" : "border-gray-300 hover:border-gray-400 dark:border-zinc-600"),
76
- style: { backgroundColor: e.color },
77
- onClick: () => _(e.id),
78
- title: `${e.color} • ${e.position}`
79
- }, e.id)), /* @__PURE__ */ c("button", {
80
- type: "button",
81
- className: "flex h-5 w-5 cursor-pointer items-center justify-center rounded-sm border border-dashed border-gray-300 text-gray-400 hover:border-blue-400 hover:text-blue-500 dark:border-zinc-600 dark:text-zinc-500",
82
- title: "Add stop at 50%",
83
- onClick: E,
84
- children: /* @__PURE__ */ c(d, {
85
- icon: "fas fa-plus",
86
- size: "xs"
87
- })
88
- })]
41
+ children: [/* @__PURE__ */ d(t, {
42
+ gradientCSS: y,
43
+ onClick: S,
44
+ children: /* @__PURE__ */ d(o, {
45
+ stops: m,
46
+ selectedId: b?.id ?? "",
47
+ onChange: E,
48
+ onSelect: v,
49
+ onRemove: D
89
50
  })
90
- ]
51
+ }), b && /* @__PURE__ */ d(n, {
52
+ stop: b,
53
+ canRemove: m.length > 2,
54
+ onColorChange: w,
55
+ onPositionChange: T,
56
+ onAdd: C,
57
+ onRemove: O
58
+ })]
91
59
  });
92
60
  };
93
61
  //#endregion
94
- export { p as default };
62
+ export { m as default };
@@ -1,10 +1,12 @@
1
1
  import { GradientStop } from '../../helpers/backgroundParser';
2
2
  type GradientStopEditorProps = {
3
3
  stop: GradientStop;
4
- showRemove: boolean;
4
+ canRemove: boolean;
5
5
  onColorChange: (color: string) => void;
6
- onPositionChange: (value: unknown) => void;
6
+ onPositionChange: (value: string) => void;
7
+ onAdd: () => void;
7
8
  onRemove: () => void;
8
9
  };
9
- declare const GradientStopEditor: ({ stop, showRemove, onColorChange, onPositionChange, onRemove }: GradientStopEditorProps) => import('react').JSX.Element;
10
+ /** The selected stop's color and position, and the two buttons that change how many stops there are. */
11
+ declare const GradientStopEditor: ({ stop, canRemove, onColorChange, onPositionChange, onAdd, onRemove }: GradientStopEditorProps) => import('react').JSX.Element;
10
12
  export default GradientStopEditor;
@@ -1,48 +1,58 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
- import n from "@plitzi/plitzi-ui/Icon";
3
- import r from "@plitzi/plitzi-ui/ColorPicker";
4
- import i from "@plitzi/plitzi-ui/MetricInput";
2
+ import n from "@plitzi/plitzi-ui/ColorPicker";
3
+ import r from "@plitzi/plitzi-ui/MetricInput";
5
4
  //#region src/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopEditor.tsx
6
- var a = ({ stop: a, showRemove: o, onColorChange: s, onPositionChange: c, onRemove: l }) => /* @__PURE__ */ t("div", {
7
- className: "flex items-center gap-1.5 rounded border border-gray-200 bg-gray-50 p-1.5 dark:border-zinc-700 dark:bg-zinc-800/50",
8
- children: [
9
- /* @__PURE__ */ e("div", {
10
- className: "min-w-0 flex-1",
11
- children: /* @__PURE__ */ e(r, {
5
+ var i = [{
6
+ label: "%",
7
+ value: "%"
8
+ }, {
9
+ label: "PX",
10
+ value: "px"
11
+ }], a = ({ stop: a, canRemove: o, onColorChange: s, onPositionChange: c, onAdd: l, onRemove: u }) => /* @__PURE__ */ t("div", {
12
+ className: "flex flex-col gap-1.5",
13
+ children: [/* @__PURE__ */ e(n, {
14
+ size: "xs",
15
+ className: { root: "w-full min-w-0" },
16
+ value: a.color,
17
+ allowVariables: !0,
18
+ showAlpha: !0,
19
+ onChange: s
20
+ }), /* @__PURE__ */ t("div", {
21
+ className: "flex items-center gap-1.5",
22
+ children: [
23
+ /* @__PURE__ */ e("span", {
24
+ className: "text-xs text-zinc-500 dark:text-zinc-400",
25
+ children: "At"
26
+ }),
27
+ /* @__PURE__ */ e(r, {
12
28
  size: "xs",
13
- className: { root: "w-full min-w-0" },
14
- value: a.color,
15
- allowVariables: !0,
16
- showAlpha: !0,
17
- onChange: s
29
+ className: "w-24 shrink-0",
30
+ value: a.position,
31
+ units: i,
32
+ allowedWords: [],
33
+ min: -Infinity,
34
+ onChange: c
35
+ }),
36
+ /* @__PURE__ */ e("span", { className: "grow" }),
37
+ /* @__PURE__ */ e("button", {
38
+ type: "button",
39
+ className: "flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-zinc-500 hover:bg-gray-100 hover:text-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-100",
40
+ title: "Add a stop",
41
+ "aria-label": "Add a stop",
42
+ onClick: l,
43
+ children: /* @__PURE__ */ e("i", { className: "fa-solid fa-plus text-xs" })
44
+ }),
45
+ /* @__PURE__ */ e("button", {
46
+ type: "button",
47
+ className: "flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-zinc-500 hover:bg-red-500/10 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-red-400",
48
+ title: o ? "Remove this stop" : "A gradient needs two stops",
49
+ "aria-label": "Remove this stop",
50
+ disabled: !o,
51
+ onClick: u,
52
+ children: /* @__PURE__ */ e("i", { className: "fa-solid fa-trash-can text-xs" })
18
53
  })
19
- }),
20
- /* @__PURE__ */ e(i, {
21
- size: "xs",
22
- className: "w-20 shrink-0",
23
- value: a.position,
24
- units: [{
25
- label: "%",
26
- value: "%"
27
- }, {
28
- label: "PX",
29
- value: "px"
30
- }],
31
- allowedWords: [],
32
- min: Infinity,
33
- onChange: c
34
- }),
35
- o && /* @__PURE__ */ e("button", {
36
- type: "button",
37
- className: "shrink-0 cursor-pointer rounded p-0.5 text-gray-400 hover:text-red-500 dark:text-zinc-500 dark:hover:text-red-400",
38
- title: "Remove stop",
39
- onClick: l,
40
- children: /* @__PURE__ */ e(n, {
41
- icon: "fas fa-times",
42
- size: "xs"
43
- })
44
- })
45
- ]
54
+ ]
55
+ })]
46
56
  });
47
57
  //#endregion
48
58
  export { a as default };
@@ -6,6 +6,10 @@ type GradientStopHandleProps = {
6
6
  trackRef: RefObject<HTMLDivElement | null>;
7
7
  onPositionChange: (stopId: string, pct: number) => void;
8
8
  onSelect: (stopId: string) => void;
9
+ onRemove: (stopId: string) => void;
9
10
  };
10
- declare const GradientStopHandle: ({ stop, selected, trackRef, onPositionChange, onSelect }: GradientStopHandleProps) => import('react').JSX.Element;
11
+ /**
12
+ * A stop on the gradient: dragged along it, or moved with the arrow keys (Shift for ten at a time); Delete removes it.
13
+ */
14
+ declare const GradientStopHandle: ({ stop, selected, trackRef, onPositionChange, onSelect, onRemove }: GradientStopHandleProps) => import('react').JSX.Element;
11
15
  export default GradientStopHandle;
@@ -1,44 +1,66 @@
1
- import e from "../../helpers/normalizeLeft.mjs";
2
- import { useCallback as t, useLayoutEffect as n, useMemo as r, useRef as i } from "react";
3
- import { jsx as a } from "react/jsx-runtime";
4
- import o from "clsx";
1
+ import { resolveTokens as e } from "../../../../cssValues.mjs";
2
+ import t from "../../../../StyleInspectorContext.mjs";
3
+ import { stopPct as n } from "./helpers.mjs";
4
+ import r from "../../helpers/normalizeLeft.mjs";
5
+ import { use as i, useCallback as a, useLayoutEffect as o, useMemo as s, useRef as c } from "react";
6
+ import { jsx as l } from "react/jsx-runtime";
7
+ import u from "clsx";
5
8
  //#region src/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopHandle.tsx
6
- var s = ({ stop: s, selected: c, trackRef: l, onPositionChange: u, onSelect: d }) => {
7
- let f = i(null), p = i(!1), m = i(!1), h = r(() => e(s.position, (f.current?.parentNode)?.getBoundingClientRect().width ?? Infinity), [s.position]), g = t((e) => {
8
- let t = l.current;
9
+ var d = ({ stop: d, selected: f, trackRef: p, onPositionChange: m, onSelect: h, onRemove: g }) => {
10
+ let { variables: _ } = i(t), v = c(null), y = c(!1), b = c(!1), x = s(() => r(d.position.split(" ")[0] ?? "", p.current?.getBoundingClientRect().width ?? Infinity), [d.position, p]), S = s(() => e(d.color, _), [d.color, _]), C = a((e) => {
11
+ let t = p.current;
9
12
  if (!t) return 0;
10
13
  let { left: n, width: r } = t.getBoundingClientRect();
11
14
  return Math.round(Math.max(0, Math.min(100, (e - n) / r * 100)));
12
- }, [l]);
13
- n(() => {
14
- !p.current && f.current && (f.current.style.left = h);
15
- }, [h]);
16
- let _ = t((e) => {
17
- e.preventDefault(), m.current = !1, p.current = !0, f.current?.setPointerCapture(e.pointerId), d(s.id);
18
- }, [d, s.id]), v = t((e) => {
19
- p.current && f.current && (m.current = !0, f.current.style.left = `${g(e.clientX)}%`);
20
- }, [g]), y = t((e) => {
21
- if (p.current && (p.current = !1, m.current && f.current)) {
22
- let t = g(e.clientX);
23
- f.current.style.left = `${t}%`, u(s.id, t);
15
+ }, [p]);
16
+ o(() => {
17
+ !y.current && v.current && (v.current.style.left = x);
18
+ }, [x]);
19
+ let w = a((e) => {
20
+ e.preventDefault(), e.stopPropagation(), b.current = !1, y.current = !0, v.current?.setPointerCapture(e.pointerId), v.current?.focus(), h(d.id);
21
+ }, [h, d.id]), T = a((e) => {
22
+ y.current && v.current && (b.current = !0, v.current.style.left = `${C(e.clientX)}%`);
23
+ }, [C]), E = a((e) => {
24
+ if (y.current && (y.current = !1, b.current && v.current)) {
25
+ let t = C(e.clientX);
26
+ v.current.style.left = `${t}%`, m(d.id, t);
24
27
  }
25
28
  }, [
29
+ C,
30
+ m,
31
+ d.id
32
+ ]), D = a((e) => {
33
+ let t = e.shiftKey ? 10 : 1;
34
+ if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
35
+ e.preventDefault();
36
+ let r = n(d.position) + (e.key === "ArrowLeft" ? -t : t);
37
+ m(d.id, Math.max(0, Math.min(100, r)));
38
+ } else (e.key === "Delete" || e.key === "Backspace") && (e.preventDefault(), e.stopPropagation(), g(d.id));
39
+ }, [
40
+ m,
26
41
  g,
27
- u,
28
- s.id
29
- ]);
30
- return /* @__PURE__ */ a("div", {
31
- ref: f,
32
- className: o("absolute top-1/2 h-4 w-4 -translate-x-1/2 -translate-y-1/2 cursor-grab rounded-full border-2 shadow-sm", c ? "z-10 border-blue-500 ring-1 ring-blue-300 dark:ring-blue-700" : "z-0 border-white hover:border-gray-300 dark:border-zinc-500"),
42
+ d.id,
43
+ d.position
44
+ ]), O = a((e) => e.stopPropagation(), []);
45
+ return /* @__PURE__ */ l("button", {
46
+ ref: v,
47
+ type: "button",
48
+ className: u("pointer-events-auto absolute top-1/2 h-5 w-5 -translate-x-1/2 -translate-y-1/2 cursor-grab rounded-full border-2 shadow-md outline-none active:cursor-grabbing", {
49
+ "ring-primary-500 dark:ring-primary-400 z-10 border-white ring-2": f,
50
+ "z-0 border-white/90 hover:border-white": !f
51
+ }),
33
52
  style: {
34
- left: h,
35
- backgroundColor: s.color
53
+ left: x,
54
+ backgroundColor: S
36
55
  },
37
- onPointerDown: _,
38
- onPointerMove: v,
39
- onPointerUp: y,
40
- title: `${s.color} • ${s.position}`
56
+ title: `${d.color} · ${d.position || "auto"} — drag, or use the arrow keys`,
57
+ "aria-label": `Color stop ${d.color} at ${d.position || "auto"}`,
58
+ onPointerDown: w,
59
+ onPointerMove: T,
60
+ onPointerUp: E,
61
+ onKeyDown: D,
62
+ onClick: O
41
63
  });
42
64
  };
43
65
  //#endregion
44
- export { s as default };
66
+ export { d as default };
@@ -4,6 +4,8 @@ type GradientStopTrackProps = {
4
4
  selectedId: string;
5
5
  onChange?: (stops: GradientStop[]) => void;
6
6
  onSelect: (id: string) => void;
7
+ onRemove: (id: string) => void;
7
8
  };
8
- declare const GradientStopTrack: ({ stops, selectedId, onChange, onSelect }: GradientStopTrackProps) => import('react').JSX.Element;
9
+ /** The handles, laid over the bar inset by half a handle, so a stop at 0% or 100% stays whole and grabbable. */
10
+ declare const GradientStopTrack: ({ stops, selectedId, onChange, onSelect, onRemove }: GradientStopTrackProps) => import('react').JSX.Element;
9
11
  export default GradientStopTrack;
@@ -1,27 +1,28 @@
1
1
  import e from "./GradientStopHandle.mjs";
2
2
  import { useCallback as t, useRef as n } from "react";
3
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
3
+ import { jsx as r } from "react/jsx-runtime";
4
4
  //#region src/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopTrack.tsx
5
- var a = ({ stops: a, selectedId: o, onChange: s, onSelect: c }) => {
6
- let l = n(null), u = n(a);
7
- u.current = a;
5
+ var i = ({ stops: i, selectedId: a, onChange: o, onSelect: s, onRemove: c }) => {
6
+ let l = n(null), u = n(i);
7
+ u.current = i;
8
8
  let d = t((e, t) => {
9
- s?.(u.current.map((n) => n.id === e ? {
9
+ o?.(u.current.map((n) => n.id === e ? {
10
10
  ...n,
11
11
  position: `${t}%`
12
12
  } : n));
13
- }, [s]);
14
- return /* @__PURE__ */ i("div", {
13
+ }, [o]);
14
+ return /* @__PURE__ */ r("div", {
15
15
  ref: l,
16
- className: "relative h-5 w-full select-none",
17
- children: [/* @__PURE__ */ r("div", { className: "absolute top-1/2 right-0 left-0 h-px -translate-y-1/2 bg-gray-300 dark:bg-zinc-600" }), a.map((t) => /* @__PURE__ */ r(e, {
16
+ className: "pointer-events-none absolute inset-y-0 right-2.5 left-2.5 select-none",
17
+ children: i.map((t) => /* @__PURE__ */ r(e, {
18
18
  trackRef: l,
19
19
  stop: t,
20
- selected: o === t.id,
20
+ selected: a === t.id,
21
21
  onPositionChange: d,
22
- onSelect: c
23
- }, t.id))]
22
+ onSelect: s,
23
+ onRemove: c
24
+ }, t.id))
24
25
  });
25
26
  };
26
27
  //#endregion
27
- export { a as default };
28
+ export { i as default };
@@ -0,0 +1,8 @@
1
+ import { GradientStop } from '../../helpers/backgroundParser';
2
+ /** Where a stop sits along the bar, in percent — its first position when it has two, 0 when it has none. */
3
+ export declare const stopPct: (position: string) => number;
4
+ export declare const sortStops: (stops: GradientStop[]) => GradientStop[];
5
+ /** The stops drawn left to right on the bar, whatever the gradient's own direction or shape. */
6
+ export declare const stopsPreview: (stops: GradientStop[]) => string;
7
+ /** The color the stops have at a point of the bar — the closest stop's — for a stop added there. */
8
+ export declare const colorNear: (stops: GradientStop[], pct: number) => string;
@@ -0,0 +1,8 @@
1
+ import { serializeStop as e } from "../../helpers/backgroundParser.mjs";
2
+ //#region src/components/StyleInspector/categories/Background/components/GradientStopBar/helpers.ts
3
+ var t = (e) => {
4
+ let t = parseFloat(e);
5
+ return isNaN(t) ? 0 : Math.max(0, Math.min(100, t));
6
+ }, n = (e) => [...e].sort((e, n) => t(e.position) - t(n.position)), r = (t) => `linear-gradient(90deg, ${n(t).map(e).join(", ")})`, i = (e, n) => [...e].sort((e, r) => Math.abs(t(e.position) - n) - Math.abs(t(r.position) - n)).at(0)?.color ?? "#808080";
7
+ //#endregion
8
+ export { i as colorNear, n as sortStops, t as stopPct, r as stopsPreview };
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ export type LayerGroupProps = {
3
+ title: string;
4
+ children?: ReactNode;
5
+ };
6
+ /** A titled group of a layer's controls — what it draws, then where it goes — so a long editor reads in two halves. */
7
+ declare const LayerGroup: ({ title, children }: LayerGroupProps) => import('react').JSX.Element;
8
+ export default LayerGroup;
@@ -0,0 +1,11 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ //#region src/components/StyleInspector/categories/Background/components/LayerGroup/LayerGroup.tsx
3
+ var n = ({ title: n, children: r }) => /* @__PURE__ */ t("div", {
4
+ className: "flex flex-col gap-2",
5
+ children: [/* @__PURE__ */ e("span", {
6
+ className: "text-[11px] font-semibold tracking-wide text-zinc-500 uppercase dark:text-zinc-400",
7
+ children: n
8
+ }), r]
9
+ });
10
+ //#endregion
11
+ export { n as default };
@@ -0,0 +1,3 @@
1
+ import { default as LayerGroup } from './LayerGroup';
2
+ export * from './LayerGroup';
3
+ export default LayerGroup;
@@ -0,0 +1,5 @@
1
+ import e from "./LayerGroup.mjs";
2
+ //#region src/components/StyleInspector/categories/Background/components/LayerGroup/index.ts
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };