@almadar/ui 6.52.0 → 6.53.1
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/dist/{EntityBindingContext-BbxrwSb9.d.ts → AwaitingSkeletonContext-Bh399p1x.d.ts} +17 -2
- package/dist/{Canvas3DHost-CWO0tswb.d.ts → Canvas3DHost-B-y2TNij.d.ts} +1 -1
- package/dist/{GameAudioProvider-_hPzjqp-.d.ts → GameAudioProvider-DyBvYP2c.d.ts} +1 -1
- package/dist/Typography-7QEWUTW3.js +5 -0
- package/dist/{UISlotRenderer-CR7SCAMR.js → UISlotRenderer-P7A4SZSK.js} +10 -10
- package/dist/avl/index.cjs +40157 -39958
- package/dist/avl/index.d.ts +5 -2
- package/dist/avl/index.js +34 -21
- package/dist/{chunk-XUSSAWKL.js → chunk-2LFBQ4IS.js} +1 -1
- package/dist/{chunk-QWDKMVLX.js → chunk-53VTY5CC.js} +141 -82
- package/dist/{chunk-MSBMVG3B.js → chunk-6O37FCX4.js} +1 -0
- package/dist/{chunk-WB2A6V3I.js → chunk-7KSLPY56.js} +49 -1
- package/dist/{chunk-BHZG4PDZ.js → chunk-7LM6I3NA.js} +629 -626
- package/dist/{chunk-NCNP2RKZ.js → chunk-E37BYSXY.js} +2 -2
- package/dist/{chunk-5GCI6C7J.js → chunk-FUQASYEW.js} +2 -2
- package/dist/{chunk-CLSLVFSP.js → chunk-HB4C27KU.js} +2 -2
- package/dist/{chunk-EERAGPBW.js → chunk-HUG25TT3.js} +32341 -33067
- package/dist/{chunk-TWHYH25Q.js → chunk-JRW33U35.js} +80 -80
- package/dist/{chunk-G4GMXYMY.js → chunk-KQXXO42S.js} +93 -171
- package/dist/chunk-OKWD7LPO.js +80 -0
- package/dist/{chunk-YHY5K2Y7.js → chunk-PEST66PN.js} +6 -0
- package/dist/{chunk-V5AGW2JN.js → chunk-QVXLKFUQ.js} +1 -1
- package/dist/chunk-UOTYAPV5.js +284 -0
- package/dist/{chunk-2QB2PXOO.js → chunk-VHTJRS2N.js} +3 -5
- package/dist/components/index.cjs +42813 -42691
- package/dist/components/index.d.ts +182 -319
- package/dist/components/index.js +621 -13
- package/dist/context/index.cjs +8 -3
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.cjs +56 -4
- package/dist/hooks/index.js +7 -7
- package/dist/lib/drawable/three/index.cjs +49 -1
- package/dist/lib/drawable/three/index.d.ts +5 -5
- package/dist/lib/drawable/three/index.js +7 -7
- package/dist/lib/index.cjs +50 -1
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.js +6 -5
- package/dist/locales/index.cjs +147 -3
- package/dist/locales/index.js +99 -3
- package/dist/{paintDispatch-DHo3WhaU.d.ts → paintDispatch-_6EhJCiL.d.ts} +3 -3
- package/dist/providers/index.cjs +35850 -35687
- package/dist/providers/index.d.ts +33 -8
- package/dist/providers/index.js +37 -13
- package/dist/renderer/index.cjs +6 -0
- package/dist/renderer/index.d.ts +1 -1
- package/dist/renderer/index.js +1 -1
- package/dist/runtime/index.cjs +42533 -42343
- package/dist/runtime/index.d.ts +4 -2
- package/dist/runtime/index.js +12 -12
- package/dist/ssr/index.cjs +377 -137
- package/dist/ssr/index.d.cts +5 -1
- package/dist/ssr/index.d.ts +5 -1
- package/dist/ssr/index.js +313 -73
- package/dist/{verificationRegistry-BYD3cVhS.d.ts → verificationRegistry-CD7Xb40L.d.ts} +1 -1
- package/locales/ar.json +49 -1
- package/locales/en.json +49 -1
- package/locales/sl.json +49 -1
- package/package.json +6 -6
- package/tailwind-preset.cjs +23 -0
- package/themes/_base.css +28 -8
- package/themes/_contract.md +5 -0
- package/dist/Typography-7FRZOS2H.js +0 -5
- package/dist/{avl-3d-context-DLteNEwu.d.ts → avl-3d-context-MAt_NuU9.d.ts} +3 -3
- package/dist/{chunk-IN3BVW2Z.js → chunk-64WACXM7.js} +14 -14
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { Icon, Button, Switch, Input } from './chunk-HUG25TT3.js';
|
|
2
|
+
import { VStack, HStack } from './chunk-7LM6I3NA.js';
|
|
3
|
+
import { Typography } from './chunk-HB4C27KU.js';
|
|
4
|
+
import { cn } from './chunk-64WACXM7.js';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { useTranslate } from '@almadar/ui/hooks';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
10
|
+
var isArr = (v) => Array.isArray(v);
|
|
11
|
+
function kindOf(v) {
|
|
12
|
+
if (v === null) return "null";
|
|
13
|
+
if (isArr(v)) return "array";
|
|
14
|
+
if (isObj(v)) return "object";
|
|
15
|
+
if (typeof v === "number") return "number";
|
|
16
|
+
if (typeof v === "boolean") return "boolean";
|
|
17
|
+
return "string";
|
|
18
|
+
}
|
|
19
|
+
var TYPE_LABEL_KEY = {
|
|
20
|
+
string: "jsonTree.type.text",
|
|
21
|
+
number: "jsonTree.type.number",
|
|
22
|
+
boolean: "jsonTree.type.boolean"
|
|
23
|
+
};
|
|
24
|
+
var TYPE_LABEL_SYMBOL = {
|
|
25
|
+
object: "{}",
|
|
26
|
+
array: "[]",
|
|
27
|
+
null: "\u2014"
|
|
28
|
+
};
|
|
29
|
+
function typeLabel(kind, t) {
|
|
30
|
+
if (kind === "object" || kind === "array" || kind === "null") return TYPE_LABEL_SYMBOL[kind];
|
|
31
|
+
return t(TYPE_LABEL_KEY[kind] ?? "");
|
|
32
|
+
}
|
|
33
|
+
var KIND_OPTIONS = ["string", "number", "boolean", "object", "array"];
|
|
34
|
+
function emptyOf(kind) {
|
|
35
|
+
switch (kind) {
|
|
36
|
+
case "object":
|
|
37
|
+
return {};
|
|
38
|
+
case "array":
|
|
39
|
+
return [];
|
|
40
|
+
case "number":
|
|
41
|
+
return 0;
|
|
42
|
+
case "boolean":
|
|
43
|
+
return false;
|
|
44
|
+
case "null":
|
|
45
|
+
return null;
|
|
46
|
+
default:
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function templateFrom(arr) {
|
|
51
|
+
if (arr.length === 0) return "";
|
|
52
|
+
const first = arr[0];
|
|
53
|
+
if (isObj(first)) {
|
|
54
|
+
const blank = {};
|
|
55
|
+
for (const k of Object.keys(first)) blank[k] = isObj(first[k]) ? {} : isArr(first[k]) ? [] : first[k];
|
|
56
|
+
return blank;
|
|
57
|
+
}
|
|
58
|
+
if (isArr(first)) return [];
|
|
59
|
+
return emptyOf(kindOf(first));
|
|
60
|
+
}
|
|
61
|
+
function ScalarControl({
|
|
62
|
+
value,
|
|
63
|
+
onChange
|
|
64
|
+
}) {
|
|
65
|
+
if (typeof value === "boolean") {
|
|
66
|
+
return /* @__PURE__ */ jsx(Switch, { checked: value, onChange: (c) => onChange(c) });
|
|
67
|
+
}
|
|
68
|
+
const numeric = typeof value === "number";
|
|
69
|
+
const initial = value === null ? "" : String(value);
|
|
70
|
+
const [draft, setDraft] = React.useState(initial);
|
|
71
|
+
React.useEffect(() => setDraft(initial), [initial]);
|
|
72
|
+
const commit = () => {
|
|
73
|
+
if (numeric) {
|
|
74
|
+
const n = draft.trim() === "" ? 0 : Number(draft);
|
|
75
|
+
onChange(Number.isNaN(n) ? 0 : n);
|
|
76
|
+
} else {
|
|
77
|
+
onChange(draft);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return /* @__PURE__ */ jsx(
|
|
81
|
+
Input,
|
|
82
|
+
{
|
|
83
|
+
inputType: numeric ? "number" : "text",
|
|
84
|
+
value: draft,
|
|
85
|
+
placeholder: value === null ? "null" : void 0,
|
|
86
|
+
onChange: (e) => setDraft(e.target.value),
|
|
87
|
+
onBlur: commit,
|
|
88
|
+
onKeyDown: (e) => {
|
|
89
|
+
if (e.key === "Enter") commit();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
function KindSelect({
|
|
95
|
+
kind,
|
|
96
|
+
onChange
|
|
97
|
+
}) {
|
|
98
|
+
const { t } = useTranslate();
|
|
99
|
+
return /* @__PURE__ */ jsx(
|
|
100
|
+
"select",
|
|
101
|
+
{
|
|
102
|
+
value: kind === "null" ? "string" : kind,
|
|
103
|
+
onChange: (e) => onChange(e.target.value),
|
|
104
|
+
"aria-label": t("jsonTree.valueType"),
|
|
105
|
+
className: cn(
|
|
106
|
+
"h-6 rounded-interactive bg-muted text-muted-foreground text-[10px] font-mono px-1",
|
|
107
|
+
"border-[length:var(--border-width-thin)] border-border",
|
|
108
|
+
"hover:bg-card focus:outline-none focus:ring-1 focus:ring-ring"
|
|
109
|
+
),
|
|
110
|
+
children: KIND_OPTIONS.map((k) => /* @__PURE__ */ jsx("option", { value: k, children: typeLabel(k, t) }, k))
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
function ValueNode({
|
|
115
|
+
value,
|
|
116
|
+
onChange,
|
|
117
|
+
depth,
|
|
118
|
+
readonly
|
|
119
|
+
}) {
|
|
120
|
+
const kind = kindOf(value);
|
|
121
|
+
if (kind === "object" || kind === "array") {
|
|
122
|
+
return /* @__PURE__ */ jsx(ContainerNode, { value, onChange, depth, readonly });
|
|
123
|
+
}
|
|
124
|
+
if (readonly) {
|
|
125
|
+
return /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "font-mono text-foreground", children: value === null ? "null" : String(value) });
|
|
126
|
+
}
|
|
127
|
+
return /* @__PURE__ */ jsx(ScalarControl, { value, onChange });
|
|
128
|
+
}
|
|
129
|
+
function Row({
|
|
130
|
+
rowKey,
|
|
131
|
+
isArrayItem,
|
|
132
|
+
value,
|
|
133
|
+
depth,
|
|
134
|
+
onValue,
|
|
135
|
+
onRenameKey,
|
|
136
|
+
onChangeKind,
|
|
137
|
+
onRemove,
|
|
138
|
+
readonly
|
|
139
|
+
}) {
|
|
140
|
+
const { t } = useTranslate();
|
|
141
|
+
const [keyDraft, setKeyDraft] = React.useState(rowKey);
|
|
142
|
+
React.useEffect(() => setKeyDraft(rowKey), [rowKey]);
|
|
143
|
+
const container = isObj(value) || isArr(value);
|
|
144
|
+
return /* @__PURE__ */ jsxs(VStack, { gap: "none", className: "group w-max min-w-full", children: [
|
|
145
|
+
/* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", className: "py-0.5 w-max", children: [
|
|
146
|
+
readonly ? /* @__PURE__ */ jsx("span", { className: cn(
|
|
147
|
+
"h-6 rounded-interactive bg-muted text-muted-foreground text-[10px] font-mono px-1 flex items-center",
|
|
148
|
+
"border-[length:var(--border-width-thin)] border-border"
|
|
149
|
+
), children: typeLabel(kindOf(value), t) }) : /* @__PURE__ */ jsx(KindSelect, { kind: kindOf(value), onChange: onChangeKind }),
|
|
150
|
+
isArrayItem ? /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "muted", className: "w-6 shrink-0 font-mono", children: rowKey }) : readonly ? /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "muted", className: "w-20 shrink-0 font-mono truncate", children: rowKey }) : /* @__PURE__ */ jsx("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ jsx(
|
|
151
|
+
Input,
|
|
152
|
+
{
|
|
153
|
+
inputType: "text",
|
|
154
|
+
value: keyDraft,
|
|
155
|
+
onChange: (e) => setKeyDraft(e.target.value),
|
|
156
|
+
onBlur: () => keyDraft !== rowKey && onRenameKey(keyDraft),
|
|
157
|
+
onKeyDown: (e) => {
|
|
158
|
+
if (e.key === "Enter" && keyDraft !== rowKey) onRenameKey(keyDraft);
|
|
159
|
+
},
|
|
160
|
+
className: "font-mono"
|
|
161
|
+
}
|
|
162
|
+
) }),
|
|
163
|
+
!container && /* @__PURE__ */ jsx("div", { className: "w-48 shrink-0", children: /* @__PURE__ */ jsx(ValueNode, { value, onChange: onValue, depth: depth + 1, readonly }) }),
|
|
164
|
+
!readonly && /* @__PURE__ */ jsx(
|
|
165
|
+
Button,
|
|
166
|
+
{
|
|
167
|
+
variant: "ghost",
|
|
168
|
+
size: "sm",
|
|
169
|
+
icon: "x",
|
|
170
|
+
onClick: onRemove,
|
|
171
|
+
"aria-label": t("common.remove"),
|
|
172
|
+
className: "shrink-0 text-muted-foreground hover:text-error"
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
] }),
|
|
176
|
+
container && /* @__PURE__ */ jsx("div", { className: "pl-2", children: /* @__PURE__ */ jsx(ValueNode, { value, onChange: onValue, depth: depth + 1, readonly }) })
|
|
177
|
+
] });
|
|
178
|
+
}
|
|
179
|
+
function ContainerNode({
|
|
180
|
+
value,
|
|
181
|
+
onChange,
|
|
182
|
+
depth,
|
|
183
|
+
readonly
|
|
184
|
+
}) {
|
|
185
|
+
const { t } = useTranslate();
|
|
186
|
+
const [open, setOpen] = React.useState(depth < 2);
|
|
187
|
+
const array = isArr(value);
|
|
188
|
+
const entries = array ? value.map((v, i) => [String(i), v]) : Object.entries(value);
|
|
189
|
+
const setObjValue = (key, next) => {
|
|
190
|
+
onChange({ ...value, [key]: next });
|
|
191
|
+
};
|
|
192
|
+
const renameKey = (oldKey, newKey) => {
|
|
193
|
+
if (!newKey || newKey === oldKey) return;
|
|
194
|
+
const out = {};
|
|
195
|
+
for (const [k, v] of Object.entries(value)) out[k === oldKey ? newKey : k] = v;
|
|
196
|
+
onChange(out);
|
|
197
|
+
};
|
|
198
|
+
const removeObjKey = (key) => {
|
|
199
|
+
const out = {};
|
|
200
|
+
for (const [k, v] of Object.entries(value)) if (k !== key) out[k] = v;
|
|
201
|
+
onChange(out);
|
|
202
|
+
};
|
|
203
|
+
const changeObjKind = (key, k) => setObjValue(key, emptyOf(k));
|
|
204
|
+
const setArrValue = (idx, next) => {
|
|
205
|
+
const copy = [...value];
|
|
206
|
+
copy[idx] = next;
|
|
207
|
+
onChange(copy);
|
|
208
|
+
};
|
|
209
|
+
const removeArrIdx = (idx) => onChange(value.filter((_, i) => i !== idx));
|
|
210
|
+
const changeArrKind = (idx, k) => setArrValue(idx, emptyOf(k));
|
|
211
|
+
const add = () => {
|
|
212
|
+
if (array) {
|
|
213
|
+
onChange([...value, templateFrom(value)]);
|
|
214
|
+
} else {
|
|
215
|
+
const obj = value;
|
|
216
|
+
let key = "key";
|
|
217
|
+
let n = 1;
|
|
218
|
+
while (key in obj) {
|
|
219
|
+
key = `key${n}`;
|
|
220
|
+
n += 1;
|
|
221
|
+
}
|
|
222
|
+
onChange({ ...obj, [key]: "" });
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const summaryKey = array ? entries.length === 1 ? "jsonTree.itemCountOne" : "jsonTree.itemCountOther" : entries.length === 1 ? "jsonTree.fieldCountOne" : "jsonTree.fieldCountOther";
|
|
226
|
+
const summary = t(summaryKey, { count: entries.length });
|
|
227
|
+
return /* @__PURE__ */ jsxs(VStack, { gap: "none", className: "w-full", children: [
|
|
228
|
+
/* @__PURE__ */ jsx(HStack, { gap: "xs", align: "center", children: /* @__PURE__ */ jsxs(
|
|
229
|
+
"button",
|
|
230
|
+
{
|
|
231
|
+
type: "button",
|
|
232
|
+
onClick: () => setOpen((o) => !o),
|
|
233
|
+
className: "flex items-center gap-1 text-muted-foreground hover:text-foreground",
|
|
234
|
+
"aria-label": open ? t("jsonTree.collapse") : t("jsonTree.expand"),
|
|
235
|
+
children: [
|
|
236
|
+
/* @__PURE__ */ jsx(Icon, { name: open ? "chevron-down" : "chevron-right", size: "sm" }),
|
|
237
|
+
/* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: array ? "[ ]" : "{ }" }),
|
|
238
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", color: "muted", children: summary })
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
) }),
|
|
242
|
+
open && /* @__PURE__ */ jsxs(
|
|
243
|
+
VStack,
|
|
244
|
+
{
|
|
245
|
+
gap: "none",
|
|
246
|
+
className: cn("ml-1.5 pl-1.5 w-max min-w-full border-l-[length:var(--border-width-thin)] border-border"),
|
|
247
|
+
children: [
|
|
248
|
+
entries.map(([k, v], idx) => /* @__PURE__ */ jsx(
|
|
249
|
+
Row,
|
|
250
|
+
{
|
|
251
|
+
rowKey: k,
|
|
252
|
+
isArrayItem: array,
|
|
253
|
+
value: v,
|
|
254
|
+
depth,
|
|
255
|
+
onValue: (next) => array ? setArrValue(idx, next) : setObjValue(k, next),
|
|
256
|
+
onRenameKey: (nk) => renameKey(k, nk),
|
|
257
|
+
onChangeKind: (kind) => array ? changeArrKind(idx, kind) : changeObjKind(k, kind),
|
|
258
|
+
onRemove: () => array ? removeArrIdx(idx) : removeObjKey(k),
|
|
259
|
+
readonly
|
|
260
|
+
},
|
|
261
|
+
array ? idx : k
|
|
262
|
+
)),
|
|
263
|
+
!readonly && /* @__PURE__ */ jsx(
|
|
264
|
+
Button,
|
|
265
|
+
{
|
|
266
|
+
variant: "ghost",
|
|
267
|
+
size: "sm",
|
|
268
|
+
icon: "plus",
|
|
269
|
+
label: array ? t("jsonTree.addItem") : t("jsonTree.addField"),
|
|
270
|
+
onClick: add,
|
|
271
|
+
className: "self-start text-muted-foreground"
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
)
|
|
277
|
+
] });
|
|
278
|
+
}
|
|
279
|
+
var JsonTreeEditor = ({ value, onChange, className, readonly }) => {
|
|
280
|
+
const root = value ?? "";
|
|
281
|
+
return /* @__PURE__ */ jsx("div", { className: cn("w-full overflow-x-auto rounded-container bg-card/40 p-2 border-[length:var(--border-width-thin)] border-border", className), children: /* @__PURE__ */ jsx(ValueNode, { value: root, onChange, depth: 0, readonly }) });
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export { JsonTreeEditor };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isNotificationSlot } from './chunk-
|
|
1
|
+
import { isNotificationSlot } from './chunk-PEST66PN.js';
|
|
2
2
|
import React, { useState, useRef, useMemo, useEffect, useCallback } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { RENDERED_SLOTS, isRenderBindingMarker } from '@almadar/core';
|
|
4
4
|
import { createLogger } from '@almadar/logger';
|
|
5
5
|
|
|
6
6
|
function expressionEqual(a, b) {
|
|
@@ -90,9 +90,7 @@ function reconcileSlotProps(prev, next) {
|
|
|
90
90
|
var log = createLogger("almadar:ui:ui-slots");
|
|
91
91
|
var DEFAULT_SOURCE_KEY = "__default__";
|
|
92
92
|
var MULTI_SOURCE_STACK_TRAIT = "__multi_source_stack__";
|
|
93
|
-
var ALL_SLOTS =
|
|
94
|
-
(slot) => !slot.includes(".") && slot !== "hud" && slot !== "screen"
|
|
95
|
-
);
|
|
93
|
+
var ALL_SLOTS = RENDERED_SLOTS;
|
|
96
94
|
var DEFAULT_SLOTS = ALL_SLOTS.reduce(
|
|
97
95
|
(acc, slot) => {
|
|
98
96
|
acc[slot] = null;
|