@almadar/ui 5.76.0 → 5.76.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/providers/index.cjs +397 -3
- package/dist/providers/index.d.ts +7 -1
- package/dist/providers/index.js +343 -4
- package/package.json +1 -1
package/dist/providers/index.cjs
CHANGED
|
@@ -65,6 +65,7 @@ function _interopNamespace(e) {
|
|
|
65
65
|
|
|
66
66
|
var React106__namespace = /*#__PURE__*/_interopNamespace(React106);
|
|
67
67
|
var LucideIcons2__namespace = /*#__PURE__*/_interopNamespace(LucideIcons2);
|
|
68
|
+
var context__default = /*#__PURE__*/_interopDefault(context);
|
|
68
69
|
var ELK__default = /*#__PURE__*/_interopDefault(ELK);
|
|
69
70
|
var SyntaxHighlighter__default = /*#__PURE__*/_interopDefault(SyntaxHighlighter);
|
|
70
71
|
var dark__default = /*#__PURE__*/_interopDefault(dark);
|
|
@@ -35190,7 +35191,7 @@ var init_MapView = __esm({
|
|
|
35190
35191
|
shadowSize: [41, 41]
|
|
35191
35192
|
});
|
|
35192
35193
|
L.Marker.prototype.options.icon = defaultIcon;
|
|
35193
|
-
const { useEffect: useEffect72, useRef: useRef75, useCallback:
|
|
35194
|
+
const { useEffect: useEffect72, useRef: useRef75, useCallback: useCallback114, useState: useState105 } = React106__namespace.default;
|
|
35194
35195
|
const { Typography: Typography2 } = await Promise.resolve().then(() => (init_Typography(), Typography_exports));
|
|
35195
35196
|
const { useEventBus: useEventBus2 } = await Promise.resolve().then(() => (init_useEventBus(), useEventBus_exports));
|
|
35196
35197
|
function MapUpdater({ centerLat, centerLng, zoom }) {
|
|
@@ -35236,7 +35237,7 @@ var init_MapView = __esm({
|
|
|
35236
35237
|
}) {
|
|
35237
35238
|
const eventBus = useEventBus2();
|
|
35238
35239
|
const [clickedPosition, setClickedPosition] = useState105(null);
|
|
35239
|
-
const handleMapClick =
|
|
35240
|
+
const handleMapClick = useCallback114((lat, lng) => {
|
|
35240
35241
|
if (showClickedPin) {
|
|
35241
35242
|
setClickedPosition({ lat, lng });
|
|
35242
35243
|
}
|
|
@@ -35245,7 +35246,7 @@ var init_MapView = __esm({
|
|
|
35245
35246
|
eventBus.emit(`UI:${mapClickEvent}`, { latitude: lat, longitude: lng });
|
|
35246
35247
|
}
|
|
35247
35248
|
}, [onMapClick, mapClickEvent, eventBus, showClickedPin]);
|
|
35248
|
-
const handleMarkerClick =
|
|
35249
|
+
const handleMarkerClick = useCallback114((marker) => {
|
|
35249
35250
|
onMarkerClick?.(marker);
|
|
35250
35251
|
if (markerClickEvent) {
|
|
35251
35252
|
eventBus.emit(`UI:${markerClickEvent}`, { ...marker });
|
|
@@ -52774,6 +52775,344 @@ function OrbitalProvider({
|
|
|
52774
52775
|
);
|
|
52775
52776
|
}
|
|
52776
52777
|
OrbitalProvider.displayName = "OrbitalProvider";
|
|
52778
|
+
|
|
52779
|
+
// lib/themeTokens.ts
|
|
52780
|
+
function themeTokensToCssVars(tokens, mode = "light", darkVariant) {
|
|
52781
|
+
const vars = {};
|
|
52782
|
+
const isDark = mode === "dark";
|
|
52783
|
+
const pickColors = isDark && darkVariant?.colors ? darkVariant.colors : tokens.colors;
|
|
52784
|
+
if (pickColors) {
|
|
52785
|
+
for (const [key, value] of Object.entries(pickColors)) {
|
|
52786
|
+
vars[`--color-${key}`] = value;
|
|
52787
|
+
}
|
|
52788
|
+
if (isDark && darkVariant?.colors && tokens.colors) {
|
|
52789
|
+
for (const [key, value] of Object.entries(tokens.colors)) {
|
|
52790
|
+
const varName = `--color-${key}`;
|
|
52791
|
+
if (!(varName in vars)) vars[varName] = value;
|
|
52792
|
+
}
|
|
52793
|
+
}
|
|
52794
|
+
}
|
|
52795
|
+
const pickRadii = isDark && darkVariant?.radii ? darkVariant.radii : tokens.radii;
|
|
52796
|
+
if (pickRadii) {
|
|
52797
|
+
for (const [key, value] of Object.entries(pickRadii)) {
|
|
52798
|
+
vars[`--radius-${key}`] = value;
|
|
52799
|
+
}
|
|
52800
|
+
}
|
|
52801
|
+
const pickSpacing = isDark && darkVariant?.spacing ? darkVariant.spacing : tokens.spacing;
|
|
52802
|
+
if (pickSpacing) {
|
|
52803
|
+
for (const [key, value] of Object.entries(pickSpacing)) {
|
|
52804
|
+
vars[`--space-${key}`] = value;
|
|
52805
|
+
}
|
|
52806
|
+
}
|
|
52807
|
+
const pickTypography = isDark && darkVariant?.typography ? darkVariant.typography : tokens.typography;
|
|
52808
|
+
if (pickTypography) {
|
|
52809
|
+
for (const [key, value] of Object.entries(pickTypography)) {
|
|
52810
|
+
vars[`--${key}`] = value;
|
|
52811
|
+
}
|
|
52812
|
+
}
|
|
52813
|
+
const pickShadows = isDark && darkVariant?.shadows ? darkVariant.shadows : tokens.shadows;
|
|
52814
|
+
if (pickShadows) {
|
|
52815
|
+
for (const [key, value] of Object.entries(pickShadows)) {
|
|
52816
|
+
vars[`--shadow-${key}`] = value;
|
|
52817
|
+
}
|
|
52818
|
+
}
|
|
52819
|
+
const pickDensity = isDark && darkVariant?.density ? darkVariant.density : tokens.density;
|
|
52820
|
+
emitDensity(pickDensity, vars);
|
|
52821
|
+
const pickTypeScale = isDark && darkVariant?.typeScale ? darkVariant.typeScale : tokens.typeScale;
|
|
52822
|
+
emitTypeScale(pickTypeScale, vars);
|
|
52823
|
+
const pickMotion = isDark && darkVariant?.motion ? darkVariant.motion : tokens.motion;
|
|
52824
|
+
emitMotion(pickMotion, vars);
|
|
52825
|
+
const pickIconography = isDark && darkVariant?.iconography ? darkVariant.iconography : tokens.iconography;
|
|
52826
|
+
emitIconography(pickIconography, vars);
|
|
52827
|
+
const pickElevation = isDark && darkVariant?.elevation ? darkVariant.elevation : tokens.elevation;
|
|
52828
|
+
emitElevation(pickElevation, vars);
|
|
52829
|
+
const pickGeometry = isDark && darkVariant?.geometry ? darkVariant.geometry : tokens.geometry;
|
|
52830
|
+
emitGeometry(pickGeometry, vars);
|
|
52831
|
+
return vars;
|
|
52832
|
+
}
|
|
52833
|
+
function emitDensity(density, vars) {
|
|
52834
|
+
if (!density) return;
|
|
52835
|
+
if (density.spacing) {
|
|
52836
|
+
const s = density.spacing;
|
|
52837
|
+
const pairs2 = [
|
|
52838
|
+
["0", s.space0],
|
|
52839
|
+
["1", s.space1],
|
|
52840
|
+
["2", s.space2],
|
|
52841
|
+
["3", s.space3],
|
|
52842
|
+
["4", s.space4],
|
|
52843
|
+
["5", s.space5],
|
|
52844
|
+
["6", s.space6],
|
|
52845
|
+
["7", s.space7],
|
|
52846
|
+
["8", s.space8],
|
|
52847
|
+
["9", s.space9],
|
|
52848
|
+
["10", s.space10],
|
|
52849
|
+
["11", s.space11],
|
|
52850
|
+
["12", s.space12]
|
|
52851
|
+
];
|
|
52852
|
+
for (const [k, v] of pairs2) {
|
|
52853
|
+
if (v !== void 0) vars[`--space-${k}`] = v;
|
|
52854
|
+
}
|
|
52855
|
+
}
|
|
52856
|
+
const pairs = [
|
|
52857
|
+
["button-height-sm", density.buttonHeightSm],
|
|
52858
|
+
["button-height-md", density.buttonHeightMd],
|
|
52859
|
+
["button-height-lg", density.buttonHeightLg],
|
|
52860
|
+
["input-height-sm", density.inputHeightSm],
|
|
52861
|
+
["input-height-md", density.inputHeightMd],
|
|
52862
|
+
["input-height-lg", density.inputHeightLg],
|
|
52863
|
+
["row-height-compact", density.rowHeightCompact],
|
|
52864
|
+
["row-height-normal", density.rowHeightNormal],
|
|
52865
|
+
["row-height-spacious", density.rowHeightSpacious],
|
|
52866
|
+
["card-padding-sm", density.cardPaddingSm],
|
|
52867
|
+
["card-padding-md", density.cardPaddingMd],
|
|
52868
|
+
["card-padding-lg", density.cardPaddingLg],
|
|
52869
|
+
["dialog-padding", density.dialogPadding],
|
|
52870
|
+
["section-gap", density.sectionGap]
|
|
52871
|
+
];
|
|
52872
|
+
for (const [k, v] of pairs) {
|
|
52873
|
+
if (v !== void 0) vars[`--${k}`] = v;
|
|
52874
|
+
}
|
|
52875
|
+
}
|
|
52876
|
+
function typeSizeKeyStr(k) {
|
|
52877
|
+
return k;
|
|
52878
|
+
}
|
|
52879
|
+
function typeWeightStr(w) {
|
|
52880
|
+
return w;
|
|
52881
|
+
}
|
|
52882
|
+
function emitTypeIntent(name, intent, vars) {
|
|
52883
|
+
const sizeKey2 = typeSizeKeyStr(intent.size);
|
|
52884
|
+
const weight = typeWeightStr(intent.weight);
|
|
52885
|
+
vars[`--intent-${name}-size`] = `var(--text-${sizeKey2})`;
|
|
52886
|
+
vars[`--intent-${name}-weight`] = `var(--font-weight-${weight})`;
|
|
52887
|
+
vars[`--intent-${name}-leading`] = `var(--leading-${sizeKey2})`;
|
|
52888
|
+
}
|
|
52889
|
+
function emitTypeScale(ts, vars) {
|
|
52890
|
+
if (!ts) return;
|
|
52891
|
+
if (ts.displayFamily !== void 0) vars["--font-family-display"] = ts.displayFamily;
|
|
52892
|
+
if (ts.bodyFamily !== void 0) vars["--font-family-body"] = ts.bodyFamily;
|
|
52893
|
+
if (ts.monoFamily !== void 0) vars["--font-family-mono"] = ts.monoFamily;
|
|
52894
|
+
if (ts.scale) {
|
|
52895
|
+
const s = ts.scale;
|
|
52896
|
+
const pairs = [
|
|
52897
|
+
["xs", s.xs],
|
|
52898
|
+
["sm", s.sm],
|
|
52899
|
+
["base", s.base],
|
|
52900
|
+
["lg", s.lg],
|
|
52901
|
+
["xl", s.xl],
|
|
52902
|
+
["2xl", s["2xl"]],
|
|
52903
|
+
["3xl", s["3xl"]],
|
|
52904
|
+
["4xl", s["4xl"]],
|
|
52905
|
+
["display-1", s["display-1"]],
|
|
52906
|
+
["display-2", s["display-2"]]
|
|
52907
|
+
];
|
|
52908
|
+
for (const [k, entry] of pairs) {
|
|
52909
|
+
if (entry !== void 0) {
|
|
52910
|
+
vars[`--text-${k}`] = entry.size;
|
|
52911
|
+
vars[`--leading-${k}`] = entry.lineHeight;
|
|
52912
|
+
}
|
|
52913
|
+
}
|
|
52914
|
+
}
|
|
52915
|
+
if (ts.intents) {
|
|
52916
|
+
const i = ts.intents;
|
|
52917
|
+
if (i.headingMajor) emitTypeIntent("heading-major", i.headingMajor, vars);
|
|
52918
|
+
if (i.headingMinor) emitTypeIntent("heading-minor", i.headingMinor, vars);
|
|
52919
|
+
if (i.bodyEmphasis) emitTypeIntent("body-emphasis", i.bodyEmphasis, vars);
|
|
52920
|
+
if (i.bodyDefault) emitTypeIntent("body-default", i.bodyDefault, vars);
|
|
52921
|
+
if (i.bodyQuiet) emitTypeIntent("body-quiet", i.bodyQuiet, vars);
|
|
52922
|
+
if (i.caption) emitTypeIntent("caption", i.caption, vars);
|
|
52923
|
+
if (i.numeric) emitTypeIntent("numeric", i.numeric, vars);
|
|
52924
|
+
}
|
|
52925
|
+
}
|
|
52926
|
+
function emitMotionIntent(name, intent, vars) {
|
|
52927
|
+
vars[`--intent-${name}-duration`] = `var(--duration-${intent.duration})`;
|
|
52928
|
+
vars[`--intent-${name}-easing`] = `var(--easing-${intent.easing})`;
|
|
52929
|
+
}
|
|
52930
|
+
function emitMotion(m, vars) {
|
|
52931
|
+
if (!m) return;
|
|
52932
|
+
if (m.durations) {
|
|
52933
|
+
const d = m.durations;
|
|
52934
|
+
const pairs = [
|
|
52935
|
+
["instant", d.instant],
|
|
52936
|
+
["fast", d.fast],
|
|
52937
|
+
["normal", d.normal],
|
|
52938
|
+
["slow", d.slow],
|
|
52939
|
+
["dramatic", d.dramatic]
|
|
52940
|
+
];
|
|
52941
|
+
for (const [k, v] of pairs) {
|
|
52942
|
+
if (v !== void 0) vars[`--duration-${k}`] = v;
|
|
52943
|
+
}
|
|
52944
|
+
}
|
|
52945
|
+
if (m.easings) {
|
|
52946
|
+
const e = m.easings;
|
|
52947
|
+
const pairs = [
|
|
52948
|
+
["linear", e.linear],
|
|
52949
|
+
["standard", e.standard],
|
|
52950
|
+
["emphasized", e.emphasized],
|
|
52951
|
+
["spring", e.spring]
|
|
52952
|
+
];
|
|
52953
|
+
for (const [k, v] of pairs) {
|
|
52954
|
+
if (v !== void 0) vars[`--easing-${k}`] = v;
|
|
52955
|
+
}
|
|
52956
|
+
}
|
|
52957
|
+
if (m.intents) {
|
|
52958
|
+
const i = m.intents;
|
|
52959
|
+
if (i.enter) emitMotionIntent("enter", i.enter, vars);
|
|
52960
|
+
if (i.exit) emitMotionIntent("exit", i.exit, vars);
|
|
52961
|
+
if (i.hover) emitMotionIntent("hover", i.hover, vars);
|
|
52962
|
+
if (i.press) emitMotionIntent("press", i.press, vars);
|
|
52963
|
+
if (i.expand) emitMotionIntent("expand", i.expand, vars);
|
|
52964
|
+
if (i.transition) emitMotionIntent("transition", i.transition, vars);
|
|
52965
|
+
}
|
|
52966
|
+
}
|
|
52967
|
+
function emitIconography(i, vars) {
|
|
52968
|
+
if (!i) return;
|
|
52969
|
+
if (i.family !== void 0) vars["--icon-family"] = i.family;
|
|
52970
|
+
if (i.strokeWidth !== void 0) vars["--icon-stroke-width"] = i.strokeWidth;
|
|
52971
|
+
if (i.defaultSize !== void 0) vars["--icon-default-size"] = i.defaultSize;
|
|
52972
|
+
}
|
|
52973
|
+
function emitElevation(e, vars) {
|
|
52974
|
+
if (!e) return;
|
|
52975
|
+
if (e.cardElevation !== void 0) vars["--elevation-card"] = e.cardElevation;
|
|
52976
|
+
if (e.popoverElevation !== void 0) vars["--elevation-popover"] = e.popoverElevation;
|
|
52977
|
+
if (e.dialogElevation !== void 0) vars["--elevation-dialog"] = e.dialogElevation;
|
|
52978
|
+
if (e.toastElevation !== void 0) vars["--elevation-toast"] = e.toastElevation;
|
|
52979
|
+
}
|
|
52980
|
+
function emitGeometry(g, vars) {
|
|
52981
|
+
if (!g) return;
|
|
52982
|
+
if (g.radiusContainer !== void 0) vars["--radius-container"] = g.radiusContainer;
|
|
52983
|
+
if (g.radiusInteractive !== void 0) vars["--radius-interactive"] = g.radiusInteractive;
|
|
52984
|
+
if (g.radiusPill !== void 0) vars["--radius-pill"] = g.radiusPill;
|
|
52985
|
+
if (g.borderHairline !== void 0) vars["--border-hairline"] = g.borderHairline;
|
|
52986
|
+
if (g.borderStandard !== void 0) vars["--border-standard"] = g.borderStandard;
|
|
52987
|
+
if (g.borderHeavy !== void 0) vars["--border-heavy"] = g.borderHeavy;
|
|
52988
|
+
}
|
|
52989
|
+
function resolveThemeForRuntime(theme) {
|
|
52990
|
+
if (theme === void 0) return void 0;
|
|
52991
|
+
if (typeof theme === "string") return void 0;
|
|
52992
|
+
return theme;
|
|
52993
|
+
}
|
|
52994
|
+
function OrbitalThemeProvider({ theme, children }) {
|
|
52995
|
+
const resolved = resolveThemeForRuntime(theme);
|
|
52996
|
+
const { resolvedMode } = context.useTheme();
|
|
52997
|
+
if (!resolved) {
|
|
52998
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
52999
|
+
}
|
|
53000
|
+
const vars = themeTokensToCssVars(resolved.tokens, resolvedMode, resolved.variants?.dark);
|
|
53001
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
53002
|
+
"div",
|
|
53003
|
+
{
|
|
53004
|
+
"data-orbital-theme": resolved.name,
|
|
53005
|
+
style: { display: "contents", ...vars },
|
|
53006
|
+
children
|
|
53007
|
+
}
|
|
53008
|
+
);
|
|
53009
|
+
}
|
|
53010
|
+
OrbitalThemeProvider.displayName = "OrbitalThemeProvider";
|
|
53011
|
+
var CurrentPagePathContext = React106.createContext(void 0);
|
|
53012
|
+
var CurrentPagePathProvider = ({
|
|
53013
|
+
value,
|
|
53014
|
+
children
|
|
53015
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(CurrentPagePathContext.Provider, { value, children });
|
|
53016
|
+
CurrentPagePathProvider.displayName = "CurrentPagePathProvider";
|
|
53017
|
+
var useCurrentPagePath2 = () => React106.useContext(CurrentPagePathContext);
|
|
53018
|
+
var ANONYMOUS_USER = {
|
|
53019
|
+
id: "anonymous",
|
|
53020
|
+
role: "anonymous",
|
|
53021
|
+
permissions: []
|
|
53022
|
+
};
|
|
53023
|
+
var UserContext = React106.createContext(null);
|
|
53024
|
+
function UserProvider({
|
|
53025
|
+
user = null,
|
|
53026
|
+
children
|
|
53027
|
+
}) {
|
|
53028
|
+
const hasRole = React106.useCallback(
|
|
53029
|
+
(role) => {
|
|
53030
|
+
if (!user) return role === "anonymous";
|
|
53031
|
+
return user.role === role;
|
|
53032
|
+
},
|
|
53033
|
+
[user]
|
|
53034
|
+
);
|
|
53035
|
+
const hasPermission = React106.useCallback(
|
|
53036
|
+
(permission) => {
|
|
53037
|
+
if (!user) return false;
|
|
53038
|
+
return user.permissions?.includes(permission) ?? false;
|
|
53039
|
+
},
|
|
53040
|
+
[user]
|
|
53041
|
+
);
|
|
53042
|
+
const hasAnyRole = React106.useCallback(
|
|
53043
|
+
(roles) => {
|
|
53044
|
+
if (!user) return roles.includes("anonymous");
|
|
53045
|
+
return user.role ? roles.includes(user.role) : false;
|
|
53046
|
+
},
|
|
53047
|
+
[user]
|
|
53048
|
+
);
|
|
53049
|
+
const hasAllPermissions = React106.useCallback(
|
|
53050
|
+
(permissions) => {
|
|
53051
|
+
if (!user || !user.permissions) return false;
|
|
53052
|
+
return permissions.every((p2) => user.permissions?.includes(p2));
|
|
53053
|
+
},
|
|
53054
|
+
[user]
|
|
53055
|
+
);
|
|
53056
|
+
const getUserField = React106.useCallback(
|
|
53057
|
+
(path) => {
|
|
53058
|
+
const userData = user ?? ANONYMOUS_USER;
|
|
53059
|
+
const parts = path.split(".");
|
|
53060
|
+
let value = userData;
|
|
53061
|
+
for (const segment of parts) {
|
|
53062
|
+
if (value === null || value === void 0) {
|
|
53063
|
+
return void 0;
|
|
53064
|
+
}
|
|
53065
|
+
if (typeof value === "object") {
|
|
53066
|
+
value = value[segment];
|
|
53067
|
+
} else {
|
|
53068
|
+
return void 0;
|
|
53069
|
+
}
|
|
53070
|
+
}
|
|
53071
|
+
return value;
|
|
53072
|
+
},
|
|
53073
|
+
[user]
|
|
53074
|
+
);
|
|
53075
|
+
const contextValue = React106.useMemo(
|
|
53076
|
+
() => ({
|
|
53077
|
+
user,
|
|
53078
|
+
isLoggedIn: user !== null,
|
|
53079
|
+
hasRole,
|
|
53080
|
+
hasPermission,
|
|
53081
|
+
hasAnyRole,
|
|
53082
|
+
hasAllPermissions,
|
|
53083
|
+
getUserField
|
|
53084
|
+
}),
|
|
53085
|
+
[user, hasRole, hasPermission, hasAnyRole, hasAllPermissions, getUserField]
|
|
53086
|
+
);
|
|
53087
|
+
return /* @__PURE__ */ jsxRuntime.jsx(UserContext.Provider, { value: contextValue, children });
|
|
53088
|
+
}
|
|
53089
|
+
function useUser() {
|
|
53090
|
+
const context = React106.useContext(UserContext);
|
|
53091
|
+
if (!context) {
|
|
53092
|
+
return {
|
|
53093
|
+
user: null,
|
|
53094
|
+
isLoggedIn: false,
|
|
53095
|
+
hasRole: (role) => role === "anonymous",
|
|
53096
|
+
hasPermission: () => false,
|
|
53097
|
+
hasAnyRole: (roles) => roles.includes("anonymous"),
|
|
53098
|
+
hasAllPermissions: () => false,
|
|
53099
|
+
getUserField: () => void 0
|
|
53100
|
+
};
|
|
53101
|
+
}
|
|
53102
|
+
return context;
|
|
53103
|
+
}
|
|
53104
|
+
function useHasRole(role) {
|
|
53105
|
+
const { hasRole } = useUser();
|
|
53106
|
+
return hasRole(role);
|
|
53107
|
+
}
|
|
53108
|
+
function useHasPermission(permission) {
|
|
53109
|
+
const { hasPermission } = useUser();
|
|
53110
|
+
return hasPermission(permission);
|
|
53111
|
+
}
|
|
53112
|
+
function useUserForEvaluation() {
|
|
53113
|
+
const { user, isLoggedIn } = useUser();
|
|
53114
|
+
return isLoggedIn && user ? user : void 0;
|
|
53115
|
+
}
|
|
52777
53116
|
var TraitScopeContext = React106.createContext(null);
|
|
52778
53117
|
function TraitScopeProvider3({
|
|
52779
53118
|
orbital,
|
|
@@ -52819,16 +53158,71 @@ function useOptionalOfflineMode() {
|
|
|
52819
53158
|
return React106.useContext(OfflineModeContext);
|
|
52820
53159
|
}
|
|
52821
53160
|
|
|
53161
|
+
Object.defineProperty(exports, "BUILT_IN_THEMES", {
|
|
53162
|
+
enumerable: true,
|
|
53163
|
+
get: function () { return context.BUILT_IN_THEMES; }
|
|
53164
|
+
});
|
|
53165
|
+
Object.defineProperty(exports, "DesignThemeProvider", {
|
|
53166
|
+
enumerable: true,
|
|
53167
|
+
get: function () { return context.DesignThemeProvider; }
|
|
53168
|
+
});
|
|
53169
|
+
Object.defineProperty(exports, "ThemeContext", {
|
|
53170
|
+
enumerable: true,
|
|
53171
|
+
get: function () { return context__default.default; }
|
|
53172
|
+
});
|
|
53173
|
+
Object.defineProperty(exports, "ThemeProvider", {
|
|
53174
|
+
enumerable: true,
|
|
53175
|
+
get: function () { return context.ThemeProvider; }
|
|
53176
|
+
});
|
|
53177
|
+
Object.defineProperty(exports, "UISlotContext", {
|
|
53178
|
+
enumerable: true,
|
|
53179
|
+
get: function () { return context.UISlotContext; }
|
|
53180
|
+
});
|
|
53181
|
+
Object.defineProperty(exports, "UISlotProvider", {
|
|
53182
|
+
enumerable: true,
|
|
53183
|
+
get: function () { return context.UISlotProvider; }
|
|
53184
|
+
});
|
|
53185
|
+
Object.defineProperty(exports, "useDesignTheme", {
|
|
53186
|
+
enumerable: true,
|
|
53187
|
+
get: function () { return context.useDesignTheme; }
|
|
53188
|
+
});
|
|
53189
|
+
Object.defineProperty(exports, "useSlotContent", {
|
|
53190
|
+
enumerable: true,
|
|
53191
|
+
get: function () { return context.useSlotContent; }
|
|
53192
|
+
});
|
|
53193
|
+
Object.defineProperty(exports, "useSlotHasContent", {
|
|
53194
|
+
enumerable: true,
|
|
53195
|
+
get: function () { return context.useSlotHasContent; }
|
|
53196
|
+
});
|
|
53197
|
+
Object.defineProperty(exports, "useTheme", {
|
|
53198
|
+
enumerable: true,
|
|
53199
|
+
get: function () { return context.useTheme; }
|
|
53200
|
+
});
|
|
53201
|
+
Object.defineProperty(exports, "useUISlots", {
|
|
53202
|
+
enumerable: true,
|
|
53203
|
+
get: function () { return context.useUISlots; }
|
|
53204
|
+
});
|
|
53205
|
+
exports.ANONYMOUS_USER = ANONYMOUS_USER;
|
|
53206
|
+
exports.CurrentPagePathContext = CurrentPagePathContext;
|
|
53207
|
+
exports.CurrentPagePathProvider = CurrentPagePathProvider;
|
|
52822
53208
|
exports.EventBusContext = EventBusContext2;
|
|
52823
53209
|
exports.EventBusProvider = EventBusProvider;
|
|
52824
53210
|
exports.OfflineModeProvider = OfflineModeProvider;
|
|
52825
53211
|
exports.OrbitalProvider = OrbitalProvider;
|
|
53212
|
+
exports.OrbitalThemeProvider = OrbitalThemeProvider;
|
|
52826
53213
|
exports.SelectionContext = SelectionContext;
|
|
52827
53214
|
exports.SelectionProvider = SelectionProvider;
|
|
52828
53215
|
exports.TraitScopeProvider = TraitScopeProvider3;
|
|
53216
|
+
exports.UserContext = UserContext;
|
|
53217
|
+
exports.UserProvider = UserProvider;
|
|
52829
53218
|
exports.VerificationProvider = VerificationProvider;
|
|
53219
|
+
exports.useCurrentPagePath = useCurrentPagePath2;
|
|
53220
|
+
exports.useHasPermission = useHasPermission;
|
|
53221
|
+
exports.useHasRole = useHasRole;
|
|
52830
53222
|
exports.useOfflineMode = useOfflineMode;
|
|
52831
53223
|
exports.useOptionalOfflineMode = useOptionalOfflineMode;
|
|
52832
53224
|
exports.useSelection = useSelection;
|
|
52833
53225
|
exports.useSelectionOptional = useSelectionOptional;
|
|
52834
53226
|
exports.useTraitScope = useTraitScope2;
|
|
53227
|
+
exports.useUser = useUser;
|
|
53228
|
+
exports.useUserForEvaluation = useUserForEvaluation;
|
|
@@ -5,7 +5,13 @@
|
|
|
5
5
|
* Use OrbitalProvider for most cases - it combines all required providers.
|
|
6
6
|
*/
|
|
7
7
|
export { OrbitalProvider, type OrbitalProviderProps } from './OrbitalProvider';
|
|
8
|
-
export type
|
|
8
|
+
export { ThemeProvider, useTheme, BUILT_IN_THEMES, type UIThemeDefinition, type ThemeProviderProps, type ColorMode, type ResolvedMode, type DesignTheme, } from './ThemeContext';
|
|
9
|
+
export { default as ThemeContext } from './ThemeContext';
|
|
10
|
+
export { UISlotProvider, useUISlots, useSlotContent, useSlotHasContent, UISlotContext, type UISlotManager, type UISlot, type SlotContent, type SlotRenderConfig, type SlotAnimation, type SlotChangeCallback, } from './UISlotContext';
|
|
11
|
+
export { OrbitalThemeProvider, type OrbitalThemeProviderProps } from './OrbitalThemeProvider';
|
|
12
|
+
export { DesignThemeProvider, useDesignTheme } from './DesignThemeContext';
|
|
13
|
+
export { CurrentPagePathProvider, CurrentPagePathContext, useCurrentPagePath, type CurrentPagePathProviderProps, } from './CurrentPagePathContext';
|
|
14
|
+
export { UserProvider, UserContext, useUser, useHasRole, useHasPermission, useUserForEvaluation, ANONYMOUS_USER, type UserData, type UserContextValue, type UserProviderProps, } from './UserContext';
|
|
9
15
|
export { EventBusProvider, EventBusContext } from './EventBusProvider';
|
|
10
16
|
export { TraitScopeProvider, useTraitScope } from './TraitScopeProvider';
|
|
11
17
|
export type { TraitScope, TraitScopeProviderProps } from './TraitScopeProvider';
|
package/dist/providers/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
10
10
|
import { createPortal } from 'react-dom';
|
|
11
11
|
import { useTranslate } from '@almadar/ui/hooks';
|
|
12
12
|
import { useUISlots, ThemeProvider, useTheme } from '@almadar/ui/context';
|
|
13
|
+
export { BUILT_IN_THEMES, DesignThemeProvider, default as ThemeContext, ThemeProvider, UISlotContext, UISlotProvider, useDesignTheme, useSlotContent, useSlotHasContent, useTheme, useUISlots } from '@almadar/ui/context';
|
|
13
14
|
import { evaluate, createMinimalContext } from '@almadar/evaluator';
|
|
14
15
|
import { getPatternDefinition, getComponentForPattern } from '@almadar/patterns';
|
|
15
16
|
import { Link, Outlet, useLocation } from 'react-router-dom';
|
|
@@ -35144,7 +35145,7 @@ var init_MapView = __esm({
|
|
|
35144
35145
|
shadowSize: [41, 41]
|
|
35145
35146
|
});
|
|
35146
35147
|
L.Marker.prototype.options.icon = defaultIcon;
|
|
35147
|
-
const { useEffect: useEffect72, useRef: useRef75, useCallback:
|
|
35148
|
+
const { useEffect: useEffect72, useRef: useRef75, useCallback: useCallback114, useState: useState105 } = React106__default;
|
|
35148
35149
|
const { Typography: Typography2 } = await Promise.resolve().then(() => (init_Typography(), Typography_exports));
|
|
35149
35150
|
const { useEventBus: useEventBus2 } = await Promise.resolve().then(() => (init_useEventBus(), useEventBus_exports));
|
|
35150
35151
|
function MapUpdater({ centerLat, centerLng, zoom }) {
|
|
@@ -35190,7 +35191,7 @@ var init_MapView = __esm({
|
|
|
35190
35191
|
}) {
|
|
35191
35192
|
const eventBus = useEventBus2();
|
|
35192
35193
|
const [clickedPosition, setClickedPosition] = useState105(null);
|
|
35193
|
-
const handleMapClick =
|
|
35194
|
+
const handleMapClick = useCallback114((lat, lng) => {
|
|
35194
35195
|
if (showClickedPin) {
|
|
35195
35196
|
setClickedPosition({ lat, lng });
|
|
35196
35197
|
}
|
|
@@ -35199,7 +35200,7 @@ var init_MapView = __esm({
|
|
|
35199
35200
|
eventBus.emit(`UI:${mapClickEvent}`, { latitude: lat, longitude: lng });
|
|
35200
35201
|
}
|
|
35201
35202
|
}, [onMapClick, mapClickEvent, eventBus, showClickedPin]);
|
|
35202
|
-
const handleMarkerClick =
|
|
35203
|
+
const handleMarkerClick = useCallback114((marker) => {
|
|
35203
35204
|
onMarkerClick?.(marker);
|
|
35204
35205
|
if (markerClickEvent) {
|
|
35205
35206
|
eventBus.emit(`UI:${markerClickEvent}`, { ...marker });
|
|
@@ -52728,6 +52729,344 @@ function OrbitalProvider({
|
|
|
52728
52729
|
);
|
|
52729
52730
|
}
|
|
52730
52731
|
OrbitalProvider.displayName = "OrbitalProvider";
|
|
52732
|
+
|
|
52733
|
+
// lib/themeTokens.ts
|
|
52734
|
+
function themeTokensToCssVars(tokens, mode = "light", darkVariant) {
|
|
52735
|
+
const vars = {};
|
|
52736
|
+
const isDark = mode === "dark";
|
|
52737
|
+
const pickColors = isDark && darkVariant?.colors ? darkVariant.colors : tokens.colors;
|
|
52738
|
+
if (pickColors) {
|
|
52739
|
+
for (const [key, value] of Object.entries(pickColors)) {
|
|
52740
|
+
vars[`--color-${key}`] = value;
|
|
52741
|
+
}
|
|
52742
|
+
if (isDark && darkVariant?.colors && tokens.colors) {
|
|
52743
|
+
for (const [key, value] of Object.entries(tokens.colors)) {
|
|
52744
|
+
const varName = `--color-${key}`;
|
|
52745
|
+
if (!(varName in vars)) vars[varName] = value;
|
|
52746
|
+
}
|
|
52747
|
+
}
|
|
52748
|
+
}
|
|
52749
|
+
const pickRadii = isDark && darkVariant?.radii ? darkVariant.radii : tokens.radii;
|
|
52750
|
+
if (pickRadii) {
|
|
52751
|
+
for (const [key, value] of Object.entries(pickRadii)) {
|
|
52752
|
+
vars[`--radius-${key}`] = value;
|
|
52753
|
+
}
|
|
52754
|
+
}
|
|
52755
|
+
const pickSpacing = isDark && darkVariant?.spacing ? darkVariant.spacing : tokens.spacing;
|
|
52756
|
+
if (pickSpacing) {
|
|
52757
|
+
for (const [key, value] of Object.entries(pickSpacing)) {
|
|
52758
|
+
vars[`--space-${key}`] = value;
|
|
52759
|
+
}
|
|
52760
|
+
}
|
|
52761
|
+
const pickTypography = isDark && darkVariant?.typography ? darkVariant.typography : tokens.typography;
|
|
52762
|
+
if (pickTypography) {
|
|
52763
|
+
for (const [key, value] of Object.entries(pickTypography)) {
|
|
52764
|
+
vars[`--${key}`] = value;
|
|
52765
|
+
}
|
|
52766
|
+
}
|
|
52767
|
+
const pickShadows = isDark && darkVariant?.shadows ? darkVariant.shadows : tokens.shadows;
|
|
52768
|
+
if (pickShadows) {
|
|
52769
|
+
for (const [key, value] of Object.entries(pickShadows)) {
|
|
52770
|
+
vars[`--shadow-${key}`] = value;
|
|
52771
|
+
}
|
|
52772
|
+
}
|
|
52773
|
+
const pickDensity = isDark && darkVariant?.density ? darkVariant.density : tokens.density;
|
|
52774
|
+
emitDensity(pickDensity, vars);
|
|
52775
|
+
const pickTypeScale = isDark && darkVariant?.typeScale ? darkVariant.typeScale : tokens.typeScale;
|
|
52776
|
+
emitTypeScale(pickTypeScale, vars);
|
|
52777
|
+
const pickMotion = isDark && darkVariant?.motion ? darkVariant.motion : tokens.motion;
|
|
52778
|
+
emitMotion(pickMotion, vars);
|
|
52779
|
+
const pickIconography = isDark && darkVariant?.iconography ? darkVariant.iconography : tokens.iconography;
|
|
52780
|
+
emitIconography(pickIconography, vars);
|
|
52781
|
+
const pickElevation = isDark && darkVariant?.elevation ? darkVariant.elevation : tokens.elevation;
|
|
52782
|
+
emitElevation(pickElevation, vars);
|
|
52783
|
+
const pickGeometry = isDark && darkVariant?.geometry ? darkVariant.geometry : tokens.geometry;
|
|
52784
|
+
emitGeometry(pickGeometry, vars);
|
|
52785
|
+
return vars;
|
|
52786
|
+
}
|
|
52787
|
+
function emitDensity(density, vars) {
|
|
52788
|
+
if (!density) return;
|
|
52789
|
+
if (density.spacing) {
|
|
52790
|
+
const s = density.spacing;
|
|
52791
|
+
const pairs2 = [
|
|
52792
|
+
["0", s.space0],
|
|
52793
|
+
["1", s.space1],
|
|
52794
|
+
["2", s.space2],
|
|
52795
|
+
["3", s.space3],
|
|
52796
|
+
["4", s.space4],
|
|
52797
|
+
["5", s.space5],
|
|
52798
|
+
["6", s.space6],
|
|
52799
|
+
["7", s.space7],
|
|
52800
|
+
["8", s.space8],
|
|
52801
|
+
["9", s.space9],
|
|
52802
|
+
["10", s.space10],
|
|
52803
|
+
["11", s.space11],
|
|
52804
|
+
["12", s.space12]
|
|
52805
|
+
];
|
|
52806
|
+
for (const [k, v] of pairs2) {
|
|
52807
|
+
if (v !== void 0) vars[`--space-${k}`] = v;
|
|
52808
|
+
}
|
|
52809
|
+
}
|
|
52810
|
+
const pairs = [
|
|
52811
|
+
["button-height-sm", density.buttonHeightSm],
|
|
52812
|
+
["button-height-md", density.buttonHeightMd],
|
|
52813
|
+
["button-height-lg", density.buttonHeightLg],
|
|
52814
|
+
["input-height-sm", density.inputHeightSm],
|
|
52815
|
+
["input-height-md", density.inputHeightMd],
|
|
52816
|
+
["input-height-lg", density.inputHeightLg],
|
|
52817
|
+
["row-height-compact", density.rowHeightCompact],
|
|
52818
|
+
["row-height-normal", density.rowHeightNormal],
|
|
52819
|
+
["row-height-spacious", density.rowHeightSpacious],
|
|
52820
|
+
["card-padding-sm", density.cardPaddingSm],
|
|
52821
|
+
["card-padding-md", density.cardPaddingMd],
|
|
52822
|
+
["card-padding-lg", density.cardPaddingLg],
|
|
52823
|
+
["dialog-padding", density.dialogPadding],
|
|
52824
|
+
["section-gap", density.sectionGap]
|
|
52825
|
+
];
|
|
52826
|
+
for (const [k, v] of pairs) {
|
|
52827
|
+
if (v !== void 0) vars[`--${k}`] = v;
|
|
52828
|
+
}
|
|
52829
|
+
}
|
|
52830
|
+
function typeSizeKeyStr(k) {
|
|
52831
|
+
return k;
|
|
52832
|
+
}
|
|
52833
|
+
function typeWeightStr(w) {
|
|
52834
|
+
return w;
|
|
52835
|
+
}
|
|
52836
|
+
function emitTypeIntent(name, intent, vars) {
|
|
52837
|
+
const sizeKey2 = typeSizeKeyStr(intent.size);
|
|
52838
|
+
const weight = typeWeightStr(intent.weight);
|
|
52839
|
+
vars[`--intent-${name}-size`] = `var(--text-${sizeKey2})`;
|
|
52840
|
+
vars[`--intent-${name}-weight`] = `var(--font-weight-${weight})`;
|
|
52841
|
+
vars[`--intent-${name}-leading`] = `var(--leading-${sizeKey2})`;
|
|
52842
|
+
}
|
|
52843
|
+
function emitTypeScale(ts, vars) {
|
|
52844
|
+
if (!ts) return;
|
|
52845
|
+
if (ts.displayFamily !== void 0) vars["--font-family-display"] = ts.displayFamily;
|
|
52846
|
+
if (ts.bodyFamily !== void 0) vars["--font-family-body"] = ts.bodyFamily;
|
|
52847
|
+
if (ts.monoFamily !== void 0) vars["--font-family-mono"] = ts.monoFamily;
|
|
52848
|
+
if (ts.scale) {
|
|
52849
|
+
const s = ts.scale;
|
|
52850
|
+
const pairs = [
|
|
52851
|
+
["xs", s.xs],
|
|
52852
|
+
["sm", s.sm],
|
|
52853
|
+
["base", s.base],
|
|
52854
|
+
["lg", s.lg],
|
|
52855
|
+
["xl", s.xl],
|
|
52856
|
+
["2xl", s["2xl"]],
|
|
52857
|
+
["3xl", s["3xl"]],
|
|
52858
|
+
["4xl", s["4xl"]],
|
|
52859
|
+
["display-1", s["display-1"]],
|
|
52860
|
+
["display-2", s["display-2"]]
|
|
52861
|
+
];
|
|
52862
|
+
for (const [k, entry] of pairs) {
|
|
52863
|
+
if (entry !== void 0) {
|
|
52864
|
+
vars[`--text-${k}`] = entry.size;
|
|
52865
|
+
vars[`--leading-${k}`] = entry.lineHeight;
|
|
52866
|
+
}
|
|
52867
|
+
}
|
|
52868
|
+
}
|
|
52869
|
+
if (ts.intents) {
|
|
52870
|
+
const i = ts.intents;
|
|
52871
|
+
if (i.headingMajor) emitTypeIntent("heading-major", i.headingMajor, vars);
|
|
52872
|
+
if (i.headingMinor) emitTypeIntent("heading-minor", i.headingMinor, vars);
|
|
52873
|
+
if (i.bodyEmphasis) emitTypeIntent("body-emphasis", i.bodyEmphasis, vars);
|
|
52874
|
+
if (i.bodyDefault) emitTypeIntent("body-default", i.bodyDefault, vars);
|
|
52875
|
+
if (i.bodyQuiet) emitTypeIntent("body-quiet", i.bodyQuiet, vars);
|
|
52876
|
+
if (i.caption) emitTypeIntent("caption", i.caption, vars);
|
|
52877
|
+
if (i.numeric) emitTypeIntent("numeric", i.numeric, vars);
|
|
52878
|
+
}
|
|
52879
|
+
}
|
|
52880
|
+
function emitMotionIntent(name, intent, vars) {
|
|
52881
|
+
vars[`--intent-${name}-duration`] = `var(--duration-${intent.duration})`;
|
|
52882
|
+
vars[`--intent-${name}-easing`] = `var(--easing-${intent.easing})`;
|
|
52883
|
+
}
|
|
52884
|
+
function emitMotion(m, vars) {
|
|
52885
|
+
if (!m) return;
|
|
52886
|
+
if (m.durations) {
|
|
52887
|
+
const d = m.durations;
|
|
52888
|
+
const pairs = [
|
|
52889
|
+
["instant", d.instant],
|
|
52890
|
+
["fast", d.fast],
|
|
52891
|
+
["normal", d.normal],
|
|
52892
|
+
["slow", d.slow],
|
|
52893
|
+
["dramatic", d.dramatic]
|
|
52894
|
+
];
|
|
52895
|
+
for (const [k, v] of pairs) {
|
|
52896
|
+
if (v !== void 0) vars[`--duration-${k}`] = v;
|
|
52897
|
+
}
|
|
52898
|
+
}
|
|
52899
|
+
if (m.easings) {
|
|
52900
|
+
const e = m.easings;
|
|
52901
|
+
const pairs = [
|
|
52902
|
+
["linear", e.linear],
|
|
52903
|
+
["standard", e.standard],
|
|
52904
|
+
["emphasized", e.emphasized],
|
|
52905
|
+
["spring", e.spring]
|
|
52906
|
+
];
|
|
52907
|
+
for (const [k, v] of pairs) {
|
|
52908
|
+
if (v !== void 0) vars[`--easing-${k}`] = v;
|
|
52909
|
+
}
|
|
52910
|
+
}
|
|
52911
|
+
if (m.intents) {
|
|
52912
|
+
const i = m.intents;
|
|
52913
|
+
if (i.enter) emitMotionIntent("enter", i.enter, vars);
|
|
52914
|
+
if (i.exit) emitMotionIntent("exit", i.exit, vars);
|
|
52915
|
+
if (i.hover) emitMotionIntent("hover", i.hover, vars);
|
|
52916
|
+
if (i.press) emitMotionIntent("press", i.press, vars);
|
|
52917
|
+
if (i.expand) emitMotionIntent("expand", i.expand, vars);
|
|
52918
|
+
if (i.transition) emitMotionIntent("transition", i.transition, vars);
|
|
52919
|
+
}
|
|
52920
|
+
}
|
|
52921
|
+
function emitIconography(i, vars) {
|
|
52922
|
+
if (!i) return;
|
|
52923
|
+
if (i.family !== void 0) vars["--icon-family"] = i.family;
|
|
52924
|
+
if (i.strokeWidth !== void 0) vars["--icon-stroke-width"] = i.strokeWidth;
|
|
52925
|
+
if (i.defaultSize !== void 0) vars["--icon-default-size"] = i.defaultSize;
|
|
52926
|
+
}
|
|
52927
|
+
function emitElevation(e, vars) {
|
|
52928
|
+
if (!e) return;
|
|
52929
|
+
if (e.cardElevation !== void 0) vars["--elevation-card"] = e.cardElevation;
|
|
52930
|
+
if (e.popoverElevation !== void 0) vars["--elevation-popover"] = e.popoverElevation;
|
|
52931
|
+
if (e.dialogElevation !== void 0) vars["--elevation-dialog"] = e.dialogElevation;
|
|
52932
|
+
if (e.toastElevation !== void 0) vars["--elevation-toast"] = e.toastElevation;
|
|
52933
|
+
}
|
|
52934
|
+
function emitGeometry(g, vars) {
|
|
52935
|
+
if (!g) return;
|
|
52936
|
+
if (g.radiusContainer !== void 0) vars["--radius-container"] = g.radiusContainer;
|
|
52937
|
+
if (g.radiusInteractive !== void 0) vars["--radius-interactive"] = g.radiusInteractive;
|
|
52938
|
+
if (g.radiusPill !== void 0) vars["--radius-pill"] = g.radiusPill;
|
|
52939
|
+
if (g.borderHairline !== void 0) vars["--border-hairline"] = g.borderHairline;
|
|
52940
|
+
if (g.borderStandard !== void 0) vars["--border-standard"] = g.borderStandard;
|
|
52941
|
+
if (g.borderHeavy !== void 0) vars["--border-heavy"] = g.borderHeavy;
|
|
52942
|
+
}
|
|
52943
|
+
function resolveThemeForRuntime(theme) {
|
|
52944
|
+
if (theme === void 0) return void 0;
|
|
52945
|
+
if (typeof theme === "string") return void 0;
|
|
52946
|
+
return theme;
|
|
52947
|
+
}
|
|
52948
|
+
function OrbitalThemeProvider({ theme, children }) {
|
|
52949
|
+
const resolved = resolveThemeForRuntime(theme);
|
|
52950
|
+
const { resolvedMode } = useTheme();
|
|
52951
|
+
if (!resolved) {
|
|
52952
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
52953
|
+
}
|
|
52954
|
+
const vars = themeTokensToCssVars(resolved.tokens, resolvedMode, resolved.variants?.dark);
|
|
52955
|
+
return /* @__PURE__ */ jsx(
|
|
52956
|
+
"div",
|
|
52957
|
+
{
|
|
52958
|
+
"data-orbital-theme": resolved.name,
|
|
52959
|
+
style: { display: "contents", ...vars },
|
|
52960
|
+
children
|
|
52961
|
+
}
|
|
52962
|
+
);
|
|
52963
|
+
}
|
|
52964
|
+
OrbitalThemeProvider.displayName = "OrbitalThemeProvider";
|
|
52965
|
+
var CurrentPagePathContext = createContext(void 0);
|
|
52966
|
+
var CurrentPagePathProvider = ({
|
|
52967
|
+
value,
|
|
52968
|
+
children
|
|
52969
|
+
}) => /* @__PURE__ */ jsx(CurrentPagePathContext.Provider, { value, children });
|
|
52970
|
+
CurrentPagePathProvider.displayName = "CurrentPagePathProvider";
|
|
52971
|
+
var useCurrentPagePath2 = () => useContext(CurrentPagePathContext);
|
|
52972
|
+
var ANONYMOUS_USER = {
|
|
52973
|
+
id: "anonymous",
|
|
52974
|
+
role: "anonymous",
|
|
52975
|
+
permissions: []
|
|
52976
|
+
};
|
|
52977
|
+
var UserContext = createContext(null);
|
|
52978
|
+
function UserProvider({
|
|
52979
|
+
user = null,
|
|
52980
|
+
children
|
|
52981
|
+
}) {
|
|
52982
|
+
const hasRole = useCallback(
|
|
52983
|
+
(role) => {
|
|
52984
|
+
if (!user) return role === "anonymous";
|
|
52985
|
+
return user.role === role;
|
|
52986
|
+
},
|
|
52987
|
+
[user]
|
|
52988
|
+
);
|
|
52989
|
+
const hasPermission = useCallback(
|
|
52990
|
+
(permission) => {
|
|
52991
|
+
if (!user) return false;
|
|
52992
|
+
return user.permissions?.includes(permission) ?? false;
|
|
52993
|
+
},
|
|
52994
|
+
[user]
|
|
52995
|
+
);
|
|
52996
|
+
const hasAnyRole = useCallback(
|
|
52997
|
+
(roles) => {
|
|
52998
|
+
if (!user) return roles.includes("anonymous");
|
|
52999
|
+
return user.role ? roles.includes(user.role) : false;
|
|
53000
|
+
},
|
|
53001
|
+
[user]
|
|
53002
|
+
);
|
|
53003
|
+
const hasAllPermissions = useCallback(
|
|
53004
|
+
(permissions) => {
|
|
53005
|
+
if (!user || !user.permissions) return false;
|
|
53006
|
+
return permissions.every((p2) => user.permissions?.includes(p2));
|
|
53007
|
+
},
|
|
53008
|
+
[user]
|
|
53009
|
+
);
|
|
53010
|
+
const getUserField = useCallback(
|
|
53011
|
+
(path) => {
|
|
53012
|
+
const userData = user ?? ANONYMOUS_USER;
|
|
53013
|
+
const parts = path.split(".");
|
|
53014
|
+
let value = userData;
|
|
53015
|
+
for (const segment of parts) {
|
|
53016
|
+
if (value === null || value === void 0) {
|
|
53017
|
+
return void 0;
|
|
53018
|
+
}
|
|
53019
|
+
if (typeof value === "object") {
|
|
53020
|
+
value = value[segment];
|
|
53021
|
+
} else {
|
|
53022
|
+
return void 0;
|
|
53023
|
+
}
|
|
53024
|
+
}
|
|
53025
|
+
return value;
|
|
53026
|
+
},
|
|
53027
|
+
[user]
|
|
53028
|
+
);
|
|
53029
|
+
const contextValue = useMemo(
|
|
53030
|
+
() => ({
|
|
53031
|
+
user,
|
|
53032
|
+
isLoggedIn: user !== null,
|
|
53033
|
+
hasRole,
|
|
53034
|
+
hasPermission,
|
|
53035
|
+
hasAnyRole,
|
|
53036
|
+
hasAllPermissions,
|
|
53037
|
+
getUserField
|
|
53038
|
+
}),
|
|
53039
|
+
[user, hasRole, hasPermission, hasAnyRole, hasAllPermissions, getUserField]
|
|
53040
|
+
);
|
|
53041
|
+
return /* @__PURE__ */ jsx(UserContext.Provider, { value: contextValue, children });
|
|
53042
|
+
}
|
|
53043
|
+
function useUser() {
|
|
53044
|
+
const context = useContext(UserContext);
|
|
53045
|
+
if (!context) {
|
|
53046
|
+
return {
|
|
53047
|
+
user: null,
|
|
53048
|
+
isLoggedIn: false,
|
|
53049
|
+
hasRole: (role) => role === "anonymous",
|
|
53050
|
+
hasPermission: () => false,
|
|
53051
|
+
hasAnyRole: (roles) => roles.includes("anonymous"),
|
|
53052
|
+
hasAllPermissions: () => false,
|
|
53053
|
+
getUserField: () => void 0
|
|
53054
|
+
};
|
|
53055
|
+
}
|
|
53056
|
+
return context;
|
|
53057
|
+
}
|
|
53058
|
+
function useHasRole(role) {
|
|
53059
|
+
const { hasRole } = useUser();
|
|
53060
|
+
return hasRole(role);
|
|
53061
|
+
}
|
|
53062
|
+
function useHasPermission(permission) {
|
|
53063
|
+
const { hasPermission } = useUser();
|
|
53064
|
+
return hasPermission(permission);
|
|
53065
|
+
}
|
|
53066
|
+
function useUserForEvaluation() {
|
|
53067
|
+
const { user, isLoggedIn } = useUser();
|
|
53068
|
+
return isLoggedIn && user ? user : void 0;
|
|
53069
|
+
}
|
|
52731
53070
|
var TraitScopeContext = createContext(null);
|
|
52732
53071
|
function TraitScopeProvider3({
|
|
52733
53072
|
orbital,
|
|
@@ -52773,4 +53112,4 @@ function useOptionalOfflineMode() {
|
|
|
52773
53112
|
return useContext(OfflineModeContext);
|
|
52774
53113
|
}
|
|
52775
53114
|
|
|
52776
|
-
export { EventBusContext2 as EventBusContext, EventBusProvider, OfflineModeProvider, OrbitalProvider, SelectionContext, SelectionProvider, TraitScopeProvider3 as TraitScopeProvider, VerificationProvider, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useTraitScope2 as useTraitScope };
|
|
53115
|
+
export { ANONYMOUS_USER, CurrentPagePathContext, CurrentPagePathProvider, EventBusContext2 as EventBusContext, EventBusProvider, OfflineModeProvider, OrbitalProvider, OrbitalThemeProvider, SelectionContext, SelectionProvider, TraitScopeProvider3 as TraitScopeProvider, UserContext, UserProvider, VerificationProvider, useCurrentPagePath2 as useCurrentPagePath, useHasPermission, useHasRole, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useTraitScope2 as useTraitScope, useUser, useUserForEvaluation };
|