@mindees/atlas 0.3.0 → 0.4.0
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/a11y.d.ts +17 -5
- package/dist/a11y.d.ts.map +1 -1
- package/dist/a11y.js +29 -9
- package/dist/a11y.js.map +1 -1
- package/dist/components.d.ts.map +1 -1
- package/dist/components.js +10 -3
- package/dist/components.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/overlay.d.ts +43 -0
- package/dist/overlay.d.ts.map +1 -0
- package/dist/overlay.js +88 -0
- package/dist/overlay.js.map +1 -0
- package/package.json +3 -3
package/dist/a11y.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ interface A11yState {
|
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
selected?: boolean;
|
|
16
16
|
checked?: boolean;
|
|
17
|
+
pressed?: boolean;
|
|
17
18
|
expanded?: boolean;
|
|
18
19
|
busy?: boolean;
|
|
19
20
|
hidden?: boolean;
|
|
@@ -30,14 +31,25 @@ interface A11yProps {
|
|
|
30
31
|
describedBy?: string;
|
|
31
32
|
/** Live-region politeness (`aria-live`). */
|
|
32
33
|
live?: 'off' | 'polite' | 'assertive';
|
|
33
|
-
/**
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Accessibility state → `aria-*`. Pass an **accessor** (`() => ({ checked: on() })`) to make the
|
|
36
|
+
* `aria-*` attributes reactive — a static object bakes them once, so a screen reader never hears
|
|
37
|
+
* a toggle change. Reactive keys are those present on the first read (stable shape).
|
|
38
|
+
*/
|
|
39
|
+
state?: A11yState | (() => A11yState);
|
|
40
|
+
/** Current value of a range widget (`aria-valuenow`); accessor → reactive. */
|
|
41
|
+
valueNow?: number | (() => number);
|
|
42
|
+
/** Minimum of a range widget (`aria-valuemin`). */
|
|
43
|
+
valueMin?: number;
|
|
44
|
+
/** Maximum of a range widget (`aria-valuemax`). */
|
|
45
|
+
valueMax?: number;
|
|
35
46
|
}
|
|
36
47
|
/**
|
|
37
|
-
* Lower {@link A11yProps} to a host prop bag of `role` + `aria-*` (only keys
|
|
38
|
-
*
|
|
48
|
+
* Lower {@link A11yProps} to a host prop bag of `role` + `aria-*` (only defined keys, so omitted
|
|
49
|
+
* props stay omitted). Accessor-valued `state`/`valueNow` lower to **reactive** attribute bindings
|
|
50
|
+
* (the renderer re-applies them via `setProp`), so accessibility tracks state changes.
|
|
39
51
|
*/
|
|
40
|
-
declare function toA11yProps(a11y: A11yProps): Record<string,
|
|
52
|
+
declare function toA11yProps(a11y: A11yProps): Record<string, unknown>;
|
|
41
53
|
//#endregion
|
|
42
54
|
export { A11yProps, A11yState, Role, toA11yProps };
|
|
43
55
|
//# sourceMappingURL=a11y.d.ts.map
|
package/dist/a11y.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a11y.d.ts","names":[],"sources":["../src/a11y.ts"],"mappings":";;AAUA;;;;AAAgB;AAuBhB;;;KAvBY,IAAA;;UAuBK,SAAA;EACf,QAAA;EACA,QAAA;EACA,OAAA;EACA,QAAA;EACA,IAAA;EACA,MAAA;AAAA;;
|
|
1
|
+
{"version":3,"file":"a11y.d.ts","names":[],"sources":["../src/a11y.ts"],"mappings":";;AAUA;;;;AAAgB;AAuBhB;;;KAvBY,IAAA;;UAuBK,SAAA;EACf,QAAA;EACA,QAAA;EACA,OAAA;EACA,OAAA;EACA,QAAA;EACA,IAAA;EACA,MAAA;AAAA;;UAee,SAAA;EAER;EAAP,IAAA,GAAO,IAAA;EAcoB;EAZ3B,KAAA;EAYoC;EAVpC,UAAA;EAJO;EAMP,WAAA;EAFA;EAIA,IAAA;EAAA;;;;;EAMA,KAAA,GAAQ,SAAA,UAAmB,SAAA;EAM3B;EAJA,QAAA;EAIQ;EAFR,QAAA;EAUyB;EARzB,QAAA;AAAA;;;;;AAQkD;iBAApC,WAAA,CAAY,IAAA,EAAM,SAAA,GAAY,MAAM"}
|
package/dist/a11y.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
//#region src/a11y.ts
|
|
2
|
+
/** The boolean state keys, paired with their `aria-*` attribute. */
|
|
3
|
+
const STATE_ARIA = [
|
|
4
|
+
["disabled", "aria-disabled"],
|
|
5
|
+
["selected", "aria-selected"],
|
|
6
|
+
["checked", "aria-checked"],
|
|
7
|
+
["pressed", "aria-pressed"],
|
|
8
|
+
["expanded", "aria-expanded"],
|
|
9
|
+
["busy", "aria-busy"],
|
|
10
|
+
["hidden", "aria-hidden"]
|
|
11
|
+
];
|
|
2
12
|
/**
|
|
3
|
-
* Lower {@link A11yProps} to a host prop bag of `role` + `aria-*` (only keys
|
|
4
|
-
*
|
|
13
|
+
* Lower {@link A11yProps} to a host prop bag of `role` + `aria-*` (only defined keys, so omitted
|
|
14
|
+
* props stay omitted). Accessor-valued `state`/`valueNow` lower to **reactive** attribute bindings
|
|
15
|
+
* (the renderer re-applies them via `setProp`), so accessibility tracks state changes.
|
|
5
16
|
*/
|
|
6
17
|
function toA11yProps(a11y) {
|
|
7
18
|
const out = {};
|
|
@@ -11,14 +22,23 @@ function toA11yProps(a11y) {
|
|
|
11
22
|
if (a11y.describedBy !== void 0) out["aria-describedby"] = a11y.describedBy;
|
|
12
23
|
if (a11y.live !== void 0) out["aria-live"] = a11y.live;
|
|
13
24
|
const s = a11y.state;
|
|
14
|
-
if (s) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
if (typeof s === "function") {
|
|
26
|
+
const initial = s();
|
|
27
|
+
for (const [key, attr] of STATE_ARIA) {
|
|
28
|
+
if (initial[key] === void 0) continue;
|
|
29
|
+
out[attr] = () => {
|
|
30
|
+
const v = s()[key];
|
|
31
|
+
return v === void 0 ? void 0 : String(v);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
} else if (s) {
|
|
35
|
+
for (const [key, attr] of STATE_ARIA) if (s[key] !== void 0) out[attr] = String(s[key]);
|
|
21
36
|
}
|
|
37
|
+
if (a11y.valueMin !== void 0) out["aria-valuemin"] = String(a11y.valueMin);
|
|
38
|
+
if (a11y.valueMax !== void 0) out["aria-valuemax"] = String(a11y.valueMax);
|
|
39
|
+
const vn = a11y.valueNow;
|
|
40
|
+
if (typeof vn === "function") out["aria-valuenow"] = () => String(vn());
|
|
41
|
+
else if (vn !== void 0) out["aria-valuenow"] = String(vn);
|
|
22
42
|
return out;
|
|
23
43
|
}
|
|
24
44
|
//#endregion
|
package/dist/a11y.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a11y.js","names":[],"sources":["../src/a11y.ts"],"sourcesContent":["/**\n * Atlas accessibility — a single typed `A11yProps` surface lowered to `role` + `aria-*`\n * attribute props. The DOM backend passes these through verbatim (`setAttribute`), so web a11y\n * is real; native hosts receive them as serialized props (interpretation is a 🔬 research-track\n * host concern — carried, never silently dropped). See `docs/adr/0022-atlas-primitives.md`.\n *\n * @module\n */\n\n/** A WAI-ARIA-ish role, mapped straight to the host `role` attribute on web. */\nexport type Role =\n | 'button'\n | 'link'\n | 'image'\n | 'heading'\n | 'list'\n | 'listitem'\n | 'text'\n | 'textbox'\n | 'checkbox'\n | 'switch'\n | 'radio'\n | 'tab'\n | 'tabpanel'\n | 'dialog'\n | 'alert'\n | 'status'\n | 'separator'\n | 'progressbar'\n | 'none'\n | 'presentation'\n\n/** Accessibility state, lowered to the matching `aria-*` attributes. */\nexport interface A11yState {\n disabled?: boolean\n selected?: boolean\n checked?: boolean\n expanded?: boolean\n busy?: boolean\n hidden?: boolean\n}\n\n/** The accessibility surface every Atlas primitive accepts. */\nexport interface A11yProps {\n /** ARIA role (web `role`). */\n role?: Role\n /** Accessible name (`aria-label`). */\n label?: string\n /** Id(s) of the element(s) labelling this one (`aria-labelledby`). */\n labelledBy?: string\n /** Id(s) of the element(s) describing this one (`aria-describedby`). */\n describedBy?: string\n /** Live-region politeness (`aria-live`). */\n live?: 'off' | 'polite' | 'assertive'\n
|
|
1
|
+
{"version":3,"file":"a11y.js","names":[],"sources":["../src/a11y.ts"],"sourcesContent":["/**\n * Atlas accessibility — a single typed `A11yProps` surface lowered to `role` + `aria-*`\n * attribute props. The DOM backend passes these through verbatim (`setAttribute`), so web a11y\n * is real; native hosts receive them as serialized props (interpretation is a 🔬 research-track\n * host concern — carried, never silently dropped). See `docs/adr/0022-atlas-primitives.md`.\n *\n * @module\n */\n\n/** A WAI-ARIA-ish role, mapped straight to the host `role` attribute on web. */\nexport type Role =\n | 'button'\n | 'link'\n | 'image'\n | 'heading'\n | 'list'\n | 'listitem'\n | 'text'\n | 'textbox'\n | 'checkbox'\n | 'switch'\n | 'radio'\n | 'tab'\n | 'tabpanel'\n | 'dialog'\n | 'alert'\n | 'status'\n | 'separator'\n | 'progressbar'\n | 'none'\n | 'presentation'\n\n/** Accessibility state, lowered to the matching `aria-*` attributes. */\nexport interface A11yState {\n disabled?: boolean\n selected?: boolean\n checked?: boolean\n pressed?: boolean\n expanded?: boolean\n busy?: boolean\n hidden?: boolean\n}\n\n/** The boolean state keys, paired with their `aria-*` attribute. */\nconst STATE_ARIA = [\n ['disabled', 'aria-disabled'],\n ['selected', 'aria-selected'],\n ['checked', 'aria-checked'],\n ['pressed', 'aria-pressed'],\n ['expanded', 'aria-expanded'],\n ['busy', 'aria-busy'],\n ['hidden', 'aria-hidden'],\n] as const\n\n/** The accessibility surface every Atlas primitive accepts. */\nexport interface A11yProps {\n /** ARIA role (web `role`). */\n role?: Role\n /** Accessible name (`aria-label`). */\n label?: string\n /** Id(s) of the element(s) labelling this one (`aria-labelledby`). */\n labelledBy?: string\n /** Id(s) of the element(s) describing this one (`aria-describedby`). */\n describedBy?: string\n /** Live-region politeness (`aria-live`). */\n live?: 'off' | 'polite' | 'assertive'\n /**\n * Accessibility state → `aria-*`. Pass an **accessor** (`() => ({ checked: on() })`) to make the\n * `aria-*` attributes reactive — a static object bakes them once, so a screen reader never hears\n * a toggle change. Reactive keys are those present on the first read (stable shape).\n */\n state?: A11yState | (() => A11yState)\n /** Current value of a range widget (`aria-valuenow`); accessor → reactive. */\n valueNow?: number | (() => number)\n /** Minimum of a range widget (`aria-valuemin`). */\n valueMin?: number\n /** Maximum of a range widget (`aria-valuemax`). */\n valueMax?: number\n}\n\n/**\n * Lower {@link A11yProps} to a host prop bag of `role` + `aria-*` (only defined keys, so omitted\n * props stay omitted). Accessor-valued `state`/`valueNow` lower to **reactive** attribute bindings\n * (the renderer re-applies them via `setProp`), so accessibility tracks state changes.\n */\nexport function toA11yProps(a11y: A11yProps): Record<string, unknown> {\n const out: Record<string, unknown> = {}\n if (a11y.role !== undefined) out.role = a11y.role\n if (a11y.label !== undefined) out['aria-label'] = a11y.label\n if (a11y.labelledBy !== undefined) out['aria-labelledby'] = a11y.labelledBy\n if (a11y.describedBy !== undefined) out['aria-describedby'] = a11y.describedBy\n if (a11y.live !== undefined) out['aria-live'] = a11y.live\n\n const s = a11y.state\n if (typeof s === 'function') {\n const initial = s()\n for (const [key, attr] of STATE_ARIA) {\n if (initial[key] === undefined) continue\n out[attr] = () => {\n const v = s()[key]\n return v === undefined ? undefined : String(v)\n }\n }\n } else if (s) {\n for (const [key, attr] of STATE_ARIA) {\n if (s[key] !== undefined) out[attr] = String(s[key])\n }\n }\n\n if (a11y.valueMin !== undefined) out['aria-valuemin'] = String(a11y.valueMin)\n if (a11y.valueMax !== undefined) out['aria-valuemax'] = String(a11y.valueMax)\n const vn = a11y.valueNow\n if (typeof vn === 'function') out['aria-valuenow'] = () => String(vn())\n else if (vn !== undefined) out['aria-valuenow'] = String(vn)\n\n return out\n}\n"],"mappings":";;AA4CA,MAAM,aAAa;CACjB,CAAC,YAAY,eAAe;CAC5B,CAAC,YAAY,eAAe;CAC5B,CAAC,WAAW,cAAc;CAC1B,CAAC,WAAW,cAAc;CAC1B,CAAC,YAAY,eAAe;CAC5B,CAAC,Q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A,SAqNV,KAAA;EApNW;EAAA,SAsNX,SAAA;AAAA;AAAA,cAEE,iBAAA,EAAmB,SAAS,CAAC,sBAAA"}
|
package/dist/components.js
CHANGED
|
@@ -188,6 +188,10 @@ const Chip = (props) => {
|
|
|
188
188
|
return createElement(Pressable, {
|
|
189
189
|
...rest,
|
|
190
190
|
role: rest.role ?? "button",
|
|
191
|
+
state: () => ({
|
|
192
|
+
...typeof rest.state === "function" ? rest.state() : rest.state ?? {},
|
|
193
|
+
pressed: isSelected()
|
|
194
|
+
}),
|
|
191
195
|
...onPress ? { onPress } : {},
|
|
192
196
|
...disabled ? { disabled: true } : {},
|
|
193
197
|
style: mergeStyle(base, style)
|
|
@@ -219,10 +223,10 @@ const Switch = (props) => {
|
|
|
219
223
|
return createElement(Pressable, {
|
|
220
224
|
...rest,
|
|
221
225
|
role: rest.role ?? "switch",
|
|
222
|
-
state: {
|
|
223
|
-
...rest.state ?? {},
|
|
226
|
+
state: () => ({
|
|
227
|
+
...typeof rest.state === "function" ? rest.state() : rest.state ?? {},
|
|
224
228
|
checked: isOn()
|
|
225
|
-
},
|
|
229
|
+
}),
|
|
226
230
|
...disabled ? { disabled: true } : {},
|
|
227
231
|
...handlePress ? { onPress: handlePress } : {},
|
|
228
232
|
style: mergeStyle(track, style)
|
|
@@ -275,6 +279,9 @@ const ProgressBar = (props) => {
|
|
|
275
279
|
return createElement(View, {
|
|
276
280
|
...rest,
|
|
277
281
|
role: rest.role ?? "progressbar",
|
|
282
|
+
valueMin: 0,
|
|
283
|
+
valueMax: 1,
|
|
284
|
+
valueNow: () => Math.max(0, Math.min(1, progress())),
|
|
278
285
|
style: mergeStyle(track, style)
|
|
279
286
|
}, createElement(View, { style: fill }));
|
|
280
287
|
};
|
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","names":["radiusScale","radius"],"sources":["../src/components.ts"],"sourcesContent":["/**\n * Atlas components — higher-level building blocks composed purely from the primitives\n * (View/Text/Pressable/Image) + the device hooks. No new host concepts, so every one\n * renders on web *and* native today, and stays fine-grained: reactive bits are accessor\n * styles, so only the changed node re-runs (no component re-render).\n *\n * Colors come from the design tokens via {@link useTheme}, so components re-theme\n * automatically light↔dark (handbook §23/§31). Spacing/radius/type use the token scales.\n *\n * @module\n */\n\nimport { type Accessor, type Component, createElement, type MindeesNode } from '@mindees/core'\nimport { useKeyboard, useSafeAreaInsets } from './environment'\nimport { type BaseProps, type Reactive, toHostProps } from './host'\nimport { Image, Pressable, Text, View } from './primitives'\nimport { flattenStyle, type StyleInput } from './style'\nimport { fontWeight, radius as radiusScale, space, type Theme, useTheme } from './tokens'\n\n/** Merge a base style with a caller's (possibly reactive) style, staying reactive if either is. */\nfunction mergeStyle(\n base: StyleInput | Accessor<StyleInput>,\n style: Reactive<StyleInput> | undefined,\n): Reactive<StyleInput> {\n const baseFn = typeof base === 'function' ? (base as Accessor<StyleInput>) : null\n const styleFn = typeof style === 'function' ? (style as Accessor<StyleInput>) : null\n if (baseFn || styleFn) {\n // In each branch the non-fn side isn't a function, so the StyleInput cast is sound.\n const baseVal = base as StyleInput\n const styleVal = style as StyleInput\n return () => flattenStyle([baseFn ? baseFn() : baseVal, styleFn ? styleFn() : styleVal])\n }\n return flattenStyle([base as StyleInput, style as StyleInput])\n}\n\n/** Normalize a `Reactive<T>` to an accessor. */\nfunction toAccessor<T>(value: Reactive<T>, fallback: T): Accessor<T> {\n if (typeof value === 'function') return value as Accessor<T>\n return () => (value === undefined ? fallback : value)\n}\n\n// ---------------------------------------------------------------------------\n// Card\n// ---------------------------------------------------------------------------\n\n/** A surface that groups one coherent unit of content. */\nexport interface CardProps extends BaseProps {\n readonly children?: MindeesNode\n /** Visual emphasis. `elevated` (default) lifts off the bg; `filled` is a soft tint; `outlined` is a hairline. */\n readonly variant?: 'elevated' | 'filled' | 'outlined'\n /** Internal padding (handbook default 16). */\n readonly padding?: number | string\n /** Corner radius (handbook 12–16 for app cards). */\n readonly radius?: number\n}\nexport const Card: Component<CardProps> = (props) => {\n const theme = useTheme()\n const {\n variant = 'elevated',\n padding = space.md,\n radius = radiusScale.lg,\n style,\n children,\n ...rest\n } = props\n const base: Accessor<StyleInput> = () => {\n const c = theme().color\n const surface: StyleInput =\n variant === 'outlined'\n ? { borderWidth: 1, borderColor: c.border }\n : variant === 'filled'\n ? { backgroundColor: c.surfaceVariant }\n : { backgroundColor: c.surface, borderWidth: 1, borderColor: c.border }\n return { padding, borderRadius: radius, ...surface }\n }\n return createElement(View, { ...rest, style: mergeStyle(base, style) }, children)\n}\n\n// ---------------------------------------------------------------------------\n// Divider\n// ---------------------------------------------------------------------------\n\n/** A thin rule separating content. */\nexport interface DividerProps extends BaseProps {\n readonly orientation?: 'horizontal' | 'vertical'\n readonly thickness?: number\n /** Override color (defaults to the theme border). */\n readonly color?: string\n}\nexport const Divider: Component<DividerProps> = (props) => {\n const theme = useTheme()\n const { orientation = 'horizontal', thickness = 1, color, style, ...rest } = props\n const base: Accessor<StyleInput> = () => {\n const bg = color ?? theme().color.border\n return orientation === 'horizontal'\n ? { height: thickness, alignSelf: 'stretch', backgroundColor: bg }\n : { width: thickness, alignSelf: 'stretch', backgroundColor: bg }\n }\n return createElement(View, {\n ...rest,\n role: rest.role ?? 'separator',\n style: mergeStyle(base, style),\n })\n}\n\n// ---------------------------------------------------------------------------\n// Badge\n// ---------------------------------------------------------------------------\n\nexport type BadgeTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger'\n\n/** Resolve a tone to its {bg, fg} in the active theme. */\nfunction toneColors(tone: BadgeTone, theme: Theme): { bg: string; fg: string } {\n const c = theme.color\n if (tone === 'neutral') return { bg: c.surfaceVariant, fg: c.text }\n return { bg: c[tone], fg: c.onTone }\n}\n\n/** A compact status/count pill. */\nexport interface BadgeProps extends BaseProps {\n readonly children?: MindeesNode\n readonly tone?: BadgeTone\n}\nexport const Badge: Component<BadgeProps> = (props) => {\n const theme = useTheme()\n const { tone = 'neutral', style, children, ...rest } = props\n const base: Accessor<StyleInput> = () => ({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n paddingTop: space['3xs'],\n paddingBottom: space['3xs'],\n paddingLeft: space.xs,\n paddingRight: space.xs,\n borderRadius: radiusScale.full,\n backgroundColor: toneColors(tone, theme()).bg,\n })\n const textStyle: Accessor<StyleInput> = () => ({\n fontSize: 12,\n fontWeight: fontWeight.semibold,\n color: toneColors(tone, theme()).fg,\n })\n return createElement(\n View,\n { ...rest, role: rest.role ?? 'status', style: mergeStyle(base, style) },\n createElement(Text, { style: textStyle }, children),\n )\n}\n\n// ---------------------------------------------------------------------------\n// Avatar\n// ---------------------------------------------------------------------------\n\n/** Up-to-two-letter initials from a name. */\nfunction initialsOf(name: string): string {\n const parts = name.trim().split(/\\s+/).filter(Boolean)\n if (parts.length === 0) return '?'\n const first = parts[0]?.[0] ?? ''\n const last = parts.length > 1 ? (parts[parts.length - 1]?.[0] ?? '') : ''\n return (first + last).toUpperCase()\n}\n\n/** A circular user image, falling back to initials. */\nexport interface AvatarProps extends BaseProps {\n readonly src?: string\n readonly name?: string\n /** Diameter in px (default 40). */\n readonly size?: number\n}\nexport const Avatar: Component<AvatarProps> = (props) => {\n const theme = useTheme()\n const { src, name, size = 40, style, ...rest } = props\n const base: Accessor<StyleInput> = () => ({\n width: size,\n height: size,\n borderRadius: size / 2,\n overflow: 'hidden',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme().color.surfaceVariant,\n })\n const content = src\n ? createElement(Image, {\n src,\n label: name ?? '',\n ...(name ? {} : { decorative: true }),\n style: { width: size, height: size },\n })\n : createElement(\n Text,\n {\n style: () => ({\n fontSize: Math.round(size * 0.4),\n fontWeight: fontWeight.semibold,\n color: theme().color.text,\n }),\n },\n name ? initialsOf(name) : '?',\n )\n return createElement(\n View,\n { ...rest, label: rest.label ?? name, style: mergeStyle(base, style) },\n content,\n )\n}\n\n// ---------------------------------------------------------------------------\n// Chip\n// ---------------------------------------------------------------------------\n\n/** A compact, optionally-selectable token (filter/choice/input). */\nexport interface ChipProps extends Omit<BaseProps, 'style'> {\n readonly label: string\n readonly selected?: Reactive<boolean>\n readonly disabled?: boolean\n readonly onPress?: () => void\n readonly leading?: MindeesNode\n readonly trailing?: MindeesNode\n readonly style?: Reactive<StyleInput>\n}\nexport const Chip: Component<ChipProps> = (props) => {\n const theme = useTheme()\n const { label, selected = false, disabled, onPress, leading, trailing, style, ...rest } = props\n const isSelected = toAccessor(selected, false)\n const base: Accessor<StyleInput> = () => {\n const c = theme().color\n const on = isSelected()\n return {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n gap: space['2xs'],\n minHeight: 32,\n paddingTop: space['2xs'],\n paddingBottom: space['2xs'],\n paddingLeft: space.sm,\n paddingRight: space.sm,\n borderRadius: radiusScale.full,\n borderWidth: 1,\n borderColor: on ? c.primary : c.border,\n backgroundColor: on ? c.primary : 'transparent',\n opacity: disabled ? 0.5 : 1,\n }\n }\n const text = createElement(\n Text,\n {\n style: () => ({\n fontSize: 14,\n fontWeight: fontWeight.medium,\n color: isSelected() ? theme().color.onPrimary : theme().color.text,\n }),\n },\n label,\n )\n const inner: MindeesNode = [leading, text, trailing].filter((n) => n != null) as MindeesNode\n return createElement(\n Pressable,\n {\n ...rest,\n role: rest.role ?? 'button',\n ...(onPress ? { onPress } : {}),\n ...(disabled ? { disabled: true } : {}),\n style: mergeStyle(base, style),\n },\n inner,\n )\n}\n\n// ---------------------------------------------------------------------------\n// Switch\n// ---------------------------------------------------------------------------\n\n/** A binary on/off toggle (composed track + knob; flips instantly on press). */\nexport interface SwitchProps extends Omit<BaseProps, 'style'> {\n /** Controlled state (static or reactive). */\n readonly value: Reactive<boolean>\n readonly onValueChange?: (value: boolean) => void\n readonly disabled?: boolean\n readonly style?: Reactive<StyleInput>\n}\nexport const Switch: Component<SwitchProps> = (props) => {\n const theme = useTheme()\n const { value, onValueChange, disabled, style, ...rest } = props\n const isOn = toAccessor(value, false)\n const track: Accessor<StyleInput> = () => ({\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: isOn() ? 'flex-end' : 'flex-start',\n width: 52,\n height: 32,\n borderRadius: radiusScale.full,\n padding: 3,\n backgroundColor: isOn() ? theme().color.primary : theme().color.textMuted,\n opacity: disabled ? 0.5 : 1,\n })\n const knob = createElement(View, {\n style: () => ({\n width: 26,\n height: 26,\n borderRadius: 13,\n backgroundColor: theme().color.onPrimary,\n }),\n })\n const handlePress = onValueChange && !disabled ? () => onValueChange(!isOn()) : undefined\n return createElement(\n Pressable,\n {\n ...rest,\n role: rest.role ?? 'switch',\n state: { ...(rest.state ?? {}), checked: isOn() },\n ...(disabled ? { disabled: true } : {}),\n ...(handlePress ? { onPress: handlePress } : {}),\n style: mergeStyle(track, style),\n },\n knob,\n )\n}\n\n// ---------------------------------------------------------------------------\n// SafeAreaView\n// ---------------------------------------------------------------------------\n\n/** A container that pads itself by the live safe-area insets (notch, home indicator, …). */\nexport interface SafeAreaViewProps extends BaseProps {\n readonly children?: MindeesNode\n /** Which edges to inset (default: all four). */\n readonly edges?: ReadonlyArray<'top' | 'right' | 'bottom' | 'left'>\n}\nexport const SafeAreaView: Component<SafeAreaViewProps> = (props) => {\n const insets = useSafeAreaInsets()\n const { edges, style, children, ...rest } = props\n const wants = (edge: 'top' | 'right' | 'bottom' | 'left'): boolean =>\n !edges || edges.includes(edge)\n const base: Accessor<StyleInput> = () => {\n const i = insets()\n return {\n paddingTop: wants('top') ? i.top : 0,\n paddingRight: wants('right') ? i.right : 0,\n paddingBottom: wants('bottom') ? i.bottom : 0,\n paddingLeft: wants('left') ? i.left : 0,\n }\n }\n return createElement(View, { ...rest, style: mergeStyle(base, style) }, children)\n}\n\n// ---------------------------------------------------------------------------\n// KeyboardAvoidingView\n// ---------------------------------------------------------------------------\n\n/** A container that pads its bottom by the live keyboard height so content stays visible. */\nexport interface KeyboardAvoidingViewProps extends BaseProps {\n readonly children?: MindeesNode\n}\nexport const KeyboardAvoidingView: Component<KeyboardAvoidingViewProps> = (props) => {\n const keyboard = useKeyboard()\n const { style, children, ...rest } = props\n const base: Accessor<StyleInput> = () => ({ paddingBottom: keyboard().height })\n return createElement(View, { ...rest, style: mergeStyle(base, style) }, children)\n}\n\n// ---------------------------------------------------------------------------\n// ProgressBar (determinate)\n// ---------------------------------------------------------------------------\n\n/** A determinate progress bar (track + reactive fill). */\nexport interface ProgressBarProps extends BaseProps {\n /** Progress 0..1 (static or reactive). Values outside the range are clamped. */\n readonly value?: Reactive<number>\n readonly trackColor?: string\n readonly color?: string\n readonly height?: number\n}\nexport const ProgressBar: Component<ProgressBarProps> = (props) => {\n const theme = useTheme()\n const { value = 0, trackColor, color, height = 6, style, ...rest } = props\n const progress = toAccessor(value, 0)\n const track: Accessor<StyleInput> = () => ({\n width: '100%',\n height,\n borderRadius: height / 2,\n overflow: 'hidden',\n backgroundColor: trackColor ?? theme().color.surfaceVariant,\n })\n const fill: Accessor<StyleInput> = () => ({\n height,\n borderRadius: height / 2,\n backgroundColor: color ?? theme().color.primary,\n width: `${Math.max(0, Math.min(1, progress())) * 100}%`,\n })\n return createElement(\n View,\n { ...rest, role: rest.role ?? 'progressbar', style: mergeStyle(track, style) },\n createElement(View, { style: fill }),\n )\n}\n\n// ---------------------------------------------------------------------------\n// ActivityIndicator\n// ---------------------------------------------------------------------------\n\n/**\n * A spinning loading indicator. Emits the `activityindicator` host tag, which each backend\n * renders natively: web → a CSS keyframe spinner (size from `width`/`height`, arc from `color`),\n * Android → an indeterminate `ProgressBar`. Size/color flow through ordinary style keys.\n */\nexport interface ActivityIndicatorProps extends BaseProps {\n /** Diameter in px (default 24). */\n readonly size?: number\n /** Spinner color (defaults to the theme primary). */\n readonly color?: string\n /** When false, renders nothing (so callers can gate it without a conditional). */\n readonly animating?: boolean\n}\nexport const ActivityIndicator: Component<ActivityIndicatorProps> = (props) => {\n const theme = useTheme()\n const { size = 24, color, animating = true, style, ...rest } = props\n if (animating === false) return null\n const base: Accessor<StyleInput> = () => ({\n width: size,\n height: size,\n color: color ?? theme().color.primary,\n })\n const host = toHostProps({ ...rest, style: mergeStyle(base, style) })\n if (!host.role) host.role = 'status'\n host['aria-busy'] = 'true'\n return createElement('activityindicator', host)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,SAAS,WACP,MACA,OACsB;CACtB,MAAM,SAAS,OAAO,SAAS,aAAc,OAAgC;CAC7E,MAAM,UAAU,OAAO,UAAU,aAAc,QAAiC;CAChF,IAAI,UAAU,SAAS;EAErB,MAAM,UAAU;EAChB,MAAM,WAAW;EACjB,aAAa,aAAa,CAAC,SAAS,OAAO,IAAI,SAAS,UAAU,QAAQ,IAAI,QAAQ,CAAC;CACzF;CACA,OAAO,aAAa,CAAC,MAAoB,KAAmB,CAAC;AAC/D;;AAGA,SAAS,WAAc,OAAoB,UAA0B;CACnE,IAAI,OAAO,UAAU,YAAY,OAAO;CACxC,aAAc,UAAU,KAAA,IAAY,WAAW;AACjD;AAgBA,MAAa,QAA8B,UAAU;CACnD,MAAM,QAAQ,SAAS;CACvB,MAAM,EACJ,UAAU,YACV,UAAU,MAAM,IAChB,QAAA,WAASA,OAAY,IACrB,OACA,UACA,GAAG,SACD;CACJ,MAAM,aAAmC;EACvC,MAAM,IAAI,MAAM,EAAE;EAOlB,OAAO;GAAE;GAAS,cAAcC;GAAQ,GALtC,YAAY,aACR;IAAE,aAAa;IAAG,aAAa,EAAE;GAAO,IACxC,YAAY,WACV,EAAE,iBAAiB,EAAE,eAAe,IACpC;IAAE,iBAAiB,EAAE;IAAS,aAAa;IAAG,aAAa,EAAE;GAAO;EACzB;CACrD;CACA,OAAO,cAAc,MAAM;EAAE,GAAG;EAAM,OAAO,WAAW,MAAM,KAAK;CAAE,GAAG,QAAQ;AAClF;AAaA,MAAa,WAAoC,UAAU;CACzD,MAAM,QAAQ,SAAS;CACvB,MAAM,EAAE,cAAc,cAAc,YAAY,GAAG,OAAO,OAAO,GAAG,SAAS;CA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CACvD;CACA,OAAO,cACL,MACA;EAAE,GAAG;EAAM,MAAM,KAAK,QAAQ;EAAe,OAAO,WAAW,OAAO,KAAK;CAAE,GAC7E,cAAc,MAAM,EAAE,OAAO,KAAK,CAAC,CACrC;AACF;AAmBA,MAAa,qBAAwD,UAAU;CAC7E,MAAM,QAAQ,SAAS;CACvB,MAAM,EAAE,OAAO,IAAI,OAAO,YAAY,MAAM,OAAO,GAAG,SAAS;CAC/D,IAAI,cAAc,OAAO,OAAO;CAChC,MAAM,cAAoC;EACxC,OAAO;EACP,QAAQ;EACR,OAAO,SAAS,MAAM,EAAE,MAAM;CAChC;CACA,MAAM,OAAO,YAAY;EAAE,GAAG;EAAM,OAAO,WAAW,MAAM,KAAK;CAAE,CAAC;CACpE,IAAI,CAAC,KAAK,MAAM,KAAK,OAAO;CAC5B,KAAK,eAAe;CACpB,OAAO,cAAc,qBAAqB,IAAI;AAChD"}
|
|
1
|
+
{"version":3,"file":"components.js","names":["radiusScale","radius"],"sources":["../src/components.ts"],"sourcesContent":["/**\n * Atlas components — higher-level building blocks composed purely from the primitives\n * (View/Text/Pressable/Image) + the device hooks. No new host concepts, so every one\n * renders on web *and* native today, and stays fine-grained: reactive bits are accessor\n * styles, so only the changed node re-runs (no component re-render).\n *\n * Colors come from the design tokens via {@link useTheme}, so components re-theme\n * automatically light↔dark (handbook §23/§31). Spacing/radius/type use the token scales.\n *\n * @module\n */\n\nimport { type Accessor, type Component, createElement, type MindeesNode } from '@mindees/core'\nimport { useKeyboard, useSafeAreaInsets } from './environment'\nimport { type BaseProps, type Reactive, toHostProps } from './host'\nimport { Image, Pressable, Text, View } from './primitives'\nimport { flattenStyle, type StyleInput } from './style'\nimport { fontWeight, radius as radiusScale, space, type Theme, useTheme } from './tokens'\n\n/** Merge a base style with a caller's (possibly reactive) style, staying reactive if either is. */\nfunction mergeStyle(\n base: StyleInput | Accessor<StyleInput>,\n style: Reactive<StyleInput> | undefined,\n): Reactive<StyleInput> {\n const baseFn = typeof base === 'function' ? (base as Accessor<StyleInput>) : null\n const styleFn = typeof style === 'function' ? (style as Accessor<StyleInput>) : null\n if (baseFn || styleFn) {\n // In each branch the non-fn side isn't a function, so the StyleInput cast is sound.\n const baseVal = base as StyleInput\n const styleVal = style as StyleInput\n return () => flattenStyle([baseFn ? baseFn() : baseVal, styleFn ? styleFn() : styleVal])\n }\n return flattenStyle([base as StyleInput, style as StyleInput])\n}\n\n/** Normalize a `Reactive<T>` to an accessor. */\nfunction toAccessor<T>(value: Reactive<T>, fallback: T): Accessor<T> {\n if (typeof value === 'function') return value as Accessor<T>\n return () => (value === undefined ? fallback : value)\n}\n\n// ---------------------------------------------------------------------------\n// Card\n// ---------------------------------------------------------------------------\n\n/** A surface that groups one coherent unit of content. */\nexport interface CardProps extends BaseProps {\n readonly children?: MindeesNode\n /** Visual emphasis. `elevated` (default) lifts off the bg; `filled` is a soft tint; `outlined` is a hairline. */\n readonly variant?: 'elevated' | 'filled' | 'outlined'\n /** Internal padding (handbook default 16). */\n readonly padding?: number | string\n /** Corner radius (handbook 12–16 for app cards). */\n readonly radius?: number\n}\nexport const Card: Component<CardProps> = (props) => {\n const theme = useTheme()\n const {\n variant = 'elevated',\n padding = space.md,\n radius = radiusScale.lg,\n style,\n children,\n ...rest\n } = props\n const base: Accessor<StyleInput> = () => {\n const c = theme().color\n const surface: StyleInput =\n variant === 'outlined'\n ? { borderWidth: 1, borderColor: c.border }\n : variant === 'filled'\n ? { backgroundColor: c.surfaceVariant }\n : { backgroundColor: c.surface, borderWidth: 1, borderColor: c.border }\n return { padding, borderRadius: radius, ...surface }\n }\n return createElement(View, { ...rest, style: mergeStyle(base, style) }, children)\n}\n\n// ---------------------------------------------------------------------------\n// Divider\n// ---------------------------------------------------------------------------\n\n/** A thin rule separating content. */\nexport interface DividerProps extends BaseProps {\n readonly orientation?: 'horizontal' | 'vertical'\n readonly thickness?: number\n /** Override color (defaults to the theme border). */\n readonly color?: string\n}\nexport const Divider: Component<DividerProps> = (props) => {\n const theme = useTheme()\n const { orientation = 'horizontal', thickness = 1, color, style, ...rest } = props\n const base: Accessor<StyleInput> = () => {\n const bg = color ?? theme().color.border\n return orientation === 'horizontal'\n ? { height: thickness, alignSelf: 'stretch', backgroundColor: bg }\n : { width: thickness, alignSelf: 'stretch', backgroundColor: bg }\n }\n return createElement(View, {\n ...rest,\n role: rest.role ?? 'separator',\n style: mergeStyle(base, style),\n })\n}\n\n// ---------------------------------------------------------------------------\n// Badge\n// ---------------------------------------------------------------------------\n\nexport type BadgeTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger'\n\n/** Resolve a tone to its {bg, fg} in the active theme. */\nfunction toneColors(tone: BadgeTone, theme: Theme): { bg: string; fg: string } {\n const c = theme.color\n if (tone === 'neutral') return { bg: c.surfaceVariant, fg: c.text }\n return { bg: c[tone], fg: c.onTone }\n}\n\n/** A compact status/count pill. */\nexport interface BadgeProps extends BaseProps {\n readonly children?: MindeesNode\n readonly tone?: BadgeTone\n}\nexport const Badge: Component<BadgeProps> = (props) => {\n const theme = useTheme()\n const { tone = 'neutral', style, children, ...rest } = props\n const base: Accessor<StyleInput> = () => ({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n paddingTop: space['3xs'],\n paddingBottom: space['3xs'],\n paddingLeft: space.xs,\n paddingRight: space.xs,\n borderRadius: radiusScale.full,\n backgroundColor: toneColors(tone, theme()).bg,\n })\n const textStyle: Accessor<StyleInput> = () => ({\n fontSize: 12,\n fontWeight: fontWeight.semibold,\n color: toneColors(tone, theme()).fg,\n })\n return createElement(\n View,\n { ...rest, role: rest.role ?? 'status', style: mergeStyle(base, style) },\n createElement(Text, { style: textStyle }, children),\n )\n}\n\n// ---------------------------------------------------------------------------\n// Avatar\n// ---------------------------------------------------------------------------\n\n/** Up-to-two-letter initials from a name. */\nfunction initialsOf(name: string): string {\n const parts = name.trim().split(/\\s+/).filter(Boolean)\n if (parts.length === 0) return '?'\n const first = parts[0]?.[0] ?? ''\n const last = parts.length > 1 ? (parts[parts.length - 1]?.[0] ?? '') : ''\n return (first + last).toUpperCase()\n}\n\n/** A circular user image, falling back to initials. */\nexport interface AvatarProps extends BaseProps {\n readonly src?: string\n readonly name?: string\n /** Diameter in px (default 40). */\n readonly size?: number\n}\nexport const Avatar: Component<AvatarProps> = (props) => {\n const theme = useTheme()\n const { src, name, size = 40, style, ...rest } = props\n const base: Accessor<StyleInput> = () => ({\n width: size,\n height: size,\n borderRadius: size / 2,\n overflow: 'hidden',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme().color.surfaceVariant,\n })\n const content = src\n ? createElement(Image, {\n src,\n label: name ?? '',\n ...(name ? {} : { decorative: true }),\n style: { width: size, height: size },\n })\n : createElement(\n Text,\n {\n style: () => ({\n fontSize: Math.round(size * 0.4),\n fontWeight: fontWeight.semibold,\n color: theme().color.text,\n }),\n },\n name ? initialsOf(name) : '?',\n )\n return createElement(\n View,\n { ...rest, label: rest.label ?? name, style: mergeStyle(base, style) },\n content,\n )\n}\n\n// ---------------------------------------------------------------------------\n// Chip\n// ---------------------------------------------------------------------------\n\n/** A compact, optionally-selectable token (filter/choice/input). */\nexport interface ChipProps extends Omit<BaseProps, 'style'> {\n readonly label: string\n readonly selected?: Reactive<boolean>\n readonly disabled?: boolean\n readonly onPress?: () => void\n readonly leading?: MindeesNode\n readonly trailing?: MindeesNode\n readonly style?: Reactive<StyleInput>\n}\nexport const Chip: Component<ChipProps> = (props) => {\n const theme = useTheme()\n const { label, selected = false, disabled, onPress, leading, trailing, style, ...rest } = props\n const isSelected = toAccessor(selected, false)\n const base: Accessor<StyleInput> = () => {\n const c = theme().color\n const on = isSelected()\n return {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n gap: space['2xs'],\n minHeight: 32,\n paddingTop: space['2xs'],\n paddingBottom: space['2xs'],\n paddingLeft: space.sm,\n paddingRight: space.sm,\n borderRadius: radiusScale.full,\n borderWidth: 1,\n borderColor: on ? c.primary : c.border,\n backgroundColor: on ? c.primary : 'transparent',\n opacity: disabled ? 0.5 : 1,\n }\n }\n const text = createElement(\n Text,\n {\n style: () => ({\n fontSize: 14,\n fontWeight: fontWeight.medium,\n color: isSelected() ? theme().color.onPrimary : theme().color.text,\n }),\n },\n label,\n )\n const inner: MindeesNode = [leading, text, trailing].filter((n) => n != null) as MindeesNode\n return createElement(\n Pressable,\n {\n ...rest,\n role: rest.role ?? 'button',\n // Reactive `aria-pressed` so a toggle chip announces its selected state as it changes.\n state: () => ({\n ...(typeof rest.state === 'function' ? rest.state() : (rest.state ?? {})),\n pressed: isSelected(),\n }),\n ...(onPress ? { onPress } : {}),\n ...(disabled ? { disabled: true } : {}),\n style: mergeStyle(base, style),\n },\n inner,\n )\n}\n\n// ---------------------------------------------------------------------------\n// Switch\n// ---------------------------------------------------------------------------\n\n/** A binary on/off toggle (composed track + knob; flips instantly on press). */\nexport interface SwitchProps extends Omit<BaseProps, 'style'> {\n /** Controlled state (static or reactive). */\n readonly value: Reactive<boolean>\n readonly onValueChange?: (value: boolean) => void\n readonly disabled?: boolean\n readonly style?: Reactive<StyleInput>\n}\nexport const Switch: Component<SwitchProps> = (props) => {\n const theme = useTheme()\n const { value, onValueChange, disabled, style, ...rest } = props\n const isOn = toAccessor(value, false)\n const track: Accessor<StyleInput> = () => ({\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: isOn() ? 'flex-end' : 'flex-start',\n width: 52,\n height: 32,\n borderRadius: radiusScale.full,\n padding: 3,\n backgroundColor: isOn() ? theme().color.primary : theme().color.textMuted,\n opacity: disabled ? 0.5 : 1,\n })\n const knob = createElement(View, {\n style: () => ({\n width: 26,\n height: 26,\n borderRadius: 13,\n backgroundColor: theme().color.onPrimary,\n }),\n })\n const handlePress = onValueChange && !disabled ? () => onValueChange(!isOn()) : undefined\n return createElement(\n Pressable,\n {\n ...rest,\n role: rest.role ?? 'switch',\n // Reactive state → `aria-checked` tracks the toggle (a static object would bake it once).\n state: () => ({\n ...(typeof rest.state === 'function' ? rest.state() : (rest.state ?? {})),\n checked: isOn(),\n }),\n ...(disabled ? { disabled: true } : {}),\n ...(handlePress ? { onPress: handlePress } : {}),\n style: mergeStyle(track, style),\n },\n knob,\n )\n}\n\n// ---------------------------------------------------------------------------\n// SafeAreaView\n// ---------------------------------------------------------------------------\n\n/** A container that pads itself by the live safe-area insets (notch, home indicator, …). */\nexport interface SafeAreaViewProps extends BaseProps {\n readonly children?: MindeesNode\n /** Which edges to inset (default: all four). */\n readonly edges?: ReadonlyArray<'top' | 'right' | 'bottom' | 'left'>\n}\nexport const SafeAreaView: Component<SafeAreaViewProps> = (props) => {\n const insets = useSafeAreaInsets()\n const { edges, style, children, ...rest } = props\n const wants = (edge: 'top' | 'right' | 'bottom' | 'left'): boolean =>\n !edges || edges.includes(edge)\n const base: Accessor<StyleInput> = () => {\n const i = insets()\n return {\n paddingTop: wants('top') ? i.top : 0,\n paddingRight: wants('right') ? i.right : 0,\n paddingBottom: wants('bottom') ? i.bottom : 0,\n paddingLeft: wants('left') ? i.left : 0,\n }\n }\n return createElement(View, { ...rest, style: mergeStyle(base, style) }, children)\n}\n\n// ---------------------------------------------------------------------------\n// KeyboardAvoidingView\n// ---------------------------------------------------------------------------\n\n/** A container that pads its bottom by the live keyboard height so content stays visible. */\nexport interface KeyboardAvoidingViewProps extends BaseProps {\n readonly children?: MindeesNode\n}\nexport const KeyboardAvoidingView: Component<KeyboardAvoidingViewProps> = (props) => {\n const keyboard = useKeyboard()\n const { style, children, ...rest } = props\n const base: Accessor<StyleInput> = () => ({ paddingBottom: keyboard().height })\n return createElement(View, { ...rest, style: mergeStyle(base, style) }, children)\n}\n\n// ---------------------------------------------------------------------------\n// ProgressBar (determinate)\n// ---------------------------------------------------------------------------\n\n/** A determinate progress bar (track + reactive fill). */\nexport interface ProgressBarProps extends BaseProps {\n /** Progress 0..1 (static or reactive). Values outside the range are clamped. */\n readonly value?: Reactive<number>\n readonly trackColor?: string\n readonly color?: string\n readonly height?: number\n}\nexport const ProgressBar: Component<ProgressBarProps> = (props) => {\n const theme = useTheme()\n const { value = 0, trackColor, color, height = 6, style, ...rest } = props\n const progress = toAccessor(value, 0)\n const track: Accessor<StyleInput> = () => ({\n width: '100%',\n height,\n borderRadius: height / 2,\n overflow: 'hidden',\n backgroundColor: trackColor ?? theme().color.surfaceVariant,\n })\n const fill: Accessor<StyleInput> = () => ({\n height,\n borderRadius: height / 2,\n backgroundColor: color ?? theme().color.primary,\n width: `${Math.max(0, Math.min(1, progress())) * 100}%`,\n })\n return createElement(\n View,\n {\n ...rest,\n role: rest.role ?? 'progressbar',\n // A progressbar with no value is inaccessible — emit a reactive aria-valuenow (0..1 range).\n valueMin: 0,\n valueMax: 1,\n valueNow: () => Math.max(0, Math.min(1, progress())),\n style: mergeStyle(track, style),\n },\n createElement(View, { style: fill }),\n )\n}\n\n// ---------------------------------------------------------------------------\n// ActivityIndicator\n// ---------------------------------------------------------------------------\n\n/**\n * A spinning loading indicator. Emits the `activityindicator` host tag, which each backend\n * renders natively: web → a CSS keyframe spinner (size from `width`/`height`, arc from `color`),\n * Android → an indeterminate `ProgressBar`. Size/color flow through ordinary style keys.\n */\nexport interface ActivityIndicatorProps extends BaseProps {\n /** Diameter in px (default 24). */\n readonly size?: number\n /** Spinner color (defaults to the theme primary). */\n readonly color?: string\n /** When false, renders nothing (so callers can gate it without a conditional). */\n readonly animating?: boolean\n}\nexport const ActivityIndicator: Component<ActivityIndicatorProps> = (props) => {\n const theme = useTheme()\n const { size = 24, color, animating = true, style, ...rest } = props\n if (animating === false) return null\n const base: Accessor<StyleInput> = () => ({\n width: size,\n height: size,\n color: color ?? theme().color.primary,\n })\n const host = toHostProps({ ...rest, style: mergeStyle(base, style) })\n if (!host.role) host.role = 'status'\n host['aria-busy'] = 'true'\n return createElement('activityindicator', host)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,SAAS,WACP,MACA,OACsB;CACtB,MAAM,SAAS,OAAO,SA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KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,SAAS,CAAC,CAAC;EACnD,OAAO,WAAW,OAAO,KAAK;CAChC,GACA,cAAc,MAAM,EAAE,OAAO,KAAK,CAAC,CACrC;AACF;AAmBA,MAAa,qBAAwD,UAAU;CAC7E,MAAM,QAAQ,SAAS;CACvB,MAAM,EAAE,OAAO,IAAI,OAAO,YAAY,MAAM,OAAO,GAAG,SAAS;CAC/D,IAAI,cAAc,OAAO,OAAO;CAChC,MAAM,cAAoC;EACxC,OAAO;EACP,QAAQ;EACR,OAAO,SAAS,MAAM,EAAE,MAAM;CAChC;CACA,MAAM,OAAO,YAAY;EAAE,GAAG;EAAM,OAAO,WAAW,MAAM,KAAK;CAAE,CAAC;CACpE,IAAI,CAAC,KAAK,MAAM,KAAK,OAAO;CAC5B,KAAK,eAAe;CACpB,OAAO,cAAc,qBAAqB,IAAI;AAChD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { StyleInput, StyleObject, StyleValue, flattenStyle } from "./style.js";
|
|
|
3
3
|
import { BaseProps, Reactive, resolveStyle, toHostProps } from "./host.js";
|
|
4
4
|
import { ActivityIndicator, ActivityIndicatorProps, Avatar, AvatarProps, Badge, BadgeProps, Card, CardProps, Chip, ChipProps, Divider, DividerProps, KeyboardAvoidingView, KeyboardAvoidingViewProps, ProgressBar, ProgressBarProps, SafeAreaView, SafeAreaViewProps, Switch, SwitchProps } from "./components.js";
|
|
5
5
|
import { ColorScheme, KeyboardState, PlatformEnvironment, SafeAreaInsets, WindowDimensions, getEnvironment, setEnvironment, useColorScheme, useKeyboard, useSafeAreaInsets, useWindowDimensions } from "./environment.js";
|
|
6
|
+
import { FocusScope, FocusScopeProps, Modal, ModalProps } from "./overlay.js";
|
|
6
7
|
import { Button, ButtonProps, Column, Image, ImageProps, InteractionState, Pressable, PressableProps, Row, ScrollView, ScrollViewProps, Spacer, SpacerProps, Stack, StackProps, Text, TextInput, TextInputProps, TextProps, View, ViewProps, usePressable } from "./primitives.js";
|
|
7
8
|
import { Theme, ThemeColors, duration, easing, fontSize, fontWeight, getTheme, lineHeight, palette, radius, space, tokens, useTheme } from "./tokens.js";
|
|
8
9
|
import { Maturity, NotImplementedError, PackageInfo, notImplemented } from "@mindees/core";
|
|
@@ -11,7 +12,7 @@ import { Maturity, NotImplementedError, PackageInfo, notImplemented } from "@min
|
|
|
11
12
|
/** The npm package name. */
|
|
12
13
|
declare const name = "@mindees/atlas";
|
|
13
14
|
/** The package version. All `@mindees/*` packages share one locked version line. */
|
|
14
|
-
declare const VERSION = "0.
|
|
15
|
+
declare const VERSION = "0.4.0";
|
|
15
16
|
/** Current maturity of this package. See the repository `STATUS.md`. */
|
|
16
17
|
declare const maturity: Maturity;
|
|
17
18
|
/**
|
|
@@ -21,5 +22,5 @@ declare const maturity: Maturity;
|
|
|
21
22
|
*/
|
|
22
23
|
declare const info: PackageInfo;
|
|
23
24
|
//#endregion
|
|
24
|
-
export { type A11yProps, type A11yState, ActivityIndicator, type ActivityIndicatorProps, Avatar, type AvatarProps, Badge, type BadgeProps, type BaseProps, Button, type ButtonProps, Card, type CardProps, Chip, type ChipProps, type ColorScheme, Column, Divider, type DividerProps, Image, type ImageProps, type InteractionState, KeyboardAvoidingView, type KeyboardAvoidingViewProps, type KeyboardState, type Maturity, NotImplementedError, type PackageInfo, type PlatformEnvironment, Pressable, type PressableProps, ProgressBar, type ProgressBarProps, type Reactive, type Role, Row, type SafeAreaInsets, SafeAreaView, type SafeAreaViewProps, ScrollView, type ScrollViewProps, Spacer, type SpacerProps, Stack, type StackProps, type StyleInput, type StyleObject, type StyleValue, Switch, type SwitchProps, Text, TextInput, type TextInputProps, type TextProps, type Theme, type ThemeColors, VERSION, View, type ViewProps, type WindowDimensions, duration, easing, flattenStyle, fontSize, fontWeight, getEnvironment, getTheme, info, lineHeight, maturity, name, notImplemented, palette, radius, resolveStyle, setEnvironment, space, toA11yProps, toHostProps, tokens, useColorScheme, useKeyboard, usePressable, useSafeAreaInsets, useTheme, useWindowDimensions };
|
|
25
|
+
export { type A11yProps, type A11yState, ActivityIndicator, type ActivityIndicatorProps, Avatar, type AvatarProps, Badge, type BadgeProps, type BaseProps, Button, type ButtonProps, Card, type CardProps, Chip, type ChipProps, type ColorScheme, Column, Divider, type DividerProps, FocusScope, type FocusScopeProps, Image, type ImageProps, type InteractionState, KeyboardAvoidingView, type KeyboardAvoidingViewProps, type KeyboardState, type Maturity, Modal, type ModalProps, NotImplementedError, type PackageInfo, type PlatformEnvironment, Pressable, type PressableProps, ProgressBar, type ProgressBarProps, type Reactive, type Role, Row, type SafeAreaInsets, SafeAreaView, type SafeAreaViewProps, ScrollView, type ScrollViewProps, Spacer, type SpacerProps, Stack, type StackProps, type StyleInput, type StyleObject, type StyleValue, Switch, type SwitchProps, Text, TextInput, type TextInputProps, type TextProps, type Theme, type ThemeColors, VERSION, View, type ViewProps, type WindowDimensions, duration, easing, flattenStyle, fontSize, fontWeight, getEnvironment, getTheme, info, lineHeight, maturity, name, notImplemented, palette, radius, resolveStyle, setEnvironment, space, toA11yProps, toHostProps, tokens, useColorScheme, useKeyboard, usePressable, useSafeAreaInsets, useTheme, useWindowDimensions };
|
|
25
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;cAea,IAAA;;cAGA,OAAA;AAAb;AAAA,cAGa,QAAA,EAAU,QAAyB;;;AAH5B;AAGpB;;cAOa,IAAA,EAAM,WAAiE"}
|
package/dist/index.js
CHANGED
|
@@ -5,12 +5,13 @@ import { resolveStyle, toHostProps } from "./host.js";
|
|
|
5
5
|
import { Button, Column, Image, Pressable, Row, ScrollView, Spacer, Stack, Text, TextInput, View, usePressable } from "./primitives.js";
|
|
6
6
|
import { duration, easing, fontSize, fontWeight, getTheme, lineHeight, palette, radius, space, tokens, useTheme } from "./tokens.js";
|
|
7
7
|
import { ActivityIndicator, Avatar, Badge, Card, Chip, Divider, KeyboardAvoidingView, ProgressBar, SafeAreaView, Switch } from "./components.js";
|
|
8
|
+
import { FocusScope, Modal } from "./overlay.js";
|
|
8
9
|
import { NotImplementedError, notImplemented } from "@mindees/core";
|
|
9
10
|
//#region src/index.ts
|
|
10
11
|
/** The npm package name. */
|
|
11
12
|
const name = "@mindees/atlas";
|
|
12
13
|
/** The package version. All `@mindees/*` packages share one locked version line. */
|
|
13
|
-
const VERSION = "0.
|
|
14
|
+
const VERSION = "0.4.0";
|
|
14
15
|
/** Current maturity of this package. See the repository `STATUS.md`. */
|
|
15
16
|
const maturity = "experimental";
|
|
16
17
|
/**
|
|
@@ -24,6 +25,6 @@ const info = Object.freeze({
|
|
|
24
25
|
maturity
|
|
25
26
|
});
|
|
26
27
|
//#endregion
|
|
27
|
-
export { ActivityIndicator, Avatar, Badge, Button, Card, Chip, Column, Divider, Image, KeyboardAvoidingView, NotImplementedError, Pressable, ProgressBar, Row, SafeAreaView, ScrollView, Spacer, Stack, Switch, Text, TextInput, VERSION, View, duration, easing, flattenStyle, fontSize, fontWeight, getEnvironment, getTheme, info, lineHeight, maturity, name, notImplemented, palette, radius, resolveStyle, setEnvironment, space, toA11yProps, toHostProps, tokens, useColorScheme, useKeyboard, usePressable, useSafeAreaInsets, useTheme, useWindowDimensions };
|
|
28
|
+
export { ActivityIndicator, Avatar, Badge, Button, Card, Chip, Column, Divider, FocusScope, Image, KeyboardAvoidingView, Modal, NotImplementedError, Pressable, ProgressBar, Row, SafeAreaView, ScrollView, Spacer, Stack, Switch, Text, TextInput, VERSION, View, duration, easing, flattenStyle, fontSize, fontWeight, getEnvironment, getTheme, info, lineHeight, maturity, name, notImplemented, palette, radius, resolveStyle, setEnvironment, space, toA11yProps, toHostProps, tokens, useColorScheme, useKeyboard, usePressable, useSafeAreaInsets, useTheme, useWindowDimensions };
|
|
28
29
|
|
|
29
30
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@mindees/atlas` (Atlas) — accessible, signals-native UI primitives. Function components\n * over `@mindees/core`'s `createElement` that return renderer-agnostic `MindeesNode` trees:\n * web rendering is real via the Helix DOM backend; native is a labeled 🔬 research track (the\n * same serializable tree, interpreted by a native host later). A curated cross-platform\n * `StyleObject`, typed accessibility, and a structural theme (on the `@mindees/atlas/theme`\n * subpath). The virtualized recycling `List` is on the `@mindees/atlas/list` subpath.\n *\n * @module\n */\n\nimport type { Maturity, PackageInfo } from '@mindees/core'\nimport { NotImplementedError, notImplemented } from '@mindees/core'\n\n/** The npm package name. */\nexport const name = '@mindees/atlas'\n\n/** The package version. All `@mindees/*` packages share one locked version line. */\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@mindees/atlas` (Atlas) — accessible, signals-native UI primitives. Function components\n * over `@mindees/core`'s `createElement` that return renderer-agnostic `MindeesNode` trees:\n * web rendering is real via the Helix DOM backend; native is a labeled 🔬 research track (the\n * same serializable tree, interpreted by a native host later). A curated cross-platform\n * `StyleObject`, typed accessibility, and a structural theme (on the `@mindees/atlas/theme`\n * subpath). The virtualized recycling `List` is on the `@mindees/atlas/list` subpath.\n *\n * @module\n */\n\nimport type { Maturity, PackageInfo } from '@mindees/core'\nimport { NotImplementedError, notImplemented } from '@mindees/core'\n\n/** The npm package name. */\nexport const name = '@mindees/atlas'\n\n/** The package version. All `@mindees/*` packages share one locked version line. */\nexport const VERSION = '0.4.0'\n\n/** Current maturity of this package. See the repository `STATUS.md`. */\nexport const maturity: Maturity = 'experimental'\n\n/**\n * Static identity + maturity metadata for this package. Frozen so the\n * self-reported identity tooling introspects cannot be mutated at runtime,\n * matching the `readonly` fields of {@link PackageInfo}.\n */\nexport const info: PackageInfo = Object.freeze({ name, version: VERSION, maturity })\n\nexport { type A11yProps, type A11yState, type Role, toA11yProps } from './a11y'\nexport {\n ActivityIndicator,\n type ActivityIndicatorProps,\n Avatar,\n type AvatarProps,\n Badge,\n type BadgeProps,\n Card,\n type CardProps,\n Chip,\n type ChipProps,\n Divider,\n type DividerProps,\n KeyboardAvoidingView,\n type KeyboardAvoidingViewProps,\n ProgressBar,\n type ProgressBarProps,\n SafeAreaView,\n type SafeAreaViewProps,\n Switch,\n type SwitchProps,\n} from './components'\nexport {\n type ColorScheme,\n getEnvironment,\n type KeyboardState,\n type PlatformEnvironment,\n type SafeAreaInsets,\n setEnvironment,\n useColorScheme,\n useKeyboard,\n useSafeAreaInsets,\n useWindowDimensions,\n type WindowDimensions,\n} from './environment'\nexport { type BaseProps, type Reactive, resolveStyle, toHostProps } from './host'\nexport {\n FocusScope,\n type FocusScopeProps,\n Modal,\n type ModalProps,\n} from './overlay'\nexport {\n Button,\n type ButtonProps,\n Column,\n Image,\n type ImageProps,\n type InteractionState,\n Pressable,\n type PressableProps,\n Row,\n ScrollView,\n type ScrollViewProps,\n Spacer,\n type SpacerProps,\n Stack,\n type StackProps,\n Text,\n TextInput,\n type TextInputProps,\n type TextProps,\n usePressable,\n View,\n type ViewProps,\n} from './primitives'\nexport { flattenStyle, type StyleInput, type StyleObject, type StyleValue } from './style'\nexport {\n duration,\n easing,\n fontSize,\n fontWeight,\n getTheme,\n lineHeight,\n palette,\n radius,\n space,\n type Theme,\n type ThemeColors,\n tokens,\n useTheme,\n} from './tokens'\nexport type { Maturity, PackageInfo }\nexport { NotImplementedError, notImplemented }\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,OAAO;;AAGpB,MAAa,UAAU;;AAGvB,MAAa,WAAqB;;;;;;AAOlC,MAAa,OAAoB,OAAO,OAAO;CAAE;CAAM,SAAS;CAAS;AAAS,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { A11yProps, Role } from "./a11y.js";
|
|
2
|
+
import { StyleInput } from "./style.js";
|
|
3
|
+
import { Reactive } from "./host.js";
|
|
4
|
+
import { Component, MindeesNode } from "@mindees/core";
|
|
5
|
+
|
|
6
|
+
//#region src/overlay.d.ts
|
|
7
|
+
/** Props for {@link FocusScope}. */
|
|
8
|
+
interface FocusScopeProps {
|
|
9
|
+
readonly children?: MindeesNode;
|
|
10
|
+
/** Focus the scope container on mount (default true). */
|
|
11
|
+
readonly autoFocus?: boolean;
|
|
12
|
+
/** Restore focus to the previously-focused element on unmount (default true). */
|
|
13
|
+
readonly restoreFocus?: boolean;
|
|
14
|
+
/** Called when Escape is pressed inside the scope. */
|
|
15
|
+
readonly onEscape?: () => void;
|
|
16
|
+
/** Dialog role (default `'dialog'`). */
|
|
17
|
+
readonly role?: Role;
|
|
18
|
+
/** Accessible name (`aria-label`). */
|
|
19
|
+
readonly label?: string;
|
|
20
|
+
/** Extra style on the scope container. */
|
|
21
|
+
readonly style?: Reactive<StyleInput>;
|
|
22
|
+
}
|
|
23
|
+
/** A focus-scoped, `aria-modal` container. Captures + restores focus on web; declarative elsewhere. */
|
|
24
|
+
declare const FocusScope: Component<FocusScopeProps>;
|
|
25
|
+
/** Props for {@link Modal}. */
|
|
26
|
+
interface ModalProps extends A11yProps {
|
|
27
|
+
/** Whether the modal is open (static or reactive). */
|
|
28
|
+
readonly visible: Reactive<boolean>;
|
|
29
|
+
/** Requested close (scrim press or Escape). */
|
|
30
|
+
readonly onRequestClose?: () => void;
|
|
31
|
+
readonly children?: MindeesNode;
|
|
32
|
+
/** Close when the scrim is pressed (default true). */
|
|
33
|
+
readonly closeOnBackdrop?: boolean;
|
|
34
|
+
/** Extra style merged into the scrim. */
|
|
35
|
+
readonly backdrop?: Reactive<StyleInput>;
|
|
36
|
+
/** Explicit overlay host target (else the backend's overlay layer). */
|
|
37
|
+
readonly mount?: unknown;
|
|
38
|
+
}
|
|
39
|
+
/** A portal-backed modal dialog: a dismissable scrim + a focus-scoped dialog above the tree. */
|
|
40
|
+
declare const Modal: Component<ModalProps>;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { FocusScope, FocusScopeProps, Modal, ModalProps };
|
|
43
|
+
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","names":[],"sources":["../src/overlay.ts"],"mappings":";;;;;;;UA8BiB,eAAA;EAAA,SACN,QAAA,GAAW,WAAA;EAYX;EAAA,SAVA,SAAA;EAUiB;EAAA,SARjB,YAAA;EAQ2B;EAAA,SAN3B,QAAA;EAoDV;EAAA,SAlDU,IAAA,GAAO,IAAA;EAQO;EAAA,SANd,KAAA;EAmDM;EAAA,SAjDN,KAAA,GAAQ,QAAA,CAAS,UAAA;AAAA;;cAIf,UAAA,EAAY,SAAS,CAAC,eAAA;;UA6ClB,UAAA,SAAmB,SAAA;EAAA;EAAA,SAEzB,OAAA,EAAS,QAAA;EAFyB;EAAA,SAIlC,cAAA;EAAA,SACA,QAAA,GAAW,WAAA;EAHF;EAAA,SAKT,eAAA;EAFA;EAAA,SAIA,QAAA,GAAW,QAAA,CAAS,UAAA;EAFpB;EAAA,SAIA,KAAA;AAAA;;cAIE,KAAA,EAAO,SAAS,CAAC,UAAA"}
|
package/dist/overlay.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { flattenStyle } from "./style.js";
|
|
2
|
+
import { Pressable, View } from "./primitives.js";
|
|
3
|
+
import { createElement, onCleanup, portal } from "@mindees/core";
|
|
4
|
+
//#region src/overlay.ts
|
|
5
|
+
/**
|
|
6
|
+
* Atlas overlays — `Modal` + `FocusScope`, built on core's `portal`.
|
|
7
|
+
*
|
|
8
|
+
* `Modal` gates a portal by a reactive `visible`: on open it relocates a scrim + a focus-scoped
|
|
9
|
+
* dialog to the renderer's overlay layer (above the tree); on close the gating region re-runs,
|
|
10
|
+
* firing the portal's cleanup (unmount) and the FocusScope's focus-restore. `FocusScope` captures
|
|
11
|
+
* the previously-focused element, auto-focuses its container, and restores focus on unmount —
|
|
12
|
+
* DOM-feature-detected, so it no-ops on native/headless (the dialog markup + a11y still serialize).
|
|
13
|
+
*
|
|
14
|
+
* v1 scope: web is fully interactive (scrim dismiss, Escape, focus capture/restore). Native is
|
|
15
|
+
* declarative — `role="dialog"` + `aria-modal` are carried to the host; a true focus trap +
|
|
16
|
+
* tab-cycling and back-button handling are a host follow-up (see the portal-modal ADR). Tab
|
|
17
|
+
* cycling within the scope is also deferred (needs a descendant query).
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
function toAccessor(value, fallback) {
|
|
22
|
+
return typeof value === "function" ? value : () => value === void 0 ? fallback : value;
|
|
23
|
+
}
|
|
24
|
+
/** A focus-scoped, `aria-modal` container. Captures + restores focus on web; declarative elsewhere. */
|
|
25
|
+
const FocusScope = (props) => {
|
|
26
|
+
let restore = null;
|
|
27
|
+
const captureAndFocus = (host) => {
|
|
28
|
+
if (typeof document === "undefined") return;
|
|
29
|
+
const node = host;
|
|
30
|
+
const previous = document.activeElement ?? null;
|
|
31
|
+
if (props.restoreFocus !== false && previous && typeof previous.focus === "function") restore = () => previous.focus?.();
|
|
32
|
+
if (props.autoFocus !== false && node && typeof node.focus === "function") queueMicrotask(() => {
|
|
33
|
+
if (node.isConnected) node.focus?.();
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
onCleanup(() => restore?.());
|
|
37
|
+
const callerStyle = props.style;
|
|
38
|
+
const style = () => flattenStyle([{ position: "relative" }, typeof callerStyle === "function" ? callerStyle() : callerStyle ?? {}]);
|
|
39
|
+
const hostProps = {
|
|
40
|
+
role: props.role ?? "dialog",
|
|
41
|
+
"aria-modal": "true",
|
|
42
|
+
tabindex: -1,
|
|
43
|
+
ref: captureAndFocus,
|
|
44
|
+
style
|
|
45
|
+
};
|
|
46
|
+
if (props.label !== void 0) hostProps["aria-label"] = props.label;
|
|
47
|
+
if (props.onEscape !== void 0) hostProps.onKeyDown = (e) => {
|
|
48
|
+
if (e.key === "Escape") props.onEscape?.();
|
|
49
|
+
};
|
|
50
|
+
return createElement("view", hostProps, props.children);
|
|
51
|
+
};
|
|
52
|
+
/** A portal-backed modal dialog: a dismissable scrim + a focus-scoped dialog above the tree. */
|
|
53
|
+
const Modal = (props) => {
|
|
54
|
+
const isVisible = toAccessor(props.visible, false);
|
|
55
|
+
return () => {
|
|
56
|
+
if (!isVisible()) return null;
|
|
57
|
+
const scrimStyle = () => flattenStyle([{
|
|
58
|
+
position: "absolute",
|
|
59
|
+
top: 0,
|
|
60
|
+
right: 0,
|
|
61
|
+
bottom: 0,
|
|
62
|
+
left: 0,
|
|
63
|
+
backgroundColor: "rgba(0,0,0,0.5)"
|
|
64
|
+
}, typeof props.backdrop === "function" ? props.backdrop() : props.backdrop ?? {}]);
|
|
65
|
+
return portal(createElement(View, { style: () => ({
|
|
66
|
+
position: "fixed",
|
|
67
|
+
top: 0,
|
|
68
|
+
right: 0,
|
|
69
|
+
bottom: 0,
|
|
70
|
+
left: 0,
|
|
71
|
+
display: "flex",
|
|
72
|
+
alignItems: "center",
|
|
73
|
+
justifyContent: "center"
|
|
74
|
+
}) }, createElement(Pressable, {
|
|
75
|
+
style: scrimStyle,
|
|
76
|
+
label: "Close",
|
|
77
|
+
...props.closeOnBackdrop !== false && props.onRequestClose ? { onPress: props.onRequestClose } : {}
|
|
78
|
+
}), createElement(FocusScope, {
|
|
79
|
+
role: props.role ?? "dialog",
|
|
80
|
+
...props.onRequestClose ? { onEscape: props.onRequestClose } : {},
|
|
81
|
+
...props.label !== void 0 ? { label: props.label } : {}
|
|
82
|
+
}, props.children)), props.mount !== void 0 ? { mount: props.mount } : void 0);
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
export { FocusScope, Modal };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.js","names":["doc"],"sources":["../src/overlay.ts"],"sourcesContent":["/**\n * Atlas overlays — `Modal` + `FocusScope`, built on core's `portal`.\n *\n * `Modal` gates a portal by a reactive `visible`: on open it relocates a scrim + a focus-scoped\n * dialog to the renderer's overlay layer (above the tree); on close the gating region re-runs,\n * firing the portal's cleanup (unmount) and the FocusScope's focus-restore. `FocusScope` captures\n * the previously-focused element, auto-focuses its container, and restores focus on unmount —\n * DOM-feature-detected, so it no-ops on native/headless (the dialog markup + a11y still serialize).\n *\n * v1 scope: web is fully interactive (scrim dismiss, Escape, focus capture/restore). Native is\n * declarative — `role=\"dialog\"` + `aria-modal` are carried to the host; a true focus trap +\n * tab-cycling and back-button handling are a host follow-up (see the portal-modal ADR). Tab\n * cycling within the scope is also deferred (needs a descendant query).\n *\n * @module\n */\n\nimport { type Component, createElement, type MindeesNode, onCleanup, portal } from '@mindees/core'\nimport type { A11yProps, Role } from './a11y'\nimport type { Reactive } from './host'\nimport { Pressable, View } from './primitives'\nimport { flattenStyle, type StyleInput } from './style'\n\nfunction toAccessor<T>(value: Reactive<T>, fallback: T): () => T {\n return typeof value === 'function'\n ? (value as () => T)\n : () => (value === undefined ? fallback : value)\n}\n\n/** Props for {@link FocusScope}. */\nexport interface FocusScopeProps {\n readonly children?: MindeesNode\n /** Focus the scope container on mount (default true). */\n readonly autoFocus?: boolean\n /** Restore focus to the previously-focused element on unmount (default true). */\n readonly restoreFocus?: boolean\n /** Called when Escape is pressed inside the scope. */\n readonly onEscape?: () => void\n /** Dialog role (default `'dialog'`). */\n readonly role?: Role\n /** Accessible name (`aria-label`). */\n readonly label?: string\n /** Extra style on the scope container. */\n readonly style?: Reactive<StyleInput>\n}\n\n/** A focus-scoped, `aria-modal` container. Captures + restores focus on web; declarative elsewhere. */\nexport const FocusScope: Component<FocusScopeProps> = (props) => {\n let restore: (() => void) | null = null\n const captureAndFocus = (host: unknown): void => {\n if (typeof document === 'undefined') return // native/headless: declarative only\n const node = host as { focus?: () => void } | null\n const doc = document as unknown as { activeElement?: { focus?: () => void } | null }\n const previous = doc.activeElement ?? null\n if (props.restoreFocus !== false && previous && typeof previous.focus === 'function') {\n restore = () => previous.focus?.()\n }\n if (props.autoFocus !== false && node && typeof node.focus === 'function') {\n // Defer: `ref` fires before the portal subtree is connected to the document, so a synchronous\n // focus() would no-op. By the microtask the subtree is mounted; skip if it closed first.\n queueMicrotask(() => {\n if ((node as { isConnected?: boolean }).isConnected) node.focus?.()\n })\n }\n }\n onCleanup(() => restore?.())\n\n const callerStyle = props.style\n const style: Reactive<StyleInput> = () =>\n flattenStyle([\n { position: 'relative' },\n typeof callerStyle === 'function' ? callerStyle() : (callerStyle ?? {}),\n ])\n\n const hostProps: Record<string, unknown> = {\n role: props.role ?? 'dialog',\n 'aria-modal': 'true',\n tabindex: -1,\n ref: captureAndFocus,\n style,\n }\n if (props.label !== undefined) hostProps['aria-label'] = props.label\n if (props.onEscape !== undefined) {\n hostProps.onKeyDown = (e: unknown) => {\n if ((e as { key?: string }).key === 'Escape') props.onEscape?.()\n }\n }\n // A RAW host `view` (not the curated View primitive) so ref/tabindex/onKeyDown/aria-modal pass through.\n return createElement('view', hostProps, props.children)\n}\n\n/** Props for {@link Modal}. */\nexport interface ModalProps extends A11yProps {\n /** Whether the modal is open (static or reactive). */\n readonly visible: Reactive<boolean>\n /** Requested close (scrim press or Escape). */\n readonly onRequestClose?: () => void\n readonly children?: MindeesNode\n /** Close when the scrim is pressed (default true). */\n readonly closeOnBackdrop?: boolean\n /** Extra style merged into the scrim. */\n readonly backdrop?: Reactive<StyleInput>\n /** Explicit overlay host target (else the backend's overlay layer). */\n readonly mount?: unknown\n}\n\n/** A portal-backed modal dialog: a dismissable scrim + a focus-scoped dialog above the tree. */\nexport const Modal: Component<ModalProps> = (props) => {\n const isVisible = toAccessor(props.visible, false)\n return () => {\n if (!isVisible()) return null\n\n const scrimStyle = (): StyleInput =>\n flattenStyle([\n {\n position: 'absolute',\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n backgroundColor: 'rgba(0,0,0,0.5)',\n },\n typeof props.backdrop === 'function' ? props.backdrop() : (props.backdrop ?? {}),\n ])\n const scrim = createElement(Pressable, {\n style: scrimStyle,\n label: 'Close',\n ...(props.closeOnBackdrop !== false && props.onRequestClose\n ? { onPress: props.onRequestClose }\n : {}),\n })\n\n const dialog = createElement(\n FocusScope,\n {\n role: props.role ?? 'dialog',\n ...(props.onRequestClose ? { onEscape: props.onRequestClose } : {}),\n ...(props.label !== undefined ? { label: props.label } : {}),\n },\n props.children,\n )\n\n // A full-screen flex-center container holds the scrim (behind) + the dialog (on top, centered).\n const container = createElement(\n View,\n {\n style: () => ({\n position: 'fixed',\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n }),\n },\n scrim,\n dialog,\n )\n return portal(container, props.mount !== undefined ? { mount: props.mount } : undefined)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,SAAS,WAAc,OAAoB,UAAsB;CAC/D,OAAO,OAAO,UAAU,aACnB,cACM,UAAU,KAAA,IAAY,WAAW;AAC9C;;AAoBA,MAAa,cAA0C,UAAU;CAC/D,IAAI,UAA+B;CACnC,MAAM,mBAAmB,SAAwB;EAC/C,IAAI,OAAO,aAAa,aAAa;EACrC,MAAM,OAAO;EAEb,MAAM,WAAWA,SAAI,iBAAiB;EACtC,IAAI,MAAM,iBAAiB,SAAS,YAAY,OAAO,SAAS,UAAU,YACxE,gBAAgB,SAAS,QAAQ;EAEnC,IAAI,MAAM,cAAc,SAAS,QAAQ,OAAO,KAAK,UAAU,YAG7D,qBAAqB;GACnB,IAAK,KAAmC,aAAa,KAAK,QAAQ;EACpE,CAAC;CAEL;CACA,gBAAgB,UAAU,CAAC;CAE3B,MAAM,cAAc,MAAM;CAC1B,MAAM,cACJ,aAAa,CACX,EAAE,UAAU,WAAW,GACvB,OAAO,gBAAgB,aAAa,YAAY,IAAK,e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
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindees/atlas",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "MindeesNative Atlas - accessible, signals-native UI primitives + a virtualized recycling list. Renderer-agnostic (web real, native research track).",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"directory": "packages/atlas"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@mindees/core": "0.
|
|
38
|
+
"@mindees/core": "0.4.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"happy-dom": "20.9.0",
|
|
42
|
-
"@mindees/renderer": "0.
|
|
42
|
+
"@mindees/renderer": "0.4.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsdown",
|