@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.
- package/CHANGELOG.md +28 -0
- package/dist/Element/PluginManager.mjs +13 -13
- package/dist/Element/hooks/useElementState.d.ts +1 -1
- package/dist/Element/hooks/useFullscreenInteractions.d.ts +11 -0
- package/dist/Element/hooks/useFullscreenInteractions.mjs +14 -0
- package/dist/Element/hooks/useRootElementInteractions.mjs +93 -87
- package/dist/builder/ruleFields.d.ts +1 -1
- package/dist/builder/ruleFields.mjs +5 -0
- package/dist/dataSource/GlobalSources.mjs +121 -104
- package/dist/dataSource/useAudienceScope.mjs +2 -1
- package/dist/dataSource/usePageClock.d.ts +12 -0
- package/dist/dataSource/usePageClock.mjs +19 -0
- package/dist/elements/basic/Countdown/Countdown.d.ts +23 -0
- package/dist/elements/basic/Countdown/Countdown.mjs +58 -0
- package/dist/elements/basic/Countdown/Settings.d.ts +12 -0
- package/dist/elements/basic/Countdown/Settings.mjs +94 -0
- package/dist/elements/basic/Countdown/declaration.d.ts +72 -0
- package/dist/elements/basic/Countdown/declaration.mjs +58 -0
- package/dist/elements/basic/Countdown/index.d.ts +69 -0
- package/dist/elements/basic/Countdown/index.mjs +5 -0
- package/dist/elements/declarations/index.d.ts +508 -7
- package/dist/elements/declarations/index.mjs +84 -72
- package/dist/elements/index.d.ts +13 -3
- package/dist/elements/index.mjs +76 -66
- package/dist/elements/media/Image/Image.d.ts +6 -1
- package/dist/elements/media/Image/Image.mjs +44 -35
- package/dist/elements/media/Image/Settings.d.ts +2 -1
- package/dist/elements/media/Image/Settings.mjs +26 -19
- package/dist/elements/media/Image/declaration.d.ts +2 -0
- package/dist/elements/media/Image/declaration.mjs +2 -1
- package/dist/elements/media/Image/index.d.ts +2 -0
- package/dist/elements/settings.mjs +92 -80
- package/dist/elements/structure/Container/Container.d.ts +2 -4
- package/dist/elements/structure/Container/Container.mjs +5 -6
- package/dist/elements/structure/Container/Settings.d.ts +1 -2
- package/dist/elements/structure/Container/Settings.mjs +5 -19
- package/dist/elements/structure/Container/declaration.d.ts +1 -2
- package/dist/elements/structure/Container/declaration.mjs +1 -3
- package/dist/elements/structure/Container/index.d.ts +1 -2
- package/dist/elements/structure/Disclosure/Disclosure.d.ts +26 -0
- package/dist/elements/structure/Disclosure/Disclosure.mjs +49 -0
- package/dist/elements/structure/Disclosure/DisclosureSummary/DisclosureSummary.d.ts +16 -0
- package/dist/elements/structure/Disclosure/DisclosureSummary/DisclosureSummary.mjs +19 -0
- package/dist/elements/structure/Disclosure/DisclosureSummary/Settings.d.ts +7 -0
- package/dist/elements/structure/Disclosure/DisclosureSummary/Settings.mjs +20 -0
- package/dist/elements/structure/Disclosure/DisclosureSummary/declaration.d.ts +59 -0
- package/dist/elements/structure/Disclosure/DisclosureSummary/declaration.mjs +47 -0
- package/dist/elements/structure/Disclosure/DisclosureSummary/index.d.ts +57 -0
- package/dist/elements/structure/Disclosure/DisclosureSummary/index.mjs +5 -0
- package/dist/elements/structure/Disclosure/Settings.d.ts +10 -0
- package/dist/elements/structure/Disclosure/Settings.mjs +47 -0
- package/dist/elements/structure/Disclosure/declaration.d.ts +66 -0
- package/dist/elements/structure/Disclosure/declaration.mjs +55 -0
- package/dist/elements/structure/Disclosure/index.d.ts +121 -0
- package/dist/elements/structure/Disclosure/index.mjs +9 -0
- package/dist/elements/structure/Disclosure/useDetails.d.ts +27 -0
- package/dist/elements/structure/Disclosure/useDetails.mjs +49 -0
- package/dist/elements/structure/TimeWindow/TimeWindow.mjs +29 -25
- package/dist/elements/structure/TimeWindow/TimeWindowContext.d.ts +6 -0
- package/dist/elements/structure/TimeWindow/TimeWindowContext.mjs +4 -0
- package/dist/elements/{testing → structure}/Variants/Settings.mjs +1 -1
- package/dist/elements/{testing → structure}/Variants/VariantItem/Settings.mjs +1 -1
- package/dist/elements/{testing → structure}/Variants/VariantItem/VariantItem.mjs +1 -1
- package/dist/elements/{testing → structure}/Variants/VariantItem/declaration.d.ts +1 -1
- package/dist/elements/{testing → structure}/Variants/VariantItem/declaration.mjs +2 -2
- package/dist/elements/{testing → structure}/Variants/VariantItem/index.d.ts +1 -1
- package/dist/elements/{testing → structure}/Variants/VariantItem/index.mjs +1 -1
- package/dist/elements/{testing → structure}/Variants/Variants.mjs +12 -12
- package/dist/elements/{testing → structure/Variants}/childOfItem.mjs +1 -1
- package/dist/elements/{testing → structure}/Variants/declaration.d.ts +1 -1
- package/dist/elements/{testing → structure}/Variants/declaration.mjs +3 -3
- package/dist/elements/{testing → structure}/Variants/index.d.ts +2 -2
- package/dist/elements/{testing → structure}/Variants/index.mjs +1 -1
- package/dist/elements/user/Account/Account.d.ts +25 -0
- package/dist/elements/user/Account/Account.mjs +104 -0
- package/dist/elements/user/Account/Settings.d.ts +10 -0
- package/dist/elements/user/Account/Settings.mjs +47 -0
- package/dist/elements/user/Account/declaration.d.ts +143 -0
- package/dist/elements/user/Account/declaration.mjs +123 -0
- package/dist/elements/user/Account/index.d.ts +141 -0
- package/dist/elements/user/Account/index.mjs +5 -0
- package/dist/elements/user/Avatar/Avatar.d.ts +19 -0
- package/dist/elements/user/Avatar/Avatar.mjs +26 -0
- package/dist/elements/user/Avatar/AvatarFace.d.ts +15 -0
- package/dist/elements/user/Avatar/AvatarFace.mjs +28 -0
- package/dist/elements/user/Avatar/Settings.d.ts +9 -0
- package/dist/elements/user/Avatar/Settings.mjs +38 -0
- package/dist/elements/user/Avatar/declaration.d.ts +65 -0
- package/dist/elements/user/Avatar/declaration.mjs +53 -0
- package/dist/elements/user/Avatar/faces.d.ts +10 -0
- package/dist/elements/user/Avatar/faces.mjs +10 -0
- package/dist/elements/user/Avatar/index.d.ts +63 -0
- package/dist/elements/user/Avatar/index.mjs +5 -0
- package/dist/elements/user/SignInForm/Settings.d.ts +16 -0
- package/dist/elements/user/SignInForm/Settings.mjs +64 -0
- package/dist/elements/user/SignInForm/SignInForm.d.ts +34 -0
- package/dist/elements/user/SignInForm/SignInForm.mjs +112 -0
- package/dist/elements/user/SignInForm/declaration.d.ts +120 -0
- package/dist/elements/user/SignInForm/declaration.mjs +99 -0
- package/dist/elements/user/SignInForm/index.d.ts +118 -0
- package/dist/elements/user/SignInForm/index.mjs +5 -0
- package/dist/index.d.ts +514 -6
- package/dist/index.mjs +84 -74
- package/package.json +7 -7
- /package/dist/elements/{testing → structure}/Variants/Settings.d.ts +0 -0
- /package/dist/elements/{testing → structure}/Variants/VariantItem/Settings.d.ts +0 -0
- /package/dist/elements/{testing → structure}/Variants/VariantItem/VariantItem.d.ts +0 -0
- /package/dist/elements/{testing → structure}/Variants/Variants.d.ts +0 -0
- /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 "./
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
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
|
|
16
|
-
let [[_, v, y, b, x
|
|
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
|
-
]),
|
|
24
|
+
]), S = i(), se = a(() => s(S).map((e) => ({
|
|
24
25
|
path: e,
|
|
25
26
|
name: `variables.${e}`
|
|
26
|
-
})), [
|
|
27
|
-
|
|
27
|
+
})), [S]);
|
|
28
|
+
r({
|
|
28
29
|
id: "global",
|
|
29
30
|
source: "variables",
|
|
30
31
|
name: "Variables",
|
|
31
|
-
fields:
|
|
32
|
-
}),
|
|
33
|
-
let [
|
|
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:
|
|
36
|
-
})), [
|
|
37
|
-
routeParams:
|
|
38
|
-
queryParams:
|
|
39
|
-
origin:
|
|
40
|
-
href:
|
|
41
|
-
currentPageId:
|
|
42
|
-
pending:
|
|
43
|
-
pendingLocation:
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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 =
|
|
71
|
+
}], i = w.length > 0 ? {
|
|
71
72
|
path: "currentPageId",
|
|
72
73
|
name: "Current Page",
|
|
73
74
|
inputType: "select",
|
|
74
|
-
values:
|
|
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
|
-
|
|
89
|
-
E
|
|
90
|
+
w
|
|
90
91
|
]);
|
|
91
|
-
|
|
92
|
+
r({
|
|
92
93
|
id: "global",
|
|
93
94
|
source: "navigation",
|
|
94
95
|
name: "Navigation",
|
|
95
|
-
fields:
|
|
96
|
-
}),
|
|
97
|
-
let
|
|
98
|
-
isAuthenticated:
|
|
99
|
-
...
|
|
100
|
-
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
|
-
...
|
|
108
|
+
...O?.details ?? {}
|
|
108
109
|
}
|
|
109
110
|
} : {}, [
|
|
110
|
-
N,
|
|
111
|
-
A,
|
|
112
111
|
j,
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
O,
|
|
113
|
+
k,
|
|
114
|
+
A
|
|
115
|
+
]), N = a(() => s(M).map((e) => ({
|
|
115
116
|
path: e,
|
|
116
117
|
name: `user.${e}`
|
|
117
|
-
})), [
|
|
118
|
-
|
|
118
|
+
})), [M]);
|
|
119
|
+
r({
|
|
119
120
|
id: "global",
|
|
120
121
|
source: "auth",
|
|
121
122
|
name: "Auth State",
|
|
122
|
-
fields:
|
|
123
|
-
}),
|
|
124
|
-
let
|
|
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
|
-
})), [
|
|
129
|
-
|
|
129
|
+
})), [F]);
|
|
130
|
+
r({
|
|
130
131
|
id: "global",
|
|
131
132
|
source: "flags",
|
|
132
133
|
name: "Feature Flags",
|
|
133
|
-
fields:
|
|
134
|
-
}),
|
|
135
|
-
let [
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}, [
|
|
139
|
-
let
|
|
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
|
-
})), [
|
|
151
|
-
|
|
151
|
+
})), [B]);
|
|
152
|
+
r({
|
|
152
153
|
id: "global",
|
|
153
154
|
source: "experiments",
|
|
154
155
|
name: "Experiments",
|
|
155
|
-
fields:
|
|
156
|
-
}),
|
|
157
|
-
let
|
|
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
|
-
})), [
|
|
161
|
-
|
|
177
|
+
})), [G]);
|
|
178
|
+
r({
|
|
162
179
|
id: "global",
|
|
163
180
|
source: "state",
|
|
164
181
|
name: "State",
|
|
165
|
-
fields:
|
|
166
|
-
}),
|
|
167
|
-
let [
|
|
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
|
-
})), [
|
|
171
|
-
|
|
187
|
+
})), [q]);
|
|
188
|
+
r({
|
|
172
189
|
id: "global",
|
|
173
190
|
source: "host",
|
|
174
191
|
name: "Host",
|
|
175
|
-
fields:
|
|
176
|
-
}),
|
|
177
|
-
let { theme: J, resolvedTheme: Y } =
|
|
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]),
|
|
197
|
+
}), [J, Y]), le = a(() => s(X).map((e) => ({
|
|
181
198
|
path: e,
|
|
182
199
|
name: `theme.${e}`
|
|
183
200
|
})), [X]);
|
|
184
|
-
|
|
201
|
+
r({
|
|
185
202
|
id: "global",
|
|
186
203
|
source: "theme",
|
|
187
204
|
name: "Theme",
|
|
188
|
-
fields:
|
|
189
|
-
}),
|
|
190
|
-
let [Z] =
|
|
191
|
-
variables:
|
|
192
|
-
navigation:
|
|
193
|
-
auth:
|
|
194
|
-
state:
|
|
195
|
-
host:
|
|
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:
|
|
198
|
-
experiments:
|
|
214
|
+
flags: F,
|
|
215
|
+
experiments: B
|
|
199
216
|
}, Q.current), [
|
|
200
217
|
Z,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
218
|
+
S,
|
|
219
|
+
T,
|
|
220
|
+
M,
|
|
221
|
+
G,
|
|
222
|
+
q,
|
|
206
223
|
X,
|
|
207
|
-
|
|
208
|
-
|
|
224
|
+
F,
|
|
225
|
+
B
|
|
209
226
|
]);
|
|
210
227
|
Q.current = $;
|
|
211
|
-
let
|
|
228
|
+
let ue = a(() => s($).map((e) => ({
|
|
212
229
|
path: e,
|
|
213
230
|
name: `computed.${e}`
|
|
214
231
|
})), [$]);
|
|
215
|
-
return
|
|
232
|
+
return r({
|
|
216
233
|
id: "global",
|
|
217
234
|
source: "computed",
|
|
218
235
|
name: "Computed",
|
|
219
|
-
fields:
|
|
220
|
-
}),
|
|
236
|
+
fields: ue
|
|
237
|
+
}), l("runtime.sources.computed", $), h;
|
|
221
238
|
};
|
|
222
|
-
export {
|
|
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;
|