@plitzi/sdk-elements 0.38.2 → 0.38.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 +335 -0
- package/dist/Element/RootElement.mjs +58 -50
- package/dist/Element/helpers/renderStaticTag.d.ts +8 -2
- package/dist/Element/helpers/renderStaticTag.mjs +5 -4
- package/dist/canvas/index.d.ts +6 -0
- package/dist/canvas/index.mjs +5 -0
- package/dist/canvas/shaders.d.ts +16 -0
- package/dist/canvas/shaders.mjs +25 -0
- package/dist/canvas/useAnimationFrame.d.ts +27 -0
- package/dist/canvas/useAnimationFrame.mjs +42 -0
- package/dist/canvas/useCanvas.d.ts +51 -0
- package/dist/canvas/useCanvas.mjs +133 -0
- package/dist/canvas/useReducedMotion.d.ts +6 -0
- package/dist/canvas/useReducedMotion.mjs +15 -0
- package/dist/elements/basic/Button/Button.d.ts +6 -1
- package/dist/elements/basic/Button/Button.mjs +9 -8
- package/dist/elements/basic/Button/declaration.d.ts +1 -0
- package/dist/elements/basic/Button/index.d.ts +1 -0
- package/dist/elements/declarations/index.d.ts +6 -2
- package/dist/elements/form/FormControl/FormControl.d.ts +5 -1
- package/dist/elements/form/FormControl/FormControl.mjs +3 -0
- package/dist/elements/form/FormControl/Settings.d.ts +1 -1
- package/dist/elements/form/FormControl/Settings.mjs +16 -1
- package/dist/elements/form/FormControl/declaration.mjs +3 -0
- package/dist/elements/media/Image/Image.d.ts +7 -1
- package/dist/elements/media/Image/Image.mjs +10 -10
- package/dist/elements/media/Image/declaration.d.ts +2 -1
- package/dist/elements/media/Image/declaration.mjs +1 -1
- package/dist/elements/media/Image/index.d.ts +2 -1
- package/dist/elements/provider/ApiContainer/ApiContainer.d.ts +1 -1
- package/dist/elements/provider/ApiContainer/ApiContainer.mjs +123 -131
- package/dist/elements/provider/ApiContainer/helpers/serverMock.d.ts +10 -0
- package/dist/elements/provider/ApiContainer/helpers/serverMock.mjs +17 -0
- package/dist/elements/structure/Container/Container.d.ts +8 -2
- package/dist/elements/structure/Container/Container.mjs +6 -5
- package/dist/elements/structure/Container/declaration.d.ts +3 -1
- package/dist/elements/structure/Container/declaration.mjs +31 -23
- package/dist/elements/structure/Container/index.d.ts +3 -1
- package/dist/elements/structure/List/List.mjs +1 -0
- package/dist/elements/structure/List/Settings.mjs +1 -1
- package/dist/elements/structure/List/declaration.mjs +1 -1
- package/dist/elements/structure/List/modes/ListControlled/ListControlled.d.ts +3 -1
- package/dist/elements/structure/List/modes/ListControlled/ListControlled.mjs +18 -17
- package/dist/index.d.ts +6 -2
- package/package.json +36 -8
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { AnimationFrameOptions, Frame } from './useAnimationFrame';
|
|
2
|
+
/** The canvas as it is laid out, in CSS pixels, and how many device pixels each of those holds. */
|
|
3
|
+
export interface CanvasSize {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
pixelRatio: number;
|
|
7
|
+
}
|
|
8
|
+
export interface CanvasOptions<C, S> extends Omit<AnimationFrameOptions, 'target'> {
|
|
9
|
+
/**
|
|
10
|
+
* Once per context — and again after a lost WebGL context comes back: buffers, programs, gradients. What it returns
|
|
11
|
+
* is handed to every `draw`. A `ShaderError` (see `createShaderProgram`) or anything else it throws is printed with
|
|
12
|
+
* the element it belongs to, and nothing is drawn.
|
|
13
|
+
*/
|
|
14
|
+
setup?: (context: C, size: CanvasSize) => S;
|
|
15
|
+
/** One frame, in CSS pixels: a 2D context is already scaled to the device's pixels, a WebGL viewport set to them. */
|
|
16
|
+
draw: (context: C, frame: Frame & CanvasSize & {
|
|
17
|
+
state: S;
|
|
18
|
+
}) => void;
|
|
19
|
+
/** The most device pixels per CSS pixel drawn — a phone at 3 draws nine times a 1× screen's work for little to see. */
|
|
20
|
+
maxPixelRatio?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface CanvasHandle {
|
|
23
|
+
/** For the `<canvas>`: `<canvas ref={ref} />`, inside the plugin's `RootElement`. */
|
|
24
|
+
ref: (canvas: HTMLCanvasElement | null) => void;
|
|
25
|
+
/** Whether a frame was drawn — until then, what the server rendered (a still image) is what to show. */
|
|
26
|
+
ready: boolean;
|
|
27
|
+
/** What failed — setup, a draw, a shader — when something did; the loop is stopped. */
|
|
28
|
+
error: string | undefined;
|
|
29
|
+
/** Whether it is animating, or holding the one still frame it drew. */
|
|
30
|
+
running: boolean;
|
|
31
|
+
}
|
|
32
|
+
type Canvas2dOptions<S> = CanvasOptions<CanvasRenderingContext2D, S> & {
|
|
33
|
+
attributes?: CanvasRenderingContext2DSettings;
|
|
34
|
+
};
|
|
35
|
+
type WebGLOptions<C, S> = CanvasOptions<C, S> & {
|
|
36
|
+
attributes?: WebGLContextAttributes;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A 2D canvas that animates: `draw(ctx, { time, width, height })` in CSS pixels, every frame it should.
|
|
40
|
+
*
|
|
41
|
+
* ```tsx
|
|
42
|
+
* const { ref } = useCanvas2d({ draw: (ctx, { time, width, height }) => { ctx.clearRect(0, 0, width, height); … } });
|
|
43
|
+
* return <RootElement className={className}><canvas ref={ref} /></RootElement>;
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare const useCanvas2d: <S = undefined>({ attributes, ...options }: Canvas2dOptions<S>) => CanvasHandle;
|
|
47
|
+
/** A WebGL (1) canvas that animates; `setup` compiles with `createShaderProgram`, which says why a shader failed. */
|
|
48
|
+
export declare const useWebGL: <S = undefined>({ attributes, ...options }: WebGLOptions<WebGLRenderingContext, S>) => CanvasHandle;
|
|
49
|
+
/** The same over WebGL 2 — GLSL ES 3.00, where the browser has it; `error` says so where it does not. */
|
|
50
|
+
export declare const useWebGL2: <S = undefined>({ attributes, ...options }: WebGLOptions<WebGL2RenderingContext, S>) => CanvasHandle;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import e from "../Element/ElementContext.mjs";
|
|
2
|
+
import t from "./useAnimationFrame.mjs";
|
|
3
|
+
import { use as n, useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
|
|
4
|
+
//#region src/canvas/useCanvas.ts
|
|
5
|
+
var s = (e) => `[plugin ${e?.definition?.type ?? "canvas"}${e?.id ? ` "${e.id}"` : ""}]`, c = (c, { setup: l, draw: u, maxPixelRatio: d = 2, paused: f, fps: p }) => {
|
|
6
|
+
let m = s(n(e)), h = a(null), [g, _] = o(null), [v, y] = o({
|
|
7
|
+
width: 0,
|
|
8
|
+
height: 0,
|
|
9
|
+
pixelRatio: 1
|
|
10
|
+
}), [b, x] = o(), [S, C] = o(!1), [w, T] = o(0), E = a(null), D = a({
|
|
11
|
+
acquire: c,
|
|
12
|
+
setup: l,
|
|
13
|
+
draw: u
|
|
14
|
+
});
|
|
15
|
+
i(() => {
|
|
16
|
+
D.current = {
|
|
17
|
+
acquire: c,
|
|
18
|
+
setup: l,
|
|
19
|
+
draw: u
|
|
20
|
+
};
|
|
21
|
+
}, [
|
|
22
|
+
c,
|
|
23
|
+
l,
|
|
24
|
+
u
|
|
25
|
+
]);
|
|
26
|
+
let O = r((e) => {
|
|
27
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
28
|
+
console.error(`${m} ${t}`), x(t);
|
|
29
|
+
}, [m]), k = r((e) => {
|
|
30
|
+
h.current = e, _(e);
|
|
31
|
+
}, []);
|
|
32
|
+
i(() => {
|
|
33
|
+
if (!g) return;
|
|
34
|
+
let e = () => {
|
|
35
|
+
let e = g.getBoundingClientRect(), t = Math.min(window.devicePixelRatio || 1, d);
|
|
36
|
+
g.width = Math.max(1, Math.round(e.width * t)), g.height = Math.max(1, Math.round(e.height * t)), y({
|
|
37
|
+
width: e.width,
|
|
38
|
+
height: e.height,
|
|
39
|
+
pixelRatio: t
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
if (e(), typeof ResizeObserver > "u") return;
|
|
43
|
+
let t = new ResizeObserver(e);
|
|
44
|
+
return t.observe(g), () => t.disconnect();
|
|
45
|
+
}, [g, d]), i(() => {
|
|
46
|
+
if (!g) return;
|
|
47
|
+
let e = (e) => {
|
|
48
|
+
e.preventDefault(), E.current = null, C(!1);
|
|
49
|
+
}, t = () => T((e) => e + 1);
|
|
50
|
+
return g.addEventListener("webglcontextlost", e), g.addEventListener("webglcontextrestored", t), () => {
|
|
51
|
+
g.removeEventListener("webglcontextlost", e), g.removeEventListener("webglcontextrestored", t);
|
|
52
|
+
};
|
|
53
|
+
}, [g]), i(() => {
|
|
54
|
+
if (g && v.width !== 0 && b === void 0) try {
|
|
55
|
+
let e = D.current.acquire(g);
|
|
56
|
+
if (!e) {
|
|
57
|
+
O(/* @__PURE__ */ Error("the browser gave no drawing context (WebGL may be off)"));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
e.prepare(v);
|
|
61
|
+
let t = D.current.setup ? D.current.setup(e.context, v) : void 0;
|
|
62
|
+
E.current = {
|
|
63
|
+
handle: e,
|
|
64
|
+
state: t
|
|
65
|
+
};
|
|
66
|
+
} catch (e) {
|
|
67
|
+
O(e);
|
|
68
|
+
}
|
|
69
|
+
}, [
|
|
70
|
+
g,
|
|
71
|
+
v,
|
|
72
|
+
w,
|
|
73
|
+
b,
|
|
74
|
+
O
|
|
75
|
+
]);
|
|
76
|
+
let A = r((e) => {
|
|
77
|
+
let t = E.current;
|
|
78
|
+
if (t && b === void 0) try {
|
|
79
|
+
t.handle.prepare(v), D.current.draw(t.handle.context, {
|
|
80
|
+
...e,
|
|
81
|
+
...v,
|
|
82
|
+
state: t.state
|
|
83
|
+
}), C(!0);
|
|
84
|
+
} catch (e) {
|
|
85
|
+
E.current = null, O(e);
|
|
86
|
+
}
|
|
87
|
+
}, [
|
|
88
|
+
v,
|
|
89
|
+
b,
|
|
90
|
+
O
|
|
91
|
+
]), { running: j } = t(A, {
|
|
92
|
+
paused: f || b !== void 0,
|
|
93
|
+
fps: p,
|
|
94
|
+
target: h
|
|
95
|
+
});
|
|
96
|
+
return i(() => {
|
|
97
|
+
!j && v.width > 0 && A({
|
|
98
|
+
time: 0,
|
|
99
|
+
delta: 0,
|
|
100
|
+
frame: 0
|
|
101
|
+
});
|
|
102
|
+
}, [
|
|
103
|
+
j,
|
|
104
|
+
v,
|
|
105
|
+
w,
|
|
106
|
+
A
|
|
107
|
+
]), {
|
|
108
|
+
ref: k,
|
|
109
|
+
ready: S,
|
|
110
|
+
error: b,
|
|
111
|
+
running: j
|
|
112
|
+
};
|
|
113
|
+
}, l = ({ attributes: e, ...t }) => c(r((t) => {
|
|
114
|
+
let n = t.getContext("2d", e);
|
|
115
|
+
return n && {
|
|
116
|
+
context: n,
|
|
117
|
+
prepare: ({ pixelRatio: e }) => n.setTransform(e, 0, 0, e, 0, 0)
|
|
118
|
+
};
|
|
119
|
+
}, [e]), t), u = ({ attributes: e, ...t }) => c(r((t) => {
|
|
120
|
+
let n = t.getContext("webgl", e);
|
|
121
|
+
return n && {
|
|
122
|
+
context: n,
|
|
123
|
+
prepare: () => n.viewport(0, 0, t.width, t.height)
|
|
124
|
+
};
|
|
125
|
+
}, [e]), t), d = ({ attributes: e, ...t }) => c(r((t) => {
|
|
126
|
+
let n = t.getContext("webgl2", e);
|
|
127
|
+
return n && {
|
|
128
|
+
context: n,
|
|
129
|
+
prepare: () => n.viewport(0, 0, t.width, t.height)
|
|
130
|
+
};
|
|
131
|
+
}, [e]), t);
|
|
132
|
+
//#endregion
|
|
133
|
+
export { l as useCanvas2d, u as useWebGL, d as useWebGL2 };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the visitor asked for less motion: their system's setting, or the QA tab's switch. What the CSS of a space
|
|
3
|
+
* already honours, for the motion a plugin draws itself. False on the server, which draws no motion either way.
|
|
4
|
+
*/
|
|
5
|
+
declare const useReducedMotion: () => boolean;
|
|
6
|
+
export default useReducedMotion;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useSyncExternalStore as e } from "react";
|
|
2
|
+
//#region src/canvas/useReducedMotion.ts
|
|
3
|
+
var t = "(prefers-reduced-motion: reduce)", n = "plitzi-reduced-motion", r = () => typeof window.matchMedia == "function" && window.matchMedia(t).matches || document.documentElement.classList.contains(n), i = (e) => {
|
|
4
|
+
let n = typeof window.matchMedia == "function" ? window.matchMedia(t) : void 0;
|
|
5
|
+
n?.addEventListener("change", e);
|
|
6
|
+
let r = new MutationObserver(e);
|
|
7
|
+
return r.observe(document.documentElement, {
|
|
8
|
+
attributes: !0,
|
|
9
|
+
attributeFilter: ["class"]
|
|
10
|
+
}), () => {
|
|
11
|
+
n?.removeEventListener("change", e), r.disconnect();
|
|
12
|
+
};
|
|
13
|
+
}, a = () => e(i, r, () => !1);
|
|
14
|
+
//#endregion
|
|
15
|
+
export { a as default };
|
|
@@ -24,6 +24,11 @@ export type ButtonProps = {
|
|
|
24
24
|
ariaExpanded?: boolean;
|
|
25
25
|
/** For a button that stays on or off — a filter, a mode: `true` while it is on. Left out, it is a plain button. */
|
|
26
26
|
ariaPressed?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* What the button shows and hides — an accordion's panel, a menu — by its anchor (`aria-controls`), so a screen
|
|
29
|
+
* reader can go from one to the other. Authoring takes the element's id and gives that element the anchor.
|
|
30
|
+
*/
|
|
31
|
+
controls?: string;
|
|
27
32
|
/**
|
|
28
33
|
* What the button does, in words — shown as a tooltip on hover, and the button's accessible name when it has no text
|
|
29
34
|
* of its own. An icon-only button without one is announced as nothing at all.
|
|
@@ -40,7 +45,7 @@ export type ButtonProps = {
|
|
|
40
45
|
*/
|
|
41
46
|
label?: string;
|
|
42
47
|
};
|
|
43
|
-
declare const Button: ({ ref, className, children, contentPlacement, content, icon, iconPlacement, subType, disabled, ariaExpanded, ariaPressed, title, label }: ButtonProps) => import('react').JSX.Element;
|
|
48
|
+
declare const Button: ({ ref, className, children, contentPlacement, content, icon, iconPlacement, subType, disabled, ariaExpanded, ariaPressed, controls, title, label }: ButtonProps) => import('react').JSX.Element;
|
|
44
49
|
declare const _default: {
|
|
45
50
|
(props: import('../../../Element/hocs/withElement').WithElementProps<ButtonProps>): import('react').JSX.Element;
|
|
46
51
|
displayName: string;
|
|
@@ -6,31 +6,32 @@ import i from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
|
|
|
6
6
|
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
7
|
import s from "clsx";
|
|
8
8
|
//#region src/elements/basic/Button/Button.tsx
|
|
9
|
-
var c = ({ ref: e, className: c = "", children: l, contentPlacement: u = "after", content: d = "Button", icon: f = "", iconPlacement: p = "before", subType: m = "button", disabled: h = !1, ariaExpanded: g, ariaPressed: _,
|
|
10
|
-
let { settings: { previewMode:
|
|
9
|
+
var c = ({ ref: e, className: c = "", children: l, contentPlacement: u = "after", content: d = "Button", icon: f = "", iconPlacement: p = "before", subType: m = "button", disabled: h = !1, ariaExpanded: g, ariaPressed: _, controls: v, title: y, label: b }) => {
|
|
10
|
+
let { settings: { previewMode: x } } = i(), { definition: { styleSelectors: S } } = t();
|
|
11
11
|
return /* @__PURE__ */ o(n, {
|
|
12
12
|
ref: e,
|
|
13
13
|
tag: "button",
|
|
14
|
-
type:
|
|
15
|
-
className: s("plitzi-component__button", c, { "container--empty--skip": !
|
|
14
|
+
type: x ? m : "button",
|
|
15
|
+
className: s("plitzi-component__button", c, { "container--empty--skip": !x && !l && (d || f) }),
|
|
16
16
|
disabled: h,
|
|
17
|
-
title:
|
|
18
|
-
"aria-label":
|
|
17
|
+
title: y || void 0,
|
|
18
|
+
"aria-label": b || void 0,
|
|
19
19
|
"aria-expanded": g,
|
|
20
20
|
"aria-pressed": _,
|
|
21
|
+
"aria-controls": v || void 0,
|
|
21
22
|
children: [
|
|
22
23
|
u === "before" && /* @__PURE__ */ a(r, {
|
|
23
24
|
content: d,
|
|
24
25
|
icon: f,
|
|
25
26
|
iconPlacement: p,
|
|
26
|
-
iconClassName:
|
|
27
|
+
iconClassName: S.icon
|
|
27
28
|
}),
|
|
28
29
|
l,
|
|
29
30
|
u === "after" && /* @__PURE__ */ a(r, {
|
|
30
31
|
content: d,
|
|
31
32
|
icon: f,
|
|
32
33
|
iconPlacement: p,
|
|
33
|
-
iconClassName:
|
|
34
|
+
iconClassName: S.icon
|
|
34
35
|
})
|
|
35
36
|
]
|
|
36
37
|
});
|
|
@@ -131,6 +131,7 @@ declare const declaration: {
|
|
|
131
131
|
title?: string | undefined;
|
|
132
132
|
content?: string | undefined;
|
|
133
133
|
disabled?: boolean | undefined;
|
|
134
|
+
controls?: string | undefined;
|
|
134
135
|
icon?: string | undefined;
|
|
135
136
|
subType?: "button" | "submit" | "reset" | undefined;
|
|
136
137
|
iconPlacement?: import('../../../Element/ElementWords').IconPlacement | undefined;
|
|
@@ -130,6 +130,7 @@ declare const Button: {
|
|
|
130
130
|
title?: string | undefined;
|
|
131
131
|
content?: string | undefined;
|
|
132
132
|
disabled?: boolean | undefined;
|
|
133
|
+
controls?: string | undefined;
|
|
133
134
|
icon?: string | undefined;
|
|
134
135
|
subType?: "button" | "submit" | "reset" | undefined;
|
|
135
136
|
iconPlacement?: import('../../../Element/ElementWords').IconPlacement | undefined;
|
|
@@ -424,6 +424,7 @@ export declare const elementDeclarations: {
|
|
|
424
424
|
title?: string | undefined;
|
|
425
425
|
content?: string | undefined;
|
|
426
426
|
disabled?: boolean | undefined;
|
|
427
|
+
controls?: string | undefined;
|
|
427
428
|
icon?: string | undefined;
|
|
428
429
|
subType?: "button" | "submit" | "reset" | undefined;
|
|
429
430
|
iconPlacement?: import('../../Element/ElementWords').IconPlacement | undefined;
|
|
@@ -742,6 +743,7 @@ export declare const elementDeclarations: {
|
|
|
742
743
|
readonly type: "container";
|
|
743
744
|
readonly attributeValues: {
|
|
744
745
|
readonly subType: readonly string[];
|
|
746
|
+
readonly live: readonly string[];
|
|
745
747
|
};
|
|
746
748
|
readonly content: {
|
|
747
749
|
readonly attributes: {
|
|
@@ -792,7 +794,8 @@ export declare const elementDeclarations: {
|
|
|
792
794
|
};
|
|
793
795
|
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
|
|
794
796
|
label?: string | undefined;
|
|
795
|
-
subType?: "div" | "header" | "footer" | "nav" | "main" | "section" | "article" | "aside" | "address" | "figure" | "dl" | "dt" | "dd" | "li" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "span" | undefined;
|
|
797
|
+
subType?: "div" | "header" | "footer" | "nav" | "main" | "section" | "article" | "aside" | "address" | "figure" | "dl" | "dt" | "dd" | "li" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | undefined;
|
|
798
|
+
live?: "polite" | "assertive" | "" | undefined;
|
|
796
799
|
decorative?: boolean | undefined;
|
|
797
800
|
}>>;
|
|
798
801
|
readonly Custom: {
|
|
@@ -2135,7 +2138,7 @@ export declare const elementDeclarations: {
|
|
|
2135
2138
|
};
|
|
2136
2139
|
readonly content: {
|
|
2137
2140
|
readonly attributes: {
|
|
2138
|
-
readonly src: "
|
|
2141
|
+
readonly src: "";
|
|
2139
2142
|
readonly alt: "";
|
|
2140
2143
|
readonly decorative: false;
|
|
2141
2144
|
readonly fetchPriority: "auto";
|
|
@@ -2187,6 +2190,7 @@ export declare const elementDeclarations: {
|
|
|
2187
2190
|
readonly settings: {};
|
|
2188
2191
|
};
|
|
2189
2192
|
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
|
|
2193
|
+
resize?: boolean | undefined;
|
|
2190
2194
|
height?: number | undefined;
|
|
2191
2195
|
width?: number | undefined;
|
|
2192
2196
|
fetchPriority?: "high" | "low" | "auto" | undefined;
|
|
@@ -2,7 +2,11 @@ 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'
|
|
5
|
+
subType: 'text' | 'number' | 'email' | 'password'
|
|
6
|
+
/** A search box: the browser draws its clear button, and a phone shows its search key. */
|
|
7
|
+
| 'search' | 'url'
|
|
8
|
+
/** A phone number: a phone shows its dial pad. */
|
|
9
|
+
| 'tel' | 'date' | 'time' | 'checkbox' | 'switch' | 'select' | 'textarea' | 'hidden'
|
|
6
10
|
/** The browser's own colour picker: its value is `#rrggbb`. */
|
|
7
11
|
| 'color';
|
|
8
12
|
name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type SettingsProps = {
|
|
2
|
-
subType?: 'text' | 'number' | 'date' | 'time' | 'email' | 'password' | 'select' | 'checkbox' | 'textarea' | 'hidden' | 'color' | 'switch';
|
|
2
|
+
subType?: 'text' | 'number' | 'date' | 'time' | 'email' | 'password' | 'search' | 'url' | 'tel' | 'select' | 'checkbox' | 'textarea' | 'hidden' | 'color' | 'switch';
|
|
3
3
|
name?: string;
|
|
4
4
|
label?: string;
|
|
5
5
|
hideLabel?: boolean;
|
|
@@ -15,7 +15,10 @@ var l = (e) => {
|
|
|
15
15
|
"textarea",
|
|
16
16
|
"number",
|
|
17
17
|
"email",
|
|
18
|
-
"password"
|
|
18
|
+
"password",
|
|
19
|
+
"search",
|
|
20
|
+
"url",
|
|
21
|
+
"tel"
|
|
19
22
|
].includes(u), F = t((e) => N?.("name", e), [N]), I = t((e) => N?.("label", e), [N]), L = t((e) => N?.("hideLabel", e.target.checked), [N]), ee = t((e) => N?.("placeholder", e), [N]), R = t((e) => {
|
|
20
23
|
N?.("subType", e), N?.("defaultValue", "");
|
|
21
24
|
}, [N]), z = t((e) => N?.("defaultValue", e), [N]), B = t((e) => N?.("autoFocus", e.target.checked), [N]), V = t((e) => N?.("autoComplete", e.target.checked), [N]), H = t((e) => N?.("required", e.target.checked), [N]), U = t((e) => N?.("requiredMessage", e), [N]), W = t((e) => N?.("minLength", l(e)), [N]), G = t((e) => N?.("minLengthMessage", e), [N]), K = t((e) => N?.("maxLength", l(e)), [N]), q = t((e) => N?.("maxLengthMessage", e), [N]), J = t((e) => N?.("formatMessage", e), [N]), Y = t((e) => N?.("pattern", e), [N]), X = t((e) => N?.("patternMessage", e), [N]), Z = t((e) => N?.("matches", e), [N]), Q = t((e) => N?.("matchesMessage", e), [N]), $ = t((e) => N?.("readOnly", e.target.checked), [N]), te = t((e) => N?.("disabled", e.target.checked), [N]), ne = t((e) => N?.("previewError", e.target.checked), [N]), re = t((e) => {
|
|
@@ -78,6 +81,18 @@ var l = (e) => {
|
|
|
78
81
|
value: "email",
|
|
79
82
|
children: "Email"
|
|
80
83
|
}),
|
|
84
|
+
/* @__PURE__ */ r("option", {
|
|
85
|
+
value: "search",
|
|
86
|
+
children: "Search"
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ r("option", {
|
|
89
|
+
value: "url",
|
|
90
|
+
children: "URL"
|
|
91
|
+
}),
|
|
92
|
+
/* @__PURE__ */ r("option", {
|
|
93
|
+
value: "tel",
|
|
94
|
+
children: "Phone"
|
|
95
|
+
}),
|
|
81
96
|
/* @__PURE__ */ r("option", {
|
|
82
97
|
value: "password",
|
|
83
98
|
children: "Password"
|
|
@@ -27,8 +27,14 @@ export type ImageProps = {
|
|
|
27
27
|
* so nothing jumps. */
|
|
28
28
|
width?: number;
|
|
29
29
|
height?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the page server may make sizes of the picture, when it does (`images` in its configuration). `false` keeps
|
|
32
|
+
* this one as it is — a picture already sized for where it sits, or one its host must serve itself. A vector (SVG) is
|
|
33
|
+
* never resized.
|
|
34
|
+
*/
|
|
35
|
+
resize?: boolean;
|
|
30
36
|
};
|
|
31
|
-
declare const Image: ({ ref, className, src: srcProp, alt: altProp, decorative, fetchPriority, loadMode, sizes, width, height }: ImageProps) => import('react').JSX.Element;
|
|
37
|
+
declare const Image: ({ ref, className, src: srcProp, alt: altProp, decorative, fetchPriority, loadMode, sizes, width, height, resize }: ImageProps) => import('react').JSX.Element;
|
|
32
38
|
declare const _default: {
|
|
33
39
|
(props: import('../../../Element/hocs/withElement').WithElementProps<ImageProps>): import('react').JSX.Element;
|
|
34
40
|
displayName: string;
|
|
@@ -6,16 +6,16 @@ import a from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
|
|
|
6
6
|
import { useCommonStore as o } from "@plitzi/sdk-shared/store";
|
|
7
7
|
import { jsx as s } from "react/jsx-runtime";
|
|
8
8
|
import c from "clsx";
|
|
9
|
-
import { imageSrcSet as l, imageUrl as u,
|
|
9
|
+
import { imageSrcSet as l, imageUrl as u, isResizableImage as d } from "@plitzi/sdk-shared/helpers/images";
|
|
10
10
|
//#region src/elements/media/Image/Image.tsx
|
|
11
|
-
var f = 1280, p = n(), m =
|
|
12
|
-
let { settings: { previewMode: C } } = a(), w =
|
|
11
|
+
var f = 1280, p = n(), m = ({ ref: e, className: n = "", src: m, alt: h = "", decorative: g = !1, fetchPriority: _ = "auto", loadMode: v, sizes: y = "100vw", width: b, height: x, resize: S = !0 }) => {
|
|
12
|
+
let { settings: { previewMode: C } } = a(), w = m || p, T = g ? "" : h, [E, D] = i(void 0), O = E === w, k = r(() => D(w), [w]), A = O ? p : w, j = O ? { "data-plitzi-failed": w } : {}, M = v === "auto" ? void 0 : v, [N] = o("images.endpoint"), P = C && N && S && !O && d(w) ? {
|
|
13
13
|
src: u(N, w, f),
|
|
14
14
|
srcSet: l(N, w),
|
|
15
|
-
sizes:
|
|
15
|
+
sizes: y
|
|
16
16
|
} : { src: A }, F = {
|
|
17
|
-
...
|
|
18
|
-
...
|
|
17
|
+
...b ? { width: b } : {},
|
|
18
|
+
...x ? { height: x } : {}
|
|
19
19
|
};
|
|
20
20
|
return C ? /* @__PURE__ */ s(t, {
|
|
21
21
|
tag: "img",
|
|
@@ -26,7 +26,7 @@ var f = 1280, p = n(), m = "https://cdn.plitzi.com/resources/img/placeholder-img
|
|
|
26
26
|
...F,
|
|
27
27
|
alt: T,
|
|
28
28
|
loading: M,
|
|
29
|
-
fetchPriority:
|
|
29
|
+
fetchPriority: _,
|
|
30
30
|
onError: O ? void 0 : k,
|
|
31
31
|
...j
|
|
32
32
|
}) : /* @__PURE__ */ s(t, {
|
|
@@ -37,11 +37,11 @@ var f = 1280, p = n(), m = "https://cdn.plitzi.com/resources/img/placeholder-img
|
|
|
37
37
|
src: A,
|
|
38
38
|
alt: T,
|
|
39
39
|
loading: M,
|
|
40
|
-
fetchPriority:
|
|
40
|
+
fetchPriority: _,
|
|
41
41
|
onError: O ? void 0 : k,
|
|
42
42
|
...j
|
|
43
43
|
})
|
|
44
44
|
});
|
|
45
|
-
},
|
|
45
|
+
}, h = e(m);
|
|
46
46
|
//#endregion
|
|
47
|
-
export {
|
|
47
|
+
export { m as Image, h as default };
|
|
@@ -10,7 +10,7 @@ declare const declaration: {
|
|
|
10
10
|
};
|
|
11
11
|
readonly content: {
|
|
12
12
|
readonly attributes: {
|
|
13
|
-
readonly src: "
|
|
13
|
+
readonly src: "";
|
|
14
14
|
readonly alt: "";
|
|
15
15
|
readonly decorative: false;
|
|
16
16
|
readonly fetchPriority: "auto";
|
|
@@ -62,6 +62,7 @@ declare const declaration: {
|
|
|
62
62
|
readonly settings: {};
|
|
63
63
|
};
|
|
64
64
|
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
|
|
65
|
+
resize?: boolean | undefined;
|
|
65
66
|
height?: number | undefined;
|
|
66
67
|
width?: number | undefined;
|
|
67
68
|
fetchPriority?: "high" | "low" | "auto" | undefined;
|
|
@@ -9,7 +9,7 @@ declare const Image: {
|
|
|
9
9
|
};
|
|
10
10
|
readonly content: {
|
|
11
11
|
readonly attributes: {
|
|
12
|
-
readonly src: "
|
|
12
|
+
readonly src: "";
|
|
13
13
|
readonly alt: "";
|
|
14
14
|
readonly decorative: false;
|
|
15
15
|
readonly fetchPriority: "auto";
|
|
@@ -61,6 +61,7 @@ declare const Image: {
|
|
|
61
61
|
readonly settings: {};
|
|
62
62
|
};
|
|
63
63
|
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
|
|
64
|
+
resize?: boolean | undefined;
|
|
64
65
|
height?: number | undefined;
|
|
65
66
|
width?: number | undefined;
|
|
66
67
|
fetchPriority?: "high" | "low" | "auto" | undefined;
|
|
@@ -75,7 +75,7 @@ export type ApiContainerProps = {
|
|
|
75
75
|
*/
|
|
76
76
|
refreshSeconds?: number | string;
|
|
77
77
|
};
|
|
78
|
-
declare const ApiContainer: ({ ref, className, children, query, method, accessToken, when, headers, mockData, subType, credentials, singleRecord, pagination, pageParam, renderWhileLoading, loadingSlot, cache, staleTime, gcTime, refreshSeconds }: ApiContainerProps) => import('react').JSX.Element;
|
|
78
|
+
declare const ApiContainer: ({ ref, className, children, query, method, accessToken, when, headers, mockData, subType, credentials, singleRecord, pagination, pageParam, renderWhileLoading, loadingSlot, cache, staleTime, gcTime, refreshSeconds, connector, action }: ApiContainerProps) => import('react').JSX.Element;
|
|
79
79
|
declare const _default: {
|
|
80
80
|
(props: import('../../../Element/hocs/withElement').WithElementProps<ApiContainerProps>): import('react').JSX.Element;
|
|
81
81
|
displayName: string;
|