@plitzi/sdk-elements 0.39.12 → 0.39.14

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 (109) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/Element/PluginManager.mjs +13 -13
  3. package/dist/Element/hooks/useElementState.d.ts +1 -1
  4. package/dist/Element/hooks/useFullscreenInteractions.d.ts +11 -0
  5. package/dist/Element/hooks/useFullscreenInteractions.mjs +14 -0
  6. package/dist/Element/hooks/useRootElementInteractions.mjs +93 -87
  7. package/dist/builder/ruleFields.d.ts +1 -1
  8. package/dist/builder/ruleFields.mjs +5 -0
  9. package/dist/dataSource/GlobalSources.mjs +121 -104
  10. package/dist/dataSource/useAudienceScope.mjs +2 -1
  11. package/dist/dataSource/usePageClock.d.ts +12 -0
  12. package/dist/dataSource/usePageClock.mjs +19 -0
  13. package/dist/elements/basic/Countdown/Countdown.d.ts +23 -0
  14. package/dist/elements/basic/Countdown/Countdown.mjs +58 -0
  15. package/dist/elements/basic/Countdown/Settings.d.ts +12 -0
  16. package/dist/elements/basic/Countdown/Settings.mjs +94 -0
  17. package/dist/elements/basic/Countdown/declaration.d.ts +72 -0
  18. package/dist/elements/basic/Countdown/declaration.mjs +58 -0
  19. package/dist/elements/basic/Countdown/index.d.ts +69 -0
  20. package/dist/elements/basic/Countdown/index.mjs +5 -0
  21. package/dist/elements/declarations/index.d.ts +508 -7
  22. package/dist/elements/declarations/index.mjs +84 -72
  23. package/dist/elements/index.d.ts +13 -3
  24. package/dist/elements/index.mjs +76 -66
  25. package/dist/elements/media/Image/Image.d.ts +6 -1
  26. package/dist/elements/media/Image/Image.mjs +44 -35
  27. package/dist/elements/media/Image/Settings.d.ts +2 -1
  28. package/dist/elements/media/Image/Settings.mjs +26 -19
  29. package/dist/elements/media/Image/declaration.d.ts +2 -0
  30. package/dist/elements/media/Image/declaration.mjs +2 -1
  31. package/dist/elements/media/Image/index.d.ts +2 -0
  32. package/dist/elements/settings.mjs +92 -80
  33. package/dist/elements/structure/Container/Container.d.ts +2 -4
  34. package/dist/elements/structure/Container/Container.mjs +5 -6
  35. package/dist/elements/structure/Container/Settings.d.ts +1 -2
  36. package/dist/elements/structure/Container/Settings.mjs +5 -19
  37. package/dist/elements/structure/Container/declaration.d.ts +1 -2
  38. package/dist/elements/structure/Container/declaration.mjs +1 -3
  39. package/dist/elements/structure/Container/index.d.ts +1 -2
  40. package/dist/elements/structure/Disclosure/Disclosure.d.ts +26 -0
  41. package/dist/elements/structure/Disclosure/Disclosure.mjs +49 -0
  42. package/dist/elements/structure/Disclosure/DisclosureSummary/DisclosureSummary.d.ts +16 -0
  43. package/dist/elements/structure/Disclosure/DisclosureSummary/DisclosureSummary.mjs +19 -0
  44. package/dist/elements/structure/Disclosure/DisclosureSummary/Settings.d.ts +7 -0
  45. package/dist/elements/structure/Disclosure/DisclosureSummary/Settings.mjs +20 -0
  46. package/dist/elements/structure/Disclosure/DisclosureSummary/declaration.d.ts +59 -0
  47. package/dist/elements/structure/Disclosure/DisclosureSummary/declaration.mjs +47 -0
  48. package/dist/elements/structure/Disclosure/DisclosureSummary/index.d.ts +57 -0
  49. package/dist/elements/structure/Disclosure/DisclosureSummary/index.mjs +5 -0
  50. package/dist/elements/structure/Disclosure/Settings.d.ts +10 -0
  51. package/dist/elements/structure/Disclosure/Settings.mjs +47 -0
  52. package/dist/elements/structure/Disclosure/declaration.d.ts +66 -0
  53. package/dist/elements/structure/Disclosure/declaration.mjs +55 -0
  54. package/dist/elements/structure/Disclosure/index.d.ts +121 -0
  55. package/dist/elements/structure/Disclosure/index.mjs +9 -0
  56. package/dist/elements/structure/Disclosure/useDetails.d.ts +27 -0
  57. package/dist/elements/structure/Disclosure/useDetails.mjs +49 -0
  58. package/dist/elements/structure/TimeWindow/TimeWindow.mjs +29 -25
  59. package/dist/elements/structure/TimeWindow/TimeWindowContext.d.ts +6 -0
  60. package/dist/elements/structure/TimeWindow/TimeWindowContext.mjs +4 -0
  61. package/dist/elements/{testing → structure}/Variants/Settings.mjs +1 -1
  62. package/dist/elements/{testing → structure}/Variants/VariantItem/Settings.mjs +1 -1
  63. package/dist/elements/{testing → structure}/Variants/VariantItem/VariantItem.mjs +1 -1
  64. package/dist/elements/{testing → structure}/Variants/VariantItem/declaration.d.ts +1 -1
  65. package/dist/elements/{testing → structure}/Variants/VariantItem/declaration.mjs +2 -2
  66. package/dist/elements/{testing → structure}/Variants/VariantItem/index.d.ts +1 -1
  67. package/dist/elements/{testing → structure}/Variants/VariantItem/index.mjs +1 -1
  68. package/dist/elements/{testing → structure}/Variants/Variants.mjs +12 -12
  69. package/dist/elements/{testing → structure/Variants}/childOfItem.mjs +1 -1
  70. package/dist/elements/{testing → structure}/Variants/declaration.d.ts +1 -1
  71. package/dist/elements/{testing → structure}/Variants/declaration.mjs +3 -3
  72. package/dist/elements/{testing → structure}/Variants/index.d.ts +2 -2
  73. package/dist/elements/{testing → structure}/Variants/index.mjs +1 -1
  74. package/dist/elements/user/Account/Account.d.ts +25 -0
  75. package/dist/elements/user/Account/Account.mjs +104 -0
  76. package/dist/elements/user/Account/Settings.d.ts +10 -0
  77. package/dist/elements/user/Account/Settings.mjs +47 -0
  78. package/dist/elements/user/Account/declaration.d.ts +143 -0
  79. package/dist/elements/user/Account/declaration.mjs +123 -0
  80. package/dist/elements/user/Account/index.d.ts +141 -0
  81. package/dist/elements/user/Account/index.mjs +5 -0
  82. package/dist/elements/user/Avatar/Avatar.d.ts +19 -0
  83. package/dist/elements/user/Avatar/Avatar.mjs +26 -0
  84. package/dist/elements/user/Avatar/AvatarFace.d.ts +15 -0
  85. package/dist/elements/user/Avatar/AvatarFace.mjs +28 -0
  86. package/dist/elements/user/Avatar/Settings.d.ts +9 -0
  87. package/dist/elements/user/Avatar/Settings.mjs +38 -0
  88. package/dist/elements/user/Avatar/declaration.d.ts +65 -0
  89. package/dist/elements/user/Avatar/declaration.mjs +53 -0
  90. package/dist/elements/user/Avatar/faces.d.ts +10 -0
  91. package/dist/elements/user/Avatar/faces.mjs +10 -0
  92. package/dist/elements/user/Avatar/index.d.ts +63 -0
  93. package/dist/elements/user/Avatar/index.mjs +5 -0
  94. package/dist/elements/user/SignInForm/Settings.d.ts +16 -0
  95. package/dist/elements/user/SignInForm/Settings.mjs +64 -0
  96. package/dist/elements/user/SignInForm/SignInForm.d.ts +34 -0
  97. package/dist/elements/user/SignInForm/SignInForm.mjs +112 -0
  98. package/dist/elements/user/SignInForm/declaration.d.ts +120 -0
  99. package/dist/elements/user/SignInForm/declaration.mjs +99 -0
  100. package/dist/elements/user/SignInForm/index.d.ts +118 -0
  101. package/dist/elements/user/SignInForm/index.mjs +5 -0
  102. package/dist/index.d.ts +514 -6
  103. package/dist/index.mjs +84 -74
  104. package/package.json +7 -7
  105. /package/dist/elements/{testing → structure}/Variants/Settings.d.ts +0 -0
  106. /package/dist/elements/{testing → structure}/Variants/VariantItem/Settings.d.ts +0 -0
  107. /package/dist/elements/{testing → structure}/Variants/VariantItem/VariantItem.d.ts +0 -0
  108. /package/dist/elements/{testing → structure}/Variants/Variants.d.ts +0 -0
  109. /package/dist/elements/{testing → structure/Variants}/childOfItem.d.ts +0 -0
@@ -1,57 +1,58 @@
1
1
  import e from "./useExperiments.mjs";
2
- import t from "./useRegisterSource.mjs";
3
- import n from "./useResolvedVariables.mjs";
4
- import { use as r, useCallback as i, useEffect as a, useMemo as o, useRef as s } from "react";
5
- import { useStableValue as ee } from "@plitzi/sdk-shared/hooks";
6
- import { getPathsFromObject as c } from "@plitzi/sdk-shared/helpers";
7
- import { useCommonStore as l, useCommonStoreSync as u } from "@plitzi/sdk-shared/store";
8
- import { evaluateComputed as te } from "@plitzi/sdk-shared/dataSource";
9
- import { get as ne } from "@plitzi/plitzi-ui/helpers";
10
- import { flagValues as re, undeclaredFlagOverrides as d } from "@plitzi/sdk-shared/flags";
11
- import { SPACE_THEME_AREA as f, useTheme as p } from "@plitzi/sdk-shared/theme/react";
12
- import { AuthContext as m } from "@plitzi/sdk-auth";
13
- import { useFlagResolution as h } from "@plitzi/sdk-shared/flags/react";
2
+ import t, { dayOf as n } from "./usePageClock.mjs";
3
+ import r from "./useRegisterSource.mjs";
4
+ import i from "./useResolvedVariables.mjs";
5
+ import { use as ee, useCallback as a, useEffect as te, useMemo as o, useRef as ne } from "react";
6
+ import { useStableValue as re } from "@plitzi/sdk-shared/hooks";
7
+ import { getPathsFromObject as s } from "@plitzi/sdk-shared/helpers";
8
+ import { useCommonStore as c, useCommonStoreSync as l } from "@plitzi/sdk-shared/store";
9
+ import { evaluateComputed as u } from "@plitzi/sdk-shared/dataSource";
10
+ import { get as ie } from "@plitzi/plitzi-ui/helpers";
11
+ import { flagValues as ae, undeclaredFlagOverrides as oe } from "@plitzi/sdk-shared/flags";
12
+ import { SPACE_THEME_AREA as d, useTheme as f } from "@plitzi/sdk-shared/theme/react";
13
+ import { AuthContext as p } from "@plitzi/sdk-auth";
14
+ import { useFlagResolution as m } from "@plitzi/sdk-shared/flags/react";
14
15
  // src/dataSource/GlobalSources.tsx
15
- var g = ({ children: g }) => {
16
- let [[_, v, y, b, x, S = ""]] = l([
16
+ var h = ({ children: h }) => {
17
+ let [[g, _, v, y, b, x = ""]] = c([
17
18
  "navigation.routeParams",
18
19
  "navigation.queryParams",
19
20
  "navigation.origin",
20
21
  "navigation.href",
21
22
  "navigation.currentPageId",
22
23
  "navigation.pendingLocation"
23
- ]), C = n(), w = i(() => c(C).map((e) => ({
24
+ ]), S = i(), se = a(() => s(S).map((e) => ({
24
25
  path: e,
25
26
  name: `variables.${e}`
26
- })), [C]);
27
- t({
27
+ })), [S]);
28
+ r({
28
29
  id: "global",
29
30
  source: "variables",
30
31
  name: "Variables",
31
- fields: w
32
- }), u("runtime.sources.variables", C);
33
- let [T = {}] = l("pageDefinitions"), E = o(() => Object.values(T).map((e) => ({
32
+ fields: se
33
+ }), l("runtime.sources.variables", S);
34
+ let [C = {}] = c("pageDefinitions"), w = o(() => Object.values(C).map((e) => ({
34
35
  value: e.id,
35
- label: ne(e, "attributes.name", e.id)
36
- })), [T]), D = o(() => ({
37
- routeParams: _,
38
- queryParams: v,
39
- origin: y,
40
- href: b,
41
- currentPageId: x,
42
- pending: S !== "",
43
- pendingLocation: S
36
+ label: ie(e, "attributes.name", e.id)
37
+ })), [C]), T = o(() => ({
38
+ routeParams: g,
39
+ queryParams: _,
40
+ origin: v,
41
+ href: y,
42
+ currentPageId: b,
43
+ pending: x !== "",
44
+ pendingLocation: x
44
45
  }), [
46
+ g,
45
47
  _,
46
48
  v,
47
49
  y,
48
50
  b,
49
- x,
50
- S
51
- ]), O = i(() => {
52
- let e = c({
53
- routeParams: _,
54
- queryParams: v
51
+ x
52
+ ]), E = a(() => {
53
+ let e = s({
54
+ routeParams: g,
55
+ queryParams: _
55
56
  }).map((e) => ({
56
57
  path: e,
57
58
  name: `navigation.${e}`
@@ -67,11 +68,11 @@ var g = ({ children: g }) => {
67
68
  }, {
68
69
  path: "pendingLocation",
69
70
  name: "Where a navigation is going"
70
- }], i = E.length > 0 ? {
71
+ }], i = w.length > 0 ? {
71
72
  path: "currentPageId",
72
73
  name: "Current Page",
73
74
  inputType: "select",
74
- values: E
75
+ values: w
75
76
  } : {
76
77
  path: "currentPageId",
77
78
  name: "Current Page"
@@ -84,59 +85,59 @@ var g = ({ children: g }) => {
84
85
  i
85
86
  ];
86
87
  }, [
88
+ g,
87
89
  _,
88
- v,
89
- E
90
+ w
90
91
  ]);
91
- t({
92
+ r({
92
93
  id: "global",
93
94
  source: "navigation",
94
95
  name: "Navigation",
95
- fields: O
96
- }), u("runtime.sources.navigation", D);
97
- let k = r(m), { user: A, authenticated: j, state: M, provider: N } = k, P = o(() => N ? {
98
- isAuthenticated: j,
99
- ...M === void 0 ? {} : { status: M },
100
- accessToken: A?.accessToken ?? "",
96
+ fields: E
97
+ }), l("runtime.sources.navigation", T);
98
+ let D = ee(p), { user: O, authenticated: k, state: A, provider: j } = D, M = o(() => j ? {
99
+ isAuthenticated: k,
100
+ ...A === void 0 ? {} : { status: A },
101
+ accessToken: O?.accessToken ?? "",
101
102
  details: {
102
103
  username: "",
103
104
  email: "",
104
105
  roles: "",
105
106
  permissions: "",
106
107
  verified: "",
107
- ...A?.details ?? {}
108
+ ...O?.details ?? {}
108
109
  }
109
110
  } : {}, [
110
- N,
111
- A,
112
111
  j,
113
- M
114
- ]), F = i(() => c(P).map((e) => ({
112
+ O,
113
+ k,
114
+ A
115
+ ]), N = a(() => s(M).map((e) => ({
115
116
  path: e,
116
117
  name: `user.${e}`
117
- })), [P]);
118
- t({
118
+ })), [M]);
119
+ r({
119
120
  id: "global",
120
121
  source: "auth",
121
122
  name: "Auth State",
122
- fields: F
123
- }), u("runtime.sources.auth", P);
124
- let I = h(k), L = o(() => re(I), [I]), R = i(() => Object.keys(L).map((e) => ({
123
+ fields: N
124
+ }), l("runtime.sources.auth", M);
125
+ let P = m(D), F = o(() => ae(P), [P]), I = a(() => Object.keys(F).map((e) => ({
125
126
  path: e,
126
127
  name: `flags.${e}`,
127
128
  inputType: "checkbox"
128
- })), [L]);
129
- t({
129
+ })), [F]);
130
+ r({
130
131
  id: "global",
131
132
  source: "flags",
132
133
  name: "Feature Flags",
133
- fields: R
134
- }), u("runtime.sources.flags", L), u("flags.resolved", I);
135
- let [z, B] = l(["schema.flags", "flags.overrides"])[0], V = ee(d(z, B ?? {}));
136
- a(() => {
137
- V.forEach(({ layer: e, name: t }) => console.warn(`[plitzi] The ${e} sets the feature flag "${t}", which this space does not declare: the override is ignored. Declare the flag in the space, or remove the override.`));
138
- }, [V]);
139
- let H = e(), U = i(() => Object.keys(H).map((e) => ({
134
+ fields: I
135
+ }), l("runtime.sources.flags", F), l("flags.resolved", P);
136
+ let [L, R] = c(["schema.flags", "flags.overrides"])[0], z = re(oe(L, R ?? {}));
137
+ te(() => {
138
+ z.forEach(({ layer: e, name: t }) => console.warn(`[plitzi] The ${e} sets the feature flag "${t}", which this space does not declare: the override is ignored. Declare the flag in the space, or remove the override.`));
139
+ }, [z]);
140
+ let B = e(), V = a(() => Object.keys(B).map((e) => ({
140
141
  path: e,
141
142
  name: `experiments.${e}`,
142
143
  inputType: "select",
@@ -147,76 +148,92 @@ var g = ({ children: g }) => {
147
148
  value: "b",
148
149
  label: "B"
149
150
  }]
150
- })), [H]);
151
- t({
151
+ })), [B]);
152
+ r({
152
153
  id: "global",
153
154
  source: "experiments",
154
155
  name: "Experiments",
155
- fields: U
156
- }), u("runtime.sources.experiments", H), u("experiments.assigned", H);
157
- let [W] = l("runtime.state"), G = i(() => c(W).map((e) => ({
156
+ fields: V
157
+ }), l("runtime.sources.experiments", B), l("experiments.assigned", B);
158
+ let H = t(), U = o(() => ({
159
+ now: H,
160
+ today: n(H)
161
+ }), [H]), W = a(() => [{
162
+ path: "now",
163
+ name: "Now (the minute)"
164
+ }, {
165
+ path: "today",
166
+ name: "Today (UTC)"
167
+ }], []);
168
+ r({
169
+ id: "global",
170
+ source: "time",
171
+ name: "Time",
172
+ fields: W
173
+ }), l("runtime.sources.time", U);
174
+ let [G] = c("runtime.state"), K = a(() => s(G).map((e) => ({
158
175
  path: e,
159
176
  name: `state.${e}`
160
- })), [W]);
161
- t({
177
+ })), [G]);
178
+ r({
162
179
  id: "global",
163
180
  source: "state",
164
181
  name: "State",
165
- fields: G
166
- }), u("runtime.sources.state", W);
167
- let [K] = l("runtime.host"), q = i(() => c(K).map((e) => ({
182
+ fields: K
183
+ }), l("runtime.sources.state", G);
184
+ let [q] = c("runtime.host"), ce = a(() => s(q).map((e) => ({
168
185
  path: e,
169
186
  name: `host.${e}`
170
- })), [K]);
171
- t({
187
+ })), [q]);
188
+ r({
172
189
  id: "global",
173
190
  source: "host",
174
191
  name: "Host",
175
- fields: q
176
- }), u("runtime.sources.host", K);
177
- let { theme: J, resolvedTheme: Y } = p(f), X = o(() => ({
192
+ fields: ce
193
+ }), l("runtime.sources.host", q);
194
+ let { theme: J, resolvedTheme: Y } = f(d), X = o(() => ({
178
195
  mode: J,
179
196
  resolved: Y
180
- }), [J, Y]), ie = i(() => c(X).map((e) => ({
197
+ }), [J, Y]), le = a(() => s(X).map((e) => ({
181
198
  path: e,
182
199
  name: `theme.${e}`
183
200
  })), [X]);
184
- t({
201
+ r({
185
202
  id: "global",
186
203
  source: "theme",
187
204
  name: "Theme",
188
- fields: ie
189
- }), u("runtime.sources.theme", X);
190
- let [Z] = l("schema.settings.computed"), Q = s(void 0), $ = o(() => te(Z ?? {}, {
191
- variables: C,
192
- navigation: D,
193
- auth: P,
194
- state: W ?? {},
195
- host: K ?? {},
205
+ fields: le
206
+ }), l("runtime.sources.theme", X);
207
+ let [Z] = c("schema.settings.computed"), Q = ne(void 0), $ = o(() => u(Z ?? {}, {
208
+ variables: S,
209
+ navigation: T,
210
+ auth: M,
211
+ state: G ?? {},
212
+ host: q ?? {},
196
213
  theme: X,
197
- flags: L,
198
- experiments: H
214
+ flags: F,
215
+ experiments: B
199
216
  }, Q.current), [
200
217
  Z,
201
- C,
202
- D,
203
- P,
204
- W,
205
- K,
218
+ S,
219
+ T,
220
+ M,
221
+ G,
222
+ q,
206
223
  X,
207
- L,
208
- H
224
+ F,
225
+ B
209
226
  ]);
210
227
  Q.current = $;
211
- let ae = i(() => c($).map((e) => ({
228
+ let ue = a(() => s($).map((e) => ({
212
229
  path: e,
213
230
  name: `computed.${e}`
214
231
  })), [$]);
215
- return t({
232
+ return r({
216
233
  id: "global",
217
234
  source: "computed",
218
235
  name: "Computed",
219
- fields: ae
220
- }), u("runtime.sources.computed", $), g;
236
+ fields: ue
237
+ }), l("runtime.sources.computed", $), h;
221
238
  };
222
- export { g as default };
239
+ export { h as default };
@@ -7,7 +7,8 @@ import { browserVisitorFacts as s, keepFirstSeen as c } from "@plitzi/sdk-shared
7
7
  var l = {
8
8
  returning: !1,
9
9
  language: "",
10
- device: "desktop"
10
+ device: "desktop",
11
+ country: ""
11
12
  }, u = () => {
12
13
  let { environment: u, builder: d } = i(), [[f, p, m, h]] = r([
13
14
  "navigation.hostname",
@@ -0,0 +1,12 @@
1
+ /** The start of the minute an instant is in. */
2
+ export declare const minuteOf: (at: number) => number;
3
+ /** The day an instant is in, in UTC: `2026-11-24`. */
4
+ export declare const dayOf: (at: number) => string;
5
+ /**
6
+ * The page's clock, minute by minute — what `time.now` reads. Drawn at the minute the server drew the page at (its
7
+ * `clock`), so the page hydrates on what it was drawn with; then the browser's own, moving on at each minute's turn and
8
+ * at once when the page comes back into view (a hidden tab's timers are held back). The minute the builder simulates
9
+ * is kept as it is.
10
+ */
11
+ declare const usePageClock: () => number;
12
+ export default usePageClock;
@@ -0,0 +1,19 @@
1
+ import { useEffect as e, useState as t } from "react";
2
+ import { useCommonStore as n } from "@plitzi/sdk-shared/store";
3
+ import { TIME_GRAIN_MS as r } from "@plitzi/sdk-shared/helpers/twigWrapper";
4
+ // src/dataSource/usePageClock.ts
5
+ var i = (e) => e - e % r, a = (e) => new Date(e).toISOString().slice(0, 10), o = () => {
6
+ let [a] = n("clock"), [o, s] = t(() => i(a?.at ?? Date.now()));
7
+ return e(() => {
8
+ s(i(a?.simulated ? a.at : Date.now()));
9
+ }, [a]), e(() => {
10
+ if (a?.simulated) return;
11
+ let e = setTimeout(() => s(i(Date.now())), r - Date.now() % r), t = () => {
12
+ document.visibilityState === "visible" && s(i(Date.now()));
13
+ };
14
+ return document.addEventListener("visibilitychange", t), () => {
15
+ clearTimeout(e), document.removeEventListener("visibilitychange", t);
16
+ };
17
+ }, [a, o]), o;
18
+ };
19
+ export { a as dayOf, o as default, i as minuteOf };
@@ -0,0 +1,23 @@
1
+ import { CountdownLabels, CountdownUnit } from '@plitzi/sdk-shared/timeWindows';
2
+ import { RefObject } from 'react';
3
+ export type CountdownProps = {
4
+ ref?: RefObject<HTMLElement | null>;
5
+ className?: string;
6
+ /**
7
+ * The instant it counts to: ISO 8601 with the offset — `2026-12-01T09:00:00Z`. Empty, the end of the time window it
8
+ * is in (`endsAt`), so the date is written once.
9
+ */
10
+ to?: string;
11
+ /** The largest unit it says: what is left beyond it is said in it — 49 hours with `hours`. */
12
+ largest?: CountdownUnit;
13
+ /** The smallest unit it says, and how often it changes: every second, or every minute. */
14
+ smallest?: CountdownUnit;
15
+ /** Its units named in words (`days`), short (`d`, `hr`) or not at all — in the page's language and plural. */
16
+ labels?: CountdownLabels;
17
+ /** The language its units are named in (`es`, `pt-BR`). Empty, the space's (`settings.language`). */
18
+ locale?: string;
19
+ };
20
+ declare const Countdown: ({ ref, className, to, largest, smallest, labels, locale }: CountdownProps) => import('react').JSX.Element;
21
+ declare const _default: import('react').FC<import('../../..').WithElementProps<CountdownProps>>;
22
+ export default _default;
23
+ export { Countdown };
@@ -0,0 +1,58 @@
1
+ import e from "../../../Element/hocs/withElement.mjs";
2
+ import t from "../../../Element/hooks/useElement.mjs";
3
+ import { RootElement as n } from "../../../Element/RootElement.mjs";
4
+ import r from "../../structure/TimeWindow/TimeWindowContext.mjs";
5
+ import { use as i, useEffect as a, useRef as o, useState as s } from "react";
6
+ import { useCommonStore as c } from "@plitzi/sdk-shared/store";
7
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
8
+ import { countdownDuration as d, countdownLabel as f, countdownParts as p, countdownTarget as m, nextCountdownTick as h } from "@plitzi/sdk-shared/timeWindows";
9
+ import g from "clsx";
10
+ import { InteractionsContext as _ } from "@plitzi/sdk-interactions";
11
+ // src/elements/basic/Countdown/Countdown.tsx
12
+ var v = (e, t) => t ? String(e) : String(e).padStart(2, "0"), y = ({ ref: e, className: y = "", to: b = "", largest: x = "days", smallest: S = "seconds", labels: C = "long", locale: w = "" }) => {
13
+ let { id: T, definition: { styleSelectors: E } } = t(), { interactionsManager: D } = i(_), O = i(r), [k] = c("clock"), [A] = c("schema.settings.language"), [j, M] = s(() => k?.at ?? Date.now()), N = m(b, O?.endsAt);
14
+ a(() => {
15
+ M(k?.simulated ? k.at : Date.now());
16
+ }, [k]), a(() => {
17
+ let e = N === void 0 || k?.simulated ? void 0 : h(j, N, S);
18
+ if (e === void 0) return;
19
+ let t = setTimeout(() => M(Date.now()), Math.max(0, e - Date.now()));
20
+ return () => clearTimeout(t);
21
+ }, [
22
+ k,
23
+ j,
24
+ N,
25
+ S
26
+ ]);
27
+ let P = N !== void 0 && j >= N, F = o(!1);
28
+ a(() => {
29
+ P && !F.current && !k?.simulated && T && (F.current = !0, D.interactionTrigger(T, "onCountdownEnd", {}));
30
+ }, [
31
+ P,
32
+ k,
33
+ T,
34
+ D
35
+ ]);
36
+ let I = p(j, N ?? j, x, S);
37
+ return /* @__PURE__ */ l(n, {
38
+ tag: "time",
39
+ ref: e,
40
+ role: "timer",
41
+ dateTime: d(I),
42
+ className: g("plitzi-component__countdown", y),
43
+ children: I.map(({ unit: e, amount: t }, n) => {
44
+ let r = f(e, t, C, w || A || "en");
45
+ return /* @__PURE__ */ u("span", {
46
+ className: g("plitzi-component__countdown-unit", E.unit),
47
+ children: [/* @__PURE__ */ l("span", {
48
+ className: g("plitzi-component__countdown-value", E.value),
49
+ children: v(t, n === 0)
50
+ }), r && /* @__PURE__ */ l("span", {
51
+ className: g("plitzi-component__countdown-label", E.label),
52
+ children: r
53
+ })]
54
+ }, e);
55
+ })
56
+ });
57
+ }, b = e(y);
58
+ export { y as Countdown, b as default };
@@ -0,0 +1,12 @@
1
+ import { CountdownLabels, CountdownUnit } from '@plitzi/sdk-shared/timeWindows';
2
+ type SettingsProps = {
3
+ to?: string;
4
+ largest?: CountdownUnit;
5
+ smallest?: CountdownUnit;
6
+ labels?: CountdownLabels;
7
+ locale?: string;
8
+ onUpdate?: (key: string, value: string | boolean | number) => void;
9
+ };
10
+ /** A countdown's settings: what it counts to, the units it says, and how it names them. */
11
+ declare const Settings: ({ to, largest, smallest, labels, locale, onUpdate }: SettingsProps) => import('react').JSX.Element;
12
+ export default Settings;
@@ -0,0 +1,94 @@
1
+ import e from "../../useSettingsUpdate.mjs";
2
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
+ import { isWindowBound as r } from "@plitzi/sdk-shared/timeWindows";
4
+ import i from "@plitzi/plitzi-ui/Input";
5
+ import a from "@plitzi/plitzi-ui/Select";
6
+ // src/elements/basic/Countdown/Settings.tsx
7
+ var o = [
8
+ {
9
+ value: "days",
10
+ label: "Days"
11
+ },
12
+ {
13
+ value: "hours",
14
+ label: "Hours"
15
+ },
16
+ {
17
+ value: "minutes",
18
+ label: "Minutes"
19
+ },
20
+ {
21
+ value: "seconds",
22
+ label: "Seconds"
23
+ }
24
+ ], s = ({ to: s = "", largest: c = "days", smallest: l = "seconds", labels: u = "long", locale: d = "", onUpdate: f }) => {
25
+ let p = e(f), m = !r(s);
26
+ return /* @__PURE__ */ n("div", {
27
+ className: "flex flex-col gap-4 py-2",
28
+ children: [
29
+ /* @__PURE__ */ t(i, {
30
+ label: "Counts to",
31
+ size: "xs",
32
+ placeholder: "2026-12-01T09:00:00Z",
33
+ value: s,
34
+ onChange: p.text("to")
35
+ }),
36
+ /* @__PURE__ */ t("span", {
37
+ className: "text-ui-fg-subtle text-xs",
38
+ children: m ? "Not read: write it with its offset — 2026-12-01T09:00:00Z, or +01:00 for CET." : "Empty, it counts to the end of the time window it is in."
39
+ }),
40
+ /* @__PURE__ */ t(a, {
41
+ label: "From",
42
+ size: "xs",
43
+ value: c,
44
+ onChange: p.text("largest"),
45
+ children: o.map((e) => /* @__PURE__ */ t("option", {
46
+ value: e.value,
47
+ children: e.label
48
+ }, e.value))
49
+ }),
50
+ /* @__PURE__ */ t(a, {
51
+ label: "Down to",
52
+ size: "xs",
53
+ value: l,
54
+ onChange: p.text("smallest"),
55
+ children: o.map((e) => /* @__PURE__ */ t("option", {
56
+ value: e.value,
57
+ children: e.label
58
+ }, e.value))
59
+ }),
60
+ /* @__PURE__ */ n(a, {
61
+ label: "Unit names",
62
+ size: "xs",
63
+ value: u,
64
+ onChange: p.text("labels"),
65
+ children: [
66
+ /* @__PURE__ */ t("option", {
67
+ value: "long",
68
+ children: "Words (days)"
69
+ }),
70
+ /* @__PURE__ */ t("option", {
71
+ value: "short",
72
+ children: "Short (d, hr)"
73
+ }),
74
+ /* @__PURE__ */ t("option", {
75
+ value: "none",
76
+ children: "None"
77
+ })
78
+ ]
79
+ }),
80
+ /* @__PURE__ */ t(i, {
81
+ label: "Language",
82
+ size: "xs",
83
+ placeholder: "The space’s",
84
+ value: d,
85
+ onChange: p.text("locale")
86
+ }),
87
+ /* @__PURE__ */ t("span", {
88
+ className: "text-ui-fg-subtle text-xs",
89
+ children: "While editing it counts at the date chosen in the State Manager’s Visitor tab, when one is."
90
+ })
91
+ ]
92
+ });
93
+ };
94
+ export { s as default };
@@ -0,0 +1,72 @@
1
+ import { CountdownProps } from './Countdown';
2
+ import { AuthorableAttributes } from '@plitzi/sdk-shared/authoring';
3
+ import { CountdownLabels, CountdownUnit } from '@plitzi/sdk-shared/timeWindows';
4
+ /** What this element can be authored with — its component's own props, minus what the runtime supplies. */
5
+ export type CountdownAttributes = AuthorableAttributes<CountdownProps>;
6
+ declare const declaration: import('@plitzi/sdk-shared/authoring').DeclaredElement<{
7
+ readonly type: "countdown";
8
+ readonly attributeValues: {
9
+ readonly largest: readonly string[];
10
+ readonly smallest: readonly string[];
11
+ readonly labels: readonly string[];
12
+ };
13
+ readonly triggers: {
14
+ readonly onCountdownEnd: {
15
+ readonly action: "onCountdownEnd";
16
+ readonly title: "On Countdown End";
17
+ readonly type: "trigger";
18
+ readonly params: {};
19
+ readonly preview: {};
20
+ };
21
+ };
22
+ readonly content: {
23
+ readonly attributes: {
24
+ readonly to: "";
25
+ readonly largest: "days";
26
+ readonly smallest: "seconds";
27
+ readonly labels: "long";
28
+ readonly locale: "";
29
+ };
30
+ readonly definition: {
31
+ readonly label: "Countdown";
32
+ readonly description: string;
33
+ readonly items: [];
34
+ readonly styleSelectors: {
35
+ readonly unit: "";
36
+ readonly value: "";
37
+ readonly label: "";
38
+ };
39
+ };
40
+ readonly market: {
41
+ readonly category: "basic";
42
+ readonly icon: "fa-solid fa-hourglass-half";
43
+ };
44
+ readonly defaultStyle: {
45
+ readonly style: {
46
+ readonly base: {
47
+ readonly default: {
48
+ readonly display: "inline-flex";
49
+ readonly 'flex-wrap': "wrap";
50
+ readonly gap: "0.5em";
51
+ readonly 'font-variant-numeric': "tabular-nums";
52
+ };
53
+ };
54
+ readonly unit: {
55
+ readonly default: {
56
+ readonly display: "inline-flex";
57
+ readonly 'align-items': "baseline";
58
+ readonly gap: "0.25em";
59
+ };
60
+ };
61
+ };
62
+ readonly subTypes: {};
63
+ };
64
+ };
65
+ }, Partial<{
66
+ to?: string | undefined;
67
+ largest?: CountdownUnit | undefined;
68
+ smallest?: CountdownUnit | undefined;
69
+ labels?: CountdownLabels | undefined;
70
+ locale?: string | undefined;
71
+ }>>;
72
+ export default declaration;