@plitzi/sdk-elements 0.34.1 → 0.35.2

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,77 @@
1
1
  # @plitzi/sdk-elements
2
2
 
3
+ ## 0.35.2
4
+
5
+ ### Minor Changes
6
+
7
+ - 470aaf8: A booking form can ask for a date, and a toggle can say it is one.
8
+
9
+ - **`formControl` accepts `subType: 'date'`.** It renders the browser's own date picker and submits `YYYY-MM-DD`, so
10
+ a flow or a server action reads one format whatever the visitor's locale. Until now a date was a free text field
11
+ and every form that needed one parsed whatever somebody typed. Offered in the builder's Input Type list.
12
+ - **`button` accepts `ariaExpanded` and `ariaPressed`.** A button that opens a menu or an answer, or one that stays on
13
+ like a filter, can tell assistive technology so — statically, or bound to the state it flips
14
+ (`bind: { ariaExpanded: 'state.menuOpen' }`). Left out, neither attribute is rendered: an ordinary button does not
15
+ claim to control anything.
16
+
17
+ - 470aaf8: The theme is a data source, and a binding reads every source its template names.
18
+
19
+ - **`theme` global source.** `GlobalSources` publishes `runtime.sources.theme` as `{ mode, resolved }` for the area
20
+ the space paints in. `resolved` is always `light` or `dark`, so `{{ theme.resolved }}` is what a URL or a `when`
21
+ rule wants — a dashboard asking the API for a thumbnail in the visitor's scheme, for one. The comments that promised
22
+ `{{ theme.resolved }}` through the app store's `theme` mirror were wrong: nothing a binding reads lives there.
23
+ - **A binding subscribes to the roots of its `twigTemplate`.** It used to get only the head of its `source`, so a
24
+ binding on `list_spaces.item.id` whose template also said `{{ theme.resolved }}` or `{{ state.scope }}` resolved the
25
+ second name to nothing, silently. The names are read off the parsed template (`templateRootNames`, exported from
26
+ `@plitzi/sdk-shared/helpers/twigWrapper`). A name that is not a source is left out of the map rather than set to
27
+ `undefined`, so `{{ source }}` and the variables lifted to the template's root are never shadowed.
28
+ - **Authoring.** `theme` joins `GLOBAL_SOURCES`: `bind: { src: 'theme.resolved' }` is accepted, and an element can no
29
+ longer be named `theme`.
30
+
31
+ ### Patch Changes
32
+
33
+ - v0.35.2
34
+ - Updated dependencies
35
+ - Updated dependencies [470aaf8]
36
+ - @plitzi/sdk-auth@0.35.2
37
+ - @plitzi/sdk-dev-tools@0.35.2
38
+ - @plitzi/sdk-event-bridge@0.35.2
39
+ - @plitzi/sdk-interactions@0.35.2
40
+ - @plitzi/sdk-navigation@0.35.2
41
+ - @plitzi/sdk-schema@0.35.2
42
+ - @plitzi/sdk-shared@0.35.2
43
+
44
+ ## 0.35.1
45
+
46
+ ### Patch Changes
47
+
48
+ - v0.35.1
49
+ - Updated dependencies
50
+ - @plitzi/sdk-auth@0.35.1
51
+ - @plitzi/sdk-dev-tools@0.35.1
52
+ - @plitzi/sdk-event-bridge@0.35.1
53
+ - @plitzi/sdk-interactions@0.35.1
54
+ - @plitzi/sdk-navigation@0.35.1
55
+ - @plitzi/sdk-schema@0.35.1
56
+ - @plitzi/sdk-shared@0.35.1
57
+
58
+ ## 0.35.0
59
+
60
+ ### Minor Changes
61
+
62
+ - v0.35.0
63
+
64
+ ### Patch Changes
65
+
66
+ - Updated dependencies
67
+ - @plitzi/sdk-auth@0.35.0
68
+ - @plitzi/sdk-dev-tools@0.35.0
69
+ - @plitzi/sdk-event-bridge@0.35.0
70
+ - @plitzi/sdk-interactions@0.35.0
71
+ - @plitzi/sdk-navigation@0.35.0
72
+ - @plitzi/sdk-schema@0.35.0
73
+ - @plitzi/sdk-shared@0.35.0
74
+
3
75
  ## 0.34.1
4
76
 
5
77
  ### Patch Changes
@@ -1,23 +1,27 @@
1
1
  import { useMemo as e } from "react";
2
2
  import { useCommonStore as t } from "@plitzi/sdk-shared/store";
3
+ import { templateRootNames as n } from "@plitzi/sdk-shared/helpers/twigWrapper";
3
4
  //#region src/Element/hooks/useElementDataSource.ts
4
- var n = ({ bindings: n, sources: r }) => {
5
- let i = e(() => {
6
- let e = new Set(r ?? []);
7
- for (let t of Object.values(n ?? {})) if (Array.isArray(t)) {
8
- for (let { source: n } of t) if (n) {
9
- let t = n.indexOf(".");
10
- e.add(t > -1 ? n.substring(0, t) : n);
11
- }
12
- }
5
+ var r = ({ source: e, transformers: t }) => {
6
+ let r = [];
7
+ if (e) {
8
+ let t = e.indexOf(".");
9
+ r.push(t > -1 ? e.substring(0, t) : e);
10
+ }
11
+ for (let { action: e, params: i } of t ?? []) e === "twigTemplate" && i.template && r.push(...n(i.template));
12
+ return r;
13
+ }, i = ({ bindings: n, sources: i }) => {
14
+ let a = e(() => {
15
+ let e = new Set(i ?? []);
16
+ for (let t of Object.values(n ?? {})) if (Array.isArray(t)) for (let n of t) for (let t of r(n)) e.add(t);
13
17
  return e.size > 0 && !e.has("variables") && e.add("variables"), [...e];
14
- }, [n, r]), a = e(() => i.map((e) => `runtime.sources.${e}`), [i]), [o] = t(a);
18
+ }, [n, i]), o = e(() => a.map((e) => `runtime.sources.${e}`), [a]), [s] = t(o);
15
19
  return e(() => {
16
20
  let e = {};
17
- return i.forEach((t, n) => {
18
- e[t] = o[n];
21
+ return a.forEach((t, n) => {
22
+ s[n] !== void 0 && (e[t] = s[n]);
19
23
  }), e;
20
- }, [i, o]);
24
+ }, [a, s]);
21
25
  };
22
26
  //#endregion
23
- export { n as default };
27
+ export { i as default };
@@ -2,67 +2,68 @@ import { use as e, useCallback as t, useMemo as n } from "react";
2
2
  import { useCommonStore as r, useCommonStoreSync as i, useRenderSettings as a } from "@plitzi/sdk-shared/store";
3
3
  import { get as o } from "@plitzi/plitzi-ui/helpers";
4
4
  import { getPathsFromObeject as s } from "@plitzi/sdk-shared/helpers/utils";
5
- import c from "@plitzi/sdk-shared/dataSource/hooks/useRegisterSource";
6
- import l from "@plitzi/sdk-auth/AuthContext";
7
- import { resolveVariables as u } from "@plitzi/sdk-shared/dataSource";
5
+ import c, { SPACE_THEME_AREA as l } from "@plitzi/sdk-shared/theme/useTheme";
6
+ import u from "@plitzi/sdk-shared/dataSource/hooks/useRegisterSource";
7
+ import d from "@plitzi/sdk-auth/AuthContext";
8
+ import { resolveVariables as f } from "@plitzi/sdk-shared/dataSource";
8
9
  //#region src/dataSource/GlobalSources.tsx
9
- var d = ({ children: d }) => {
10
- let { environment: f } = a(), [[p, m, h, g, _, v]] = r([
10
+ var p = ({ children: p }) => {
11
+ let { environment: m } = a(), [[h, g, _, v, y, b]] = r([
11
12
  "schema.variables",
12
13
  "navigation.routeParams",
13
14
  "navigation.queryParams",
14
15
  "navigation.hostname",
15
16
  "navigation.origin",
16
17
  "navigation.currentPageId"
17
- ]), y = n(() => u(p, {
18
- routeParams: m,
19
- queryParams: h,
20
- hostname: g,
21
- environment: f
18
+ ]), x = n(() => f(h, {
19
+ routeParams: g,
20
+ queryParams: _,
21
+ hostname: v,
22
+ environment: m
22
23
  }), [
23
- f,
24
- g,
25
- h,
26
24
  m,
27
- p
28
- ]), b = t(() => s(y).map((e) => ({
25
+ v,
26
+ _,
27
+ g,
28
+ h
29
+ ]), S = t(() => s(x).map((e) => ({
29
30
  path: e,
30
31
  name: `variables.${e}`
31
- })), [y]);
32
- c({
32
+ })), [x]);
33
+ u({
33
34
  id: "global",
34
35
  source: "variables",
35
36
  name: "Variables",
36
- fields: b
37
- }), i("runtime.sources.variables", y);
38
- let [x = {}] = r("pageDefinitions"), S = n(() => Object.values(x).map((e) => ({
37
+ fields: S
38
+ }), i("runtime.sources.variables", x);
39
+ let [C = {}] = r("pageDefinitions"), w = n(() => Object.values(C).map((e) => ({
39
40
  value: e.id,
40
41
  label: o(e, "attributes.name", e.id)
41
- })), [x]), C = n(() => ({
42
- routeParams: m,
43
- queryParams: h,
44
- origin: _,
45
- currentPageId: v
42
+ })), [C]), T = n(() => ({
43
+ routeParams: g,
44
+ queryParams: _,
45
+ origin: y,
46
+ currentPageId: b
46
47
  }), [
47
- m,
48
- h,
48
+ g,
49
49
  _,
50
- v
51
- ]), w = t(() => {
50
+ y,
51
+ b
52
+ ]), E = t(() => {
52
53
  let e = s({
53
- routeParams: m,
54
- queryParams: h
54
+ routeParams: g,
55
+ queryParams: _
55
56
  }).map((e) => ({
56
57
  path: e,
57
58
  name: `navigation.${e}`
58
59
  })), t = {
59
60
  path: "origin",
60
61
  name: "Origin"
61
- }, n = S.length > 0 ? {
62
+ }, n = w.length > 0 ? {
62
63
  path: "currentPageId",
63
64
  name: "Current Page",
64
65
  inputType: "select",
65
- values: S
66
+ values: w
66
67
  } : {
67
68
  path: "currentPageId",
68
69
  name: "Current Page"
@@ -73,61 +74,74 @@ var d = ({ children: d }) => {
73
74
  n
74
75
  ];
75
76
  }, [
76
- m,
77
- h,
78
- S
77
+ g,
78
+ _,
79
+ w
79
80
  ]);
80
- c({
81
+ u({
81
82
  id: "global",
82
83
  source: "navigation",
83
84
  name: "Navigation",
84
- fields: w
85
- }), i("runtime.sources.navigation", C);
86
- let { user: T, authenticated: E } = e(l), [D = "basic"] = r("schema.settings.userProvider"), O = n(() => D === "" ? {} : {
87
- isAuthenticated: E,
88
- accessToken: T?.accessToken ?? "",
85
+ fields: E
86
+ }), i("runtime.sources.navigation", T);
87
+ let { user: D, authenticated: O } = e(d), [k = "basic"] = r("schema.settings.userProvider"), A = n(() => k === "" ? {} : {
88
+ isAuthenticated: O,
89
+ accessToken: D?.accessToken ?? "",
89
90
  details: {
90
91
  username: "",
91
92
  email: "",
92
93
  roles: "",
93
94
  permissions: "",
94
95
  verified: "",
95
- ...T?.details ?? {}
96
+ ...D?.details ?? {}
96
97
  }
97
98
  }, [
99
+ k,
98
100
  D,
99
- T,
100
- E
101
- ]), k = t(() => s(O).map((e) => ({
101
+ O
102
+ ]), j = t(() => s(A).map((e) => ({
102
103
  path: e,
103
104
  name: `user.${e}`
104
- })), [O]);
105
- c({
105
+ })), [A]);
106
+ u({
106
107
  id: "global",
107
108
  source: "auth",
108
109
  name: "Auth State",
109
- fields: k
110
- }), i("runtime.sources.auth", O);
111
- let [A] = r("runtime.state"), j = t(() => s(A).map((e) => ({
110
+ fields: j
111
+ }), i("runtime.sources.auth", A);
112
+ let [M] = r("runtime.state"), N = t(() => s(M).map((e) => ({
112
113
  path: e,
113
114
  name: `state.${e}`
114
- })), [A]);
115
- c({
115
+ })), [M]);
116
+ u({
116
117
  id: "global",
117
118
  source: "state",
118
119
  name: "State",
119
- fields: j
120
- }), i("runtime.sources.state", A);
121
- let [M] = r("runtime.host"), N = t(() => s(M).map((e) => ({
120
+ fields: N
121
+ }), i("runtime.sources.state", M);
122
+ let [P] = r("runtime.host"), F = t(() => s(P).map((e) => ({
122
123
  path: e,
123
124
  name: `host.${e}`
124
- })), [M]);
125
- return c({
125
+ })), [P]);
126
+ u({
126
127
  id: "global",
127
128
  source: "host",
128
129
  name: "Host",
129
- fields: N
130
- }), i("runtime.sources.host", M), d;
130
+ fields: F
131
+ }), i("runtime.sources.host", P);
132
+ let { theme: I, resolvedTheme: L } = c(l), R = n(() => ({
133
+ mode: I,
134
+ resolved: L
135
+ }), [I, L]), z = t(() => s(R).map((e) => ({
136
+ path: e,
137
+ name: `theme.${e}`
138
+ })), [R]);
139
+ return u({
140
+ id: "global",
141
+ source: "theme",
142
+ name: "Theme",
143
+ fields: z
144
+ }), i("runtime.sources.theme", R), p;
131
145
  };
132
146
  //#endregion
133
- export { d as default };
147
+ export { p as default };
@@ -7,8 +7,17 @@ export type ButtonProps = {
7
7
  content?: string;
8
8
  subType?: 'button' | 'submit' | 'reset';
9
9
  disabled?: boolean;
10
+ /**
11
+ * For a button that shows and hides something — a menu, an answer, a panel: `true` while that is open.
12
+ *
13
+ * Left out, the button claims to control nothing, which is not the same as `false` ("it controls something, and it
14
+ * is closed"). A screen reader announces the difference, so an ordinary button must not get a default here.
15
+ */
16
+ ariaExpanded?: boolean;
17
+ /** For a button that stays on or off — a filter, a mode: `true` while it is on. Left out, it is a plain button. */
18
+ ariaPressed?: boolean;
10
19
  };
11
- declare const Button: ({ ref, className, children, contentPlacement, content, subType, disabled }: ButtonProps) => import("react").JSX.Element;
20
+ declare const Button: ({ ref, className, children, contentPlacement, content, subType, disabled, ariaExpanded, ariaPressed }: ButtonProps) => import("react").JSX.Element;
12
21
  declare const _default: {
13
22
  (props: import('../../../Element/hocs/withElement').WithElementProps<ButtonProps>): import("react").JSX.Element;
14
23
  displayName: string;
@@ -6,15 +6,17 @@ import i from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
6
6
  import { jsxs as a } from "react/jsx-runtime";
7
7
  import o from "clsx";
8
8
  //#region src/elements/basic/Button/Button.tsx
9
- var s = ({ ref: e, className: s = "", children: c, contentPlacement: l = "after", content: u = "Button", subType: d = "button", disabled: f = !1 }) => {
10
- let { definition: { label: p } } = t(), { settings: { previewMode: m } } = i(), h = r(() => typeof u == "string" ? u : p, [u, p]);
9
+ var s = ({ ref: e, className: s = "", children: c, contentPlacement: l = "after", content: u = "Button", subType: d = "button", disabled: f = !1, ariaExpanded: p, ariaPressed: m }) => {
10
+ let { definition: { label: h } } = t(), { settings: { previewMode: g } } = i(), _ = r(() => typeof u == "string" ? u : h, [u, h]);
11
11
  return /* @__PURE__ */ a(n, {
12
12
  ref: e,
13
13
  tag: "button",
14
- type: m ? d : "button",
15
- className: o("plitzi-component__button", s, { "container--empty--skip": !m && !c && u }),
14
+ type: g ? d : "button",
15
+ className: o("plitzi-component__button", s, { "container--empty--skip": !g && !c && u }),
16
16
  disabled: f,
17
- "aria-label": h,
17
+ "aria-label": _,
18
+ "aria-expanded": p,
19
+ "aria-pressed": m,
18
20
  children: [
19
21
  l === "before" && u,
20
22
  c,
@@ -123,5 +123,7 @@ declare const declaration: {
123
123
  disabled?: boolean | undefined;
124
124
  subType?: "button" | "submit" | "reset" | undefined;
125
125
  contentPlacement?: "before" | "after" | undefined;
126
+ ariaExpanded?: boolean | undefined;
127
+ ariaPressed?: boolean | undefined;
126
128
  }>>;
127
129
  export default declaration;
@@ -122,5 +122,7 @@ declare const Button: {
122
122
  disabled?: boolean | undefined;
123
123
  subType?: "button" | "submit" | "reset" | undefined;
124
124
  contentPlacement?: "before" | "after" | undefined;
125
+ ariaExpanded?: boolean | undefined;
126
+ ariaPressed?: boolean | undefined;
125
127
  }>>;
126
128
  export default Button;
@@ -320,6 +320,8 @@ export declare const elementDeclarations: {
320
320
  disabled?: boolean | undefined;
321
321
  subType?: "button" | "submit" | "reset" | undefined;
322
322
  contentPlacement?: "before" | "after" | undefined;
323
+ ariaExpanded?: boolean | undefined;
324
+ ariaPressed?: boolean | undefined;
323
325
  }>>;
324
326
  readonly Container: {
325
327
  readonly type: "container";
@@ -2,7 +2,7 @@ import { ChangeEvent, RefObject } from 'react';
2
2
  export type FormControlProps = {
3
3
  ref: RefObject<HTMLElement>;
4
4
  className: string;
5
- subType: 'text' | 'number' | 'email' | 'password' | 'time' | 'checkbox' | 'switch' | 'select' | 'textarea' | 'hidden';
5
+ subType: 'text' | 'number' | 'email' | 'password' | 'date' | 'time' | 'checkbox' | 'switch' | 'select' | 'textarea' | 'hidden';
6
6
  name: string;
7
7
  label: string;
8
8
  placeholder: string;
@@ -105,6 +105,7 @@ var y = ({ ref: e, className: i = "", subType: y = "text", name: b = "", label:
105
105
  "number",
106
106
  "email",
107
107
  "password",
108
+ "date",
108
109
  "time"
109
110
  ].includes(y) && /* @__PURE__ */ g(s, {
110
111
  id: `${P}_${N}`,
@@ -1,5 +1,5 @@
1
1
  type SettingsProps = {
2
- subType?: 'text' | 'number' | 'time' | 'email' | 'password' | 'select' | 'checkbox' | 'textarea' | 'hidden' | 'color' | 'switch';
2
+ subType?: 'text' | 'number' | 'date' | 'time' | 'email' | 'password' | 'select' | 'checkbox' | 'textarea' | 'hidden' | 'color' | 'switch';
3
3
  name?: string;
4
4
  label?: string;
5
5
  placeholder?: string;
@@ -59,6 +59,10 @@ var c = (e) => {
59
59
  value: "number",
60
60
  children: "Number"
61
61
  }),
62
+ /* @__PURE__ */ n("option", {
63
+ value: "date",
64
+ children: "Date"
65
+ }),
62
66
  /* @__PURE__ */ n("option", {
63
67
  value: "time",
64
68
  children: "Time"
@@ -3,7 +3,7 @@ export type WithFieldValueProps<T> = {
3
3
  ref: RefObject<HTMLElement>;
4
4
  name: string;
5
5
  defaultValue?: string;
6
- subType: 'hidden' | 'text' | 'number' | 'email' | 'password' | 'select' | 'checkbox' | 'textarea' | 'color' | 'switch';
6
+ subType: 'hidden' | 'text' | 'number' | 'email' | 'password' | 'date' | 'time' | 'select' | 'checkbox' | 'textarea' | 'color' | 'switch';
7
7
  required: boolean;
8
8
  minLength?: number;
9
9
  maxLength?: number;
package/dist/index.d.ts CHANGED
@@ -1979,6 +1979,8 @@ export declare const defaultElements: {
1979
1979
  disabled?: boolean | undefined;
1980
1980
  subType?: "button" | "submit" | "reset" | undefined;
1981
1981
  contentPlacement?: "before" | "after" | undefined;
1982
+ ariaExpanded?: boolean | undefined;
1983
+ ariaPressed?: boolean | undefined;
1982
1984
  }>>;
1983
1985
  paragraph: {
1984
1986
  (props: import('./Element/hocs/withElement').WithElementProps<import('./elements/basic/Paragraph/Paragraph').ParagraphProps>): import("react").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-elements",
3
- "version": "0.34.1",
3
+ "version": "0.35.2",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist"
@@ -986,13 +986,13 @@
986
986
  "dependencies": {
987
987
  "@plitzi/nexus": "^1.1.4",
988
988
  "@plitzi/plitzi-ui": "^1.6.21",
989
- "@plitzi/sdk-auth": "0.34.1",
990
- "@plitzi/sdk-dev-tools": "0.34.1",
991
- "@plitzi/sdk-event-bridge": "0.34.1",
992
- "@plitzi/sdk-interactions": "0.34.1",
993
- "@plitzi/sdk-navigation": "0.34.1",
994
- "@plitzi/sdk-schema": "0.34.1",
995
- "@plitzi/sdk-shared": "0.34.1",
989
+ "@plitzi/sdk-auth": "0.35.2",
990
+ "@plitzi/sdk-dev-tools": "0.35.2",
991
+ "@plitzi/sdk-event-bridge": "0.35.2",
992
+ "@plitzi/sdk-interactions": "0.35.2",
993
+ "@plitzi/sdk-navigation": "0.35.2",
994
+ "@plitzi/sdk-schema": "0.35.2",
995
+ "@plitzi/sdk-shared": "0.35.2",
996
996
  "clsx": "^2.1.1",
997
997
  "immer": "^11.1.18"
998
998
  },