@plitzi/sdk-shared 0.32.3 → 0.32.4

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @plitzi/sdk-shared
2
2
 
3
+ ## 0.32.4
4
+
5
+ ### Patch Changes
6
+
7
+ - v0.32.4
8
+ - Updated dependencies
9
+ - @plitzi/nexus@0.32.4
10
+
3
11
  ## 0.32.3
4
12
 
5
13
  ### Patch Changes
@@ -4,19 +4,21 @@ import n from "./dateConverter.mjs";
4
4
  import r from "./staticValue.mjs";
5
5
  import i from "./stringToArray.mjs";
6
6
  import a from "./styleSelector.mjs";
7
- import o from "./twigTemplate.mjs";
7
+ import o from "./styleVariant.mjs";
8
+ import s from "./twigTemplate.mjs";
8
9
  //#region src/dataSource/utility/index.ts
9
- var s = {
10
- twigTemplate: o,
10
+ var c = {
11
+ twigTemplate: s,
11
12
  dateConverter: n,
12
13
  staticValue: r,
13
14
  capitalize: t,
14
15
  arrayMap: e,
15
16
  stringToArray: i,
16
- styleSelector: a
17
- }, c = Object.values(s).map(({ title: e, action: t }) => ({
17
+ styleSelector: a,
18
+ styleVariant: o
19
+ }, l = Object.values(c).map(({ title: e, action: t }) => ({
18
20
  label: e,
19
21
  value: t
20
22
  }));
21
23
  //#endregion
22
- export { s as default, c as utilityOptions };
24
+ export { c as default, l as utilityOptions };
@@ -20,7 +20,16 @@ var t = {
20
20
  label: "Selector",
21
21
  defaultValue: "",
22
22
  type: "select",
23
- options: []
23
+ options: (e, t, n) => {
24
+ let r = n?.stylePlatform;
25
+ return r ? Object.keys(r).map((e) => ({
26
+ label: e,
27
+ options: Object.values(r[e]).filter((e) => e.type === "class").map((e) => ({
28
+ label: e.name,
29
+ value: e.name
30
+ }))
31
+ })) : [];
32
+ }
24
33
  }
25
34
  },
26
35
  preview: {
@@ -0,0 +1,3 @@
1
+ import { DataSourceUtility } from '../../types';
2
+ declare const styleVariant: DataSourceUtility<string | string[] | Record<string, string | string[]>, Record<string, string | string[]>, string>;
3
+ export default styleVariant;
@@ -0,0 +1,76 @@
1
+ import { set as e } from "@plitzi/plitzi-ui/helpers/lodash";
2
+ //#region src/dataSource/utility/styleVariant.ts
3
+ var t = (t, n, r, i = {}) => {
4
+ let { key: a, variant: o, append: s } = n;
5
+ if (!a) return i.sourceTo ?? {};
6
+ let c = a || "base", l = o || t;
7
+ return typeof l == "object" && !Array.isArray(l) ? l : e(s ? { ...i.sourceTo } : {}, c, l);
8
+ }, n = (e) => {
9
+ let t = e.reduce((e, { groupLabel: t, option: n }) => (t in e || (e[t] = []), e[t].push(n), e), {});
10
+ return Object.entries(t).map(([e, t]) => ({
11
+ label: e,
12
+ options: t
13
+ }));
14
+ }, r = {
15
+ action: "styleVariant",
16
+ title: "Style Variant",
17
+ type: "utility",
18
+ params: {
19
+ key: {
20
+ label: "Selector Key",
21
+ defaultValue: "",
22
+ type: "select",
23
+ options: (e, t) => {
24
+ let r = t?.definition?.styleSelectors;
25
+ if (!t || !t.definition || !r) return [];
26
+ let i = t.definition.type;
27
+ return n(Object.entries(r).flatMap(([e, t]) => (t ? [i, ...t.split(" ")] : [i]).map((t) => ({
28
+ groupLabel: e,
29
+ option: {
30
+ value: `${t}.${e}`,
31
+ label: `${t} (${e})`
32
+ }
33
+ }))));
34
+ }
35
+ },
36
+ variant: {
37
+ label: "Variant",
38
+ defaultValue: "",
39
+ type: "select",
40
+ options: (e, t, n) => {
41
+ let r = t?.definition?.styleSelectors, i = e.key || "";
42
+ if (!t || !t.definition || !r || !n?.stylePlatform || !i.includes(".")) return [];
43
+ let a = t.definition.type, o = i.split(".").pop() || "", s = r[o];
44
+ if (!s) return [];
45
+ let c = [], l = [a, ...s.split(" ").filter(Boolean)];
46
+ return Object.entries(n.stylePlatform).forEach(([e, t]) => {
47
+ l.forEach((n) => {
48
+ let r = t[n];
49
+ if (!r) return;
50
+ let i = r.attributes[o];
51
+ Object.keys(i.variants || {}).forEach((t) => {
52
+ c.push({
53
+ value: t,
54
+ label: `${e}: ${t}`
55
+ });
56
+ });
57
+ });
58
+ }), c;
59
+ }
60
+ },
61
+ append: {
62
+ label: "Append to Variant",
63
+ description: "Merge with existing variant values instead of replacing",
64
+ defaultValue: !1,
65
+ type: "checkbox"
66
+ }
67
+ },
68
+ preview: {
69
+ key: "",
70
+ variant: "",
71
+ append: ""
72
+ },
73
+ callback: t
74
+ };
75
+ //#endregion
76
+ export { r as default };
@@ -1,15 +1,22 @@
1
1
  import { Element } from './SchemaTypes';
2
2
  import { Field, RuleValue } from '@plitzi/plitzi-ui/QueryBuilder';
3
+ export type DataSourceUtilityParamsOption = {
4
+ label: string;
5
+ value: string;
6
+ } | {
7
+ label: string;
8
+ options: {
9
+ label: string;
10
+ value: string;
11
+ }[];
12
+ };
3
13
  export type DataSourceUtilityParams<TParams = string | boolean | number> = Record<string, {
4
14
  type?: DataSourceUtilityParamType | ((params: DataSourceUtilityParamsValue<TParams>) => DataSourceUtilityParamType);
5
15
  label?: string;
6
16
  description?: string;
7
17
  defaultValue?: string | boolean | number;
8
18
  disabled?: boolean | ((params: DataSourceUtilityParamsValue<TParams>) => boolean);
9
- options?: {
10
- label: string;
11
- value: string;
12
- }[];
19
+ options?: DataSourceUtilityParamsOption[] | Promise<DataSourceUtilityParamsOption[]> | ((params: DataSourceUtilityParamsValue<TParams>, element?: Partial<Element>, data?: Record<string, unknown>) => DataSourceUtilityParamsOption[] | Promise<DataSourceUtilityParamsOption[]>);
13
20
  }>;
14
21
  export type DataSourceUtilityParamsValue<T = string | boolean | number> = Record<keyof DataSourceUtility<T>['params'], T>;
15
22
  export type DataSourceUtilityParamType = 'text' | 'select' | 'textarea' | 'checkbox' | 'codemirror-text';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-shared",
3
- "version": "0.32.3",
3
+ "version": "0.32.4",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist",
@@ -102,6 +102,10 @@
102
102
  "types": "./dist/dataSource/utility/styleSelector.d.ts",
103
103
  "import": "./dist/dataSource/utility/styleSelector.mjs"
104
104
  },
105
+ "./dataSource/utility/styleVariant": {
106
+ "types": "./dist/dataSource/utility/styleVariant.d.ts",
107
+ "import": "./dist/dataSource/utility/styleVariant.mjs"
108
+ },
105
109
  "./dataSource/utility/twigTemplate": {
106
110
  "types": "./dist/dataSource/utility/twigTemplate.d.ts",
107
111
  "import": "./dist/dataSource/utility/twigTemplate.mjs"
@@ -1075,7 +1079,7 @@
1075
1079
  },
1076
1080
  "dependencies": {
1077
1081
  "@modelcontextprotocol/sdk": "^1.29.0",
1078
- "@plitzi/nexus": "0.32.3",
1082
+ "@plitzi/nexus": "0.32.4",
1079
1083
  "@plitzi/plitzi-ui": "^1.6.13",
1080
1084
  "date-fns": "^4.4.0",
1081
1085
  "date-fns-tz": "^3.2.0",