@molecule/app-ui-react-native 2.0.1 → 2.1.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/README.md +42 -7
- package/dist/elements/Anchor.d.ts +15 -0
- package/dist/elements/Anchor.d.ts.map +1 -0
- package/dist/elements/Anchor.js +57 -0
- package/dist/elements/Box.d.ts +19 -0
- package/dist/elements/Box.d.ts.map +1 -0
- package/dist/elements/Box.js +150 -0
- package/dist/elements/CheckField.d.ts +18 -0
- package/dist/elements/CheckField.d.ts.map +1 -0
- package/dist/elements/CheckField.js +103 -0
- package/dist/elements/Disclosure.d.ts +11 -0
- package/dist/elements/Disclosure.d.ts.map +1 -0
- package/dist/elements/Disclosure.js +67 -0
- package/dist/elements/Fieldset.d.ts +16 -0
- package/dist/elements/Fieldset.d.ts.map +1 -0
- package/dist/elements/Fieldset.js +34 -0
- package/dist/elements/FileField.d.ts +12 -0
- package/dist/elements/FileField.d.ts.map +1 -0
- package/dist/elements/FileField.js +111 -0
- package/dist/elements/FormArea.d.ts +18 -0
- package/dist/elements/FormArea.d.ts.map +1 -0
- package/dist/elements/FormArea.js +42 -0
- package/dist/elements/GlyphIcon.d.ts +19 -0
- package/dist/elements/GlyphIcon.d.ts.map +1 -0
- package/dist/elements/GlyphIcon.js +43 -0
- package/dist/elements/Image.d.ts +17 -0
- package/dist/elements/Image.d.ts.map +1 -0
- package/dist/elements/Image.js +26 -0
- package/dist/elements/Link.d.ts +20 -0
- package/dist/elements/Link.d.ts.map +1 -0
- package/dist/elements/Link.js +53 -0
- package/dist/elements/Pressable.d.ts +18 -0
- package/dist/elements/Pressable.d.ts.map +1 -0
- package/dist/elements/Pressable.js +107 -0
- package/dist/elements/PulseDots.d.ts +15 -0
- package/dist/elements/PulseDots.d.ts.map +1 -0
- package/dist/elements/PulseDots.js +78 -0
- package/dist/elements/RangeField.d.ts +11 -0
- package/dist/elements/RangeField.d.ts.map +1 -0
- package/dist/elements/RangeField.js +259 -0
- package/dist/elements/RichText.d.ts +23 -0
- package/dist/elements/RichText.d.ts.map +1 -0
- package/dist/elements/RichText.js +55 -0
- package/dist/elements/Rule.d.ts +11 -0
- package/dist/elements/Rule.d.ts.map +1 -0
- package/dist/elements/Rule.js +19 -0
- package/dist/elements/ScrollArea.d.ts +21 -0
- package/dist/elements/ScrollArea.d.ts.map +1 -0
- package/dist/elements/ScrollArea.js +101 -0
- package/dist/elements/SelectAction.d.ts +20 -0
- package/dist/elements/SelectAction.d.ts.map +1 -0
- package/dist/elements/SelectAction.js +113 -0
- package/dist/elements/SelectField.d.ts +11 -0
- package/dist/elements/SelectField.d.ts.map +1 -0
- package/dist/elements/SelectField.js +220 -0
- package/dist/elements/SelectMenu.d.ts +19 -0
- package/dist/elements/SelectMenu.d.ts.map +1 -0
- package/dist/elements/SelectMenu.js +122 -0
- package/dist/elements/Svg.d.ts +155 -0
- package/dist/elements/Svg.d.ts.map +1 -0
- package/dist/elements/Svg.js +525 -0
- package/dist/elements/TableBox.d.ts +19 -0
- package/dist/elements/TableBox.d.ts.map +1 -0
- package/dist/elements/TableBox.js +87 -0
- package/dist/elements/TableCell.d.ts +16 -0
- package/dist/elements/TableCell.d.ts.map +1 -0
- package/dist/elements/TableCell.js +69 -0
- package/dist/elements/Text.d.ts +17 -0
- package/dist/elements/Text.d.ts.map +1 -0
- package/dist/elements/Text.js +96 -0
- package/dist/elements/TextField.d.ts +25 -0
- package/dist/elements/TextField.d.ts.map +1 -0
- package/dist/elements/TextField.js +257 -0
- package/dist/elements/accessibility.d.ts +36 -0
- package/dist/elements/accessibility.d.ts.map +1 -0
- package/dist/elements/accessibility.js +239 -0
- package/dist/elements/className.d.ts +45 -0
- package/dist/elements/className.d.ts.map +1 -0
- package/dist/elements/className.js +8 -0
- package/dist/elements/decimal.d.ts +5 -0
- package/dist/elements/decimal.d.ts.map +1 -0
- package/dist/elements/decimal.js +11 -0
- package/dist/elements/documentUrl.d.ts +35 -0
- package/dist/elements/documentUrl.d.ts.map +1 -0
- package/dist/elements/documentUrl.js +89 -0
- package/dist/elements/drag-drop.d.ts +11 -0
- package/dist/elements/drag-drop.d.ts.map +1 -0
- package/dist/elements/drag-drop.js +277 -0
- package/dist/elements/drag.d.ts +47 -0
- package/dist/elements/drag.d.ts.map +1 -0
- package/dist/elements/drag.js +362 -0
- package/dist/elements/events.d.ts +45 -0
- package/dist/elements/events.d.ts.map +1 -0
- package/dist/elements/events.js +101 -0
- package/dist/elements/fieldBounds.d.ts +5 -0
- package/dist/elements/fieldBounds.d.ts.map +1 -0
- package/dist/elements/fieldBounds.js +60 -0
- package/dist/elements/flow.d.ts +36 -0
- package/dist/elements/flow.d.ts.map +1 -0
- package/dist/elements/flow.js +47 -0
- package/dist/elements/form.d.ts +48 -0
- package/dist/elements/form.d.ts.map +1 -0
- package/dist/elements/form.js +112 -0
- package/dist/elements/grid.d.ts +96 -0
- package/dist/elements/grid.d.ts.map +1 -0
- package/dist/elements/grid.js +272 -0
- package/dist/elements/index.d.ts +36 -0
- package/dist/elements/index.d.ts.map +1 -0
- package/dist/elements/index.js +35 -0
- package/dist/elements/inherited.d.ts +181 -0
- package/dist/elements/inherited.d.ts.map +1 -0
- package/dist/elements/inherited.js +512 -0
- package/dist/elements/labels.d.ts +39 -0
- package/dist/elements/labels.d.ts.map +1 -0
- package/dist/elements/labels.js +163 -0
- package/dist/elements/measure.d.ts +27 -0
- package/dist/elements/measure.d.ts.map +1 -0
- package/dist/elements/measure.js +24 -0
- package/dist/elements/outsidePress.d.ts +31 -0
- package/dist/elements/outsidePress.d.ts.map +1 -0
- package/dist/elements/outsidePress.js +94 -0
- package/dist/elements/paste.d.ts +22 -0
- package/dist/elements/paste.d.ts.map +1 -0
- package/dist/elements/paste.js +49 -0
- package/dist/elements/press.d.ts +41 -0
- package/dist/elements/press.d.ts.map +1 -0
- package/dist/elements/press.js +131 -0
- package/dist/elements/rangeKeyboard.d.ts +41 -0
- package/dist/elements/rangeKeyboard.d.ts.map +1 -0
- package/dist/elements/rangeKeyboard.js +58 -0
- package/dist/elements/rangeValues.d.ts +20 -0
- package/dist/elements/rangeValues.d.ts.map +1 -0
- package/dist/elements/rangeValues.js +101 -0
- package/dist/elements/ref.d.ts +16 -0
- package/dist/elements/ref.d.ts.map +1 -0
- package/dist/elements/ref.js +22 -0
- package/dist/elements/reveal.d.ts +8 -0
- package/dist/elements/reveal.d.ts.map +1 -0
- package/dist/elements/reveal.js +10 -0
- package/dist/elements/scrollReveal.d.ts +19 -0
- package/dist/elements/scrollReveal.d.ts.map +1 -0
- package/dist/elements/scrollReveal.js +52 -0
- package/dist/elements/selectOptions.d.ts +25 -0
- package/dist/elements/selectOptions.d.ts.map +1 -0
- package/dist/elements/selectOptions.js +60 -0
- package/dist/elements/style.d.ts +30 -0
- package/dist/elements/style.d.ts.map +1 -0
- package/dist/elements/style.js +363 -0
- package/dist/elements/svgHover.d.ts +41 -0
- package/dist/elements/svgHover.d.ts.map +1 -0
- package/dist/elements/svgHover.js +152 -0
- package/dist/elements/table.d.ts +52 -0
- package/dist/elements/table.d.ts.map +1 -0
- package/dist/elements/table.js +104 -0
- package/dist/elements/types.d.ts +25 -0
- package/dist/elements/types.d.ts.map +1 -0
- package/dist/elements/types.js +8 -0
- package/dist/elements/viewport.d.ts +53 -0
- package/dist/elements/viewport.d.ts.map +1 -0
- package/dist/elements/viewport.js +62 -0
- package/dist/elements/wheelZoom.d.ts +11 -0
- package/dist/elements/wheelZoom.d.ts.map +1 -0
- package/dist/elements/wheelZoom.js +7 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/platform/focus.d.ts +31 -0
- package/dist/platform/focus.d.ts.map +1 -0
- package/dist/platform/focus.js +86 -0
- package/dist/platform/index.d.ts +31 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/index.js +179 -0
- package/dist/platform/layout.d.ts +13 -0
- package/dist/platform/layout.d.ts.map +1 -0
- package/dist/platform/layout.js +15 -0
- package/dist/platform/position.d.ts +5 -0
- package/dist/platform/position.d.ts.map +1 -0
- package/dist/platform/position.js +177 -0
- package/dist/platform/stack.d.ts +86 -0
- package/dist/platform/stack.d.ts.map +1 -0
- package/dist/platform/stack.js +318 -0
- package/package.json +64 -6
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-11-
|
|
6
|
+
Generated: 2026-11-27T11:42:37.242Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-ui-react-native
|
|
@@ -11,9 +11,9 @@ Generated: 2026-11-26T04:13:56.392Z
|
|
|
11
11
|
React Native UI components for molecule.dev.
|
|
12
12
|
|
|
13
13
|
Provides React Native implementations (View/Pressable/Text-based) of the
|
|
14
|
-
core `@molecule/app-ui` component interfaces
|
|
14
|
+
core `@molecule/app-ui` component interfaces, including Accordion,
|
|
15
15
|
Alert, Avatar, Badge, Button, Card (+ CardHeader/CardTitle/CardDescription/
|
|
16
|
-
CardContent/CardFooter), Checkbox, Container, Dropdown, Flex, Form,
|
|
16
|
+
CardContent/CardFooter), Checkbox, Container, Dropdown, FileField, Flex, Form,
|
|
17
17
|
FormField, Grid, Input, Label, Modal, Pagination, Progress, RadioGroup,
|
|
18
18
|
Select, Separator, Skeleton, Spacer, Spinner, Switch, Table, Tabs,
|
|
19
19
|
Textarea, Toast (+ ToastProvider / ToastContainer / useToast), Tooltip.
|
|
@@ -56,7 +56,8 @@ function Greeting() {
|
|
|
56
56
|
## Installation
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
npm install @molecule/app-ui-react-native @molecule/app-i18n @molecule/app-react @molecule/app-ui react
|
|
59
|
+
npm install @molecule/app-ui-react-native @molecule/app-clipboard @molecule/app-drag-drop @molecule/app-file-picker @molecule/app-filesystem @molecule/app-fonts @molecule/app-i18n @molecule/app-logger @molecule/app-react @molecule/app-routing @molecule/app-ui react
|
|
60
|
+
npm install -D @types/react
|
|
60
61
|
```
|
|
61
62
|
|
|
62
63
|
## API
|
|
@@ -1947,28 +1948,62 @@ const Textarea: React.ForwardRefExoticComponent<
|
|
|
1947
1948
|
>
|
|
1948
1949
|
```
|
|
1949
1950
|
|
|
1951
|
+
#### `FileField`
|
|
1952
|
+
|
|
1953
|
+
Opens the bonded device picker from its browse target or the caller's `pick()` handle.
|
|
1954
|
+
|
|
1955
|
+
```typescript
|
|
1956
|
+
const FileField: ForwardRefExoticComponent<
|
|
1957
|
+
FileFieldProps<ReactNode> & RefAttributes<FileFieldHandle>
|
|
1958
|
+
>
|
|
1959
|
+
```
|
|
1960
|
+
|
|
1950
1961
|
## Injection Notes
|
|
1951
1962
|
|
|
1952
1963
|
### Requirements
|
|
1953
1964
|
|
|
1954
1965
|
Peer dependencies:
|
|
1955
1966
|
|
|
1956
|
-
- `@molecule/app-
|
|
1967
|
+
- `@molecule/app-clipboard` ^1.0.5
|
|
1968
|
+
- `@molecule/app-drag-drop` ^1.2.0
|
|
1969
|
+
- `@molecule/app-file-picker` ^1.0.0
|
|
1970
|
+
- `@molecule/app-filesystem` ^1.1.0
|
|
1971
|
+
- `@molecule/app-fonts` ^1.4.1
|
|
1972
|
+
- `@molecule/app-i18n` ^1.3.0
|
|
1957
1973
|
- `@molecule/app-icons` ^1.0.1 _(optional)_
|
|
1958
|
-
- `@molecule/app-
|
|
1959
|
-
- `@molecule/app-
|
|
1974
|
+
- `@molecule/app-logger` ^1.1.0
|
|
1975
|
+
- `@molecule/app-react` ^4.17.0
|
|
1976
|
+
- `@molecule/app-routing` ^1.5.3
|
|
1977
|
+
- `@molecule/app-ui` ^1.14.0
|
|
1978
|
+
- `@react-native-community/slider` ^4.5.6 _(optional)_
|
|
1960
1979
|
- `react` ^18.0.0 || ^19.0.0
|
|
1961
1980
|
- `react-native` >=0.72.0 _(optional)_
|
|
1981
|
+
- `react-native-safe-area-context` ^5.4.0 _(optional)_
|
|
1982
|
+
- `react-native-svg` ^15.11.2 _(optional)_
|
|
1983
|
+
- `react-native-url-polyfill` ^3.0.0 _(optional)_
|
|
1962
1984
|
|
|
1963
1985
|
### Runtime Dependencies
|
|
1964
1986
|
|
|
1987
|
+
- `@molecule/app-clipboard`
|
|
1988
|
+
- `@molecule/app-drag-drop`
|
|
1989
|
+
- `@molecule/app-file-picker`
|
|
1990
|
+
- `@molecule/app-filesystem`
|
|
1991
|
+
- `@molecule/app-fonts`
|
|
1965
1992
|
- `@molecule/app-i18n`
|
|
1966
1993
|
- `@molecule/app-icons` _(optional)_
|
|
1994
|
+
- `@molecule/app-logger`
|
|
1967
1995
|
- `@molecule/app-react`
|
|
1996
|
+
- `@molecule/app-routing`
|
|
1968
1997
|
- `@molecule/app-ui`
|
|
1998
|
+
- `@react-native-community/slider` _(optional)_
|
|
1969
1999
|
- `react`
|
|
1970
2000
|
- `react-native` _(optional)_
|
|
2001
|
+
- `react-native-safe-area-context` _(optional)_
|
|
2002
|
+
- `react-native-svg` _(optional)_
|
|
2003
|
+
- `react-native-url-polyfill` _(optional)_
|
|
1971
2004
|
|
|
2005
|
+
- Use `@molecule/app-ui-react-native/elements` for renderer-neutral device elements and
|
|
2006
|
+
`@molecule/app-ui-react-native/platform` for the device overlay host.
|
|
1972
2007
|
- **Styling requires NativeWind, not just setClassMap.** Components apply ClassMap classes via
|
|
1973
2008
|
`className` on React Native primitives — that prop only has an effect when the NativeWind
|
|
1974
2009
|
babel preset + Tailwind config are wired into the app AND `setClassMap(classMap)` from
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anchor: a link with a literal href.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { ElementHandle } from '@molecule/app-ui';
|
|
7
|
+
export { setPublicDocumentUrl } from './documentUrl.js';
|
|
8
|
+
/**
|
|
9
|
+
* Renders a native pressable link. A press runs the caller's handler, then opens the href through
|
|
10
|
+
* the OS unless the handler prevented it or the href is the `'#'` placeholder.
|
|
11
|
+
*/
|
|
12
|
+
export declare const Anchor: import("react").ForwardRefExoticComponent<Omit<import("@molecule/app-ui").ElementLinkProps<import("react").ReactNode>, "replace" | "state" | "to"> & {
|
|
13
|
+
href: string;
|
|
14
|
+
} & import("react").RefAttributes<ElementHandle>>;
|
|
15
|
+
//# sourceMappingURL=Anchor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Anchor.d.ts","sourceRoot":"","sources":["../../src/elements/Anchor.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAe,aAAa,EAA6B,MAAM,kBAAkB,CAAA;AAuB7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AA4BvD;;;GAGG;AACH,eAAO,MAAM,MAAM;;iDAoClB,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Anchor: a link with a literal href.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { forwardRef } from 'react';
|
|
8
|
+
import { Linking, Pressable } from 'react-native';
|
|
9
|
+
import { nativeAccessibility } from './accessibility.js';
|
|
10
|
+
import { resolvePublicDocumentUrl } from './documentUrl.js';
|
|
11
|
+
import { registerInline } from './flow.js';
|
|
12
|
+
import { useGridCell } from './grid.js';
|
|
13
|
+
import { blockInInline, dataAttributes, ElementScope, flowOf, isCssInline, layoutChildren, splitClasses, useInheritedText, useLineStart, useTagClasses, } from './inherited.js';
|
|
14
|
+
import { AnchorPress, pressProps } from './press.js';
|
|
15
|
+
import { useNativeRef } from './ref.js';
|
|
16
|
+
import { nativeStyle } from './style.js';
|
|
17
|
+
export { setPublicDocumentUrl } from './documentUrl.js';
|
|
18
|
+
/** Opens the literal destination, resolving relative references with the public document URL. */
|
|
19
|
+
async function openAnchor(href) {
|
|
20
|
+
try {
|
|
21
|
+
const destination = resolvePublicDocumentUrl(href);
|
|
22
|
+
if (destination === undefined) {
|
|
23
|
+
console.error(`Cannot open Anchor href ${JSON.stringify(href)} without a public document URL. Call setPublicDocumentUrl() with an absolute HTTP(S) URL at app startup.`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
await Linking.openURL(typeof destination === 'string' ? destination : await destination);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error(`Could not open Anchor href ${JSON.stringify(href)}.`, error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Determines how the anchor sits among inline or block siblings. */
|
|
33
|
+
function anchorFlow(props) {
|
|
34
|
+
const data = dataAttributes(props);
|
|
35
|
+
return blockInInline(flowOf(props.className, 'box', data), props.children, isCssInline(props.className, true, data));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Renders a native pressable link. A press runs the caller's handler, then opens the href through
|
|
39
|
+
* the OS unless the handler prevented it or the href is the `'#'` placeholder.
|
|
40
|
+
*/
|
|
41
|
+
export const Anchor = forwardRef(function Anchor(props, ref) {
|
|
42
|
+
const { href, title, className, style, webStyle, onClick, children } = props;
|
|
43
|
+
const split = splitClasses(useTagClasses(className, 'a'), useInheritedText(), dataAttributes(props));
|
|
44
|
+
const accessibility = nativeAccessibility({
|
|
45
|
+
...props,
|
|
46
|
+
role: props.role ?? 'link',
|
|
47
|
+
'aria-label': props['aria-label'] ?? title,
|
|
48
|
+
});
|
|
49
|
+
/** Runs the same click for the link and any nested button that received the press. */
|
|
50
|
+
function follow(event) {
|
|
51
|
+
onClick?.(event);
|
|
52
|
+
if (!event.defaultPrevented && href !== '#')
|
|
53
|
+
void openAnchor(href);
|
|
54
|
+
}
|
|
55
|
+
return (_jsx(ElementScope, { split: split, text: split.text, children: _jsx(Pressable, { ...accessibility, ref: useNativeRef(ref), className: split.view || undefined, style: [nativeStyle(style, webStyle), useLineStart(anchorFlow(props)), useGridCell()], ...pressProps({ ...props, onClick: follow }), children: _jsx(AnchorPress.Provider, { value: follow, children: layoutChildren(children, split) }) }) }));
|
|
56
|
+
});
|
|
57
|
+
registerInline(Anchor, anchorFlow);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Box: a container element.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type ReactElement } from 'react';
|
|
7
|
+
import type { BoxProps } from '@molecule/app-ui';
|
|
8
|
+
import type { ElementNode, ElementRefProps } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* A container: a `View` with the role its `as` tag implies, or a `Pressable` when it has a press, hover
|
|
11
|
+
* or focus handler or a tab stop (a `div` with `onClick`). Its text classes pass to the text
|
|
12
|
+
* inside it, and in a container that is not a flex container its inline children share lines, as
|
|
13
|
+
* CSS lays them out on the web.
|
|
14
|
+
*
|
|
15
|
+
* @param props - See {@link BoxProps}.
|
|
16
|
+
* @returns The element.
|
|
17
|
+
*/
|
|
18
|
+
export declare function Box(props: BoxProps<ElementNode> & ElementRefProps): ReactElement;
|
|
19
|
+
//# sourceMappingURL=Box.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../src/elements/Box.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAmC,MAAM,OAAO,CAAA;AAQ1E,OAAO,KAAK,EAAE,QAAQ,EAAmD,MAAM,kBAAkB,CAAA;AA2BjG,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE9D;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,eAAe,GAAG,YAAY,CAQhF"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Box: a container element.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { useCallback, useContext, useRef } from 'react';
|
|
8
|
+
import { Image as NativeImage, Pressable as NativePressable, View, } from 'react-native';
|
|
9
|
+
import { useDialogAccessibility } from '../platform/focus.js';
|
|
10
|
+
import { layoutChanged } from '../platform/layout.js';
|
|
11
|
+
import { nativeAccessibility } from './accessibility.js';
|
|
12
|
+
import { useImageSource } from './documentUrl.js';
|
|
13
|
+
import { dragViewActions, LongPressDragScope, useDragFrame, useNativeDrag } from './drag.js';
|
|
14
|
+
import { registerInline } from './flow.js';
|
|
15
|
+
import { useGridCell, useGridLayout } from './grid.js';
|
|
16
|
+
import { blockInInline, dataAttributes, ElementScope, flowOf, isCssInline, layoutChildren, splitClasses, useInheritedText, useLineStart, useTagClasses, } from './inherited.js';
|
|
17
|
+
import { useLabelText, WrappingLabel } from './labels.js';
|
|
18
|
+
import { OutsidePressScope, useOutsidePress } from './outsidePress.js';
|
|
19
|
+
import { boxPasteOwner, PasteScope } from './paste.js';
|
|
20
|
+
import { activatePress, ContextMenuScope, isPressable, pressProps, useMousePress } from './press.js';
|
|
21
|
+
import { useNativeRef } from './ref.js';
|
|
22
|
+
import { nativeStyle } from './style.js';
|
|
23
|
+
/**
|
|
24
|
+
* A container: a `View` with the role its `as` tag implies, or a `Pressable` when it has a press, hover
|
|
25
|
+
* or focus handler or a tab stop (a `div` with `onClick`). Its text classes pass to the text
|
|
26
|
+
* inside it, and in a container that is not a flex container its inline children share lines, as
|
|
27
|
+
* CSS lays them out on the web.
|
|
28
|
+
*
|
|
29
|
+
* @param props - See {@link BoxProps}.
|
|
30
|
+
* @returns The element.
|
|
31
|
+
*/
|
|
32
|
+
export function Box(props) {
|
|
33
|
+
return props.as === 'label' ? (_jsx(WrappingLabel, { render: (activateLabel) => _jsx(BoxView, { ...props, activateLabel: activateLabel }), children: props.children })) : (_jsx(BoxView, { ...props }));
|
|
34
|
+
}
|
|
35
|
+
/** Draws the box and wires any default label activation after the caller's handler. */
|
|
36
|
+
function BoxView(props) {
|
|
37
|
+
const { as, title, className, style, webStyle, children, ref, activateLabel, hidden } = props;
|
|
38
|
+
const { coverImage, ...layoutStyle } = style ?? {};
|
|
39
|
+
useLabelText(props.id, children, props['aria-label']);
|
|
40
|
+
const split = splitClasses(useTagClasses(className, as), useInheritedText(), dataAttributes(props));
|
|
41
|
+
const host = useRef(null);
|
|
42
|
+
const forward = useNativeRef(ref);
|
|
43
|
+
const setHost = useCallback((view) => {
|
|
44
|
+
host.current = view;
|
|
45
|
+
forward?.(view);
|
|
46
|
+
}, [forward]);
|
|
47
|
+
const [frame, nativeRef] = useDragFrame(setHost);
|
|
48
|
+
const outside = useOutsidePress(hidden ? undefined : props.onPressOutside, ref ? host : undefined);
|
|
49
|
+
const context = useContext(ContextMenuScope);
|
|
50
|
+
const inheritedPaste = useContext(PasteScope);
|
|
51
|
+
const paste = props.onPasteText && boxPasteOwner(props.onPasteText);
|
|
52
|
+
const dialog = props['aria-modal'] === true || props['aria-modal'] === 'true';
|
|
53
|
+
const dialogAccessibility = useDialogAccessibility({
|
|
54
|
+
...props,
|
|
55
|
+
'aria-label': props['aria-label'] ?? title,
|
|
56
|
+
});
|
|
57
|
+
const interaction = useMousePress(props, pressProps(as === 'label' ? { ...props, tabIndex: props.tabIndex ?? -1 } : props, activateLabel), paste, !hidden);
|
|
58
|
+
const secondary = hidden ? undefined : props.secondaryAction;
|
|
59
|
+
const inheritedDrag = useContext(LongPressDragScope);
|
|
60
|
+
const ownDrag = hidden ? undefined : props.drag;
|
|
61
|
+
const delegatedDrag = !ownDrag && secondary ? inheritedDrag : null;
|
|
62
|
+
const responder = useNativeDrag(delegatedDrag?.frame ?? frame, {
|
|
63
|
+
drag: ownDrag ?? delegatedDrag?.drag,
|
|
64
|
+
secondary,
|
|
65
|
+
press: interaction,
|
|
66
|
+
});
|
|
67
|
+
const resolvedStyle = nativeStyle(style && layoutStyle, webStyle);
|
|
68
|
+
const addressFontStyle = as === 'address' ? (resolvedStyle?.fontStyle ?? 'italic') : undefined;
|
|
69
|
+
if (as === 'address' && resolvedStyle)
|
|
70
|
+
delete resolvedStyle.fontStyle;
|
|
71
|
+
// Keep the individual cells accessible when the grid owns the gesture.
|
|
72
|
+
const grid = props.role === 'grid' && ownDrag;
|
|
73
|
+
const pressable = isPressable(dialog ? { ...props, tabIndex: undefined } : props);
|
|
74
|
+
const accessible = hidden || as === 'label' || dialog || grid
|
|
75
|
+
? false
|
|
76
|
+
: (props.accessibilityGroup ?? (responder && (secondary || pressable) ? true : undefined));
|
|
77
|
+
const view = {
|
|
78
|
+
...nativeAccessibility({ ...props, 'aria-label': props['aria-label'] ?? title }, as),
|
|
79
|
+
...dialogAccessibility,
|
|
80
|
+
accessible,
|
|
81
|
+
accessibilityElementsHidden: hidden || undefined,
|
|
82
|
+
importantForAccessibility: hidden ? 'no-hide-descendants' : undefined,
|
|
83
|
+
pointerEvents: hidden ? 'none' : undefined,
|
|
84
|
+
collapsable: ref ? false : undefined,
|
|
85
|
+
onLayout: ref ? layoutChanged : undefined,
|
|
86
|
+
onTouchStart: props.onTouchStart
|
|
87
|
+
? (event) => {
|
|
88
|
+
outside.onTouchStart?.(event);
|
|
89
|
+
props.onTouchStart?.();
|
|
90
|
+
}
|
|
91
|
+
: outside.onTouchStart,
|
|
92
|
+
...(responder && {
|
|
93
|
+
collapsable: false,
|
|
94
|
+
...responder,
|
|
95
|
+
...dragViewActions(props, interaction, interaction.onPress ? () => activatePress(props.onClick, activateLabel) : undefined, secondary),
|
|
96
|
+
}),
|
|
97
|
+
className: split.view || undefined,
|
|
98
|
+
style: [
|
|
99
|
+
resolvedStyle,
|
|
100
|
+
useLineStart(boxFlow(props)),
|
|
101
|
+
useGridCell(),
|
|
102
|
+
hidden && { display: 'none' },
|
|
103
|
+
],
|
|
104
|
+
};
|
|
105
|
+
const press = !responder && (activateLabel || pressable || paste) ? interaction : null;
|
|
106
|
+
const longPressScope = ownDrag
|
|
107
|
+
? ownDrag.touchStart === 'longPress'
|
|
108
|
+
? { frame, drag: ownDrag }
|
|
109
|
+
: null
|
|
110
|
+
: inheritedDrag;
|
|
111
|
+
const background = coverImage ? _jsx(CoverImage, { src: coverImage }) : null;
|
|
112
|
+
return (_jsx(OutsidePressScope.Provider, { value: outside.scope, children: _jsx(ContextMenuScope.Provider, { value: props.onContextMenu ?? context, children: _jsx(PasteScope.Provider, { value: paste ?? inheritedPaste, children: _jsx(LongPressDragScope.Provider, { value: longPressScope, children: _jsx(ElementScope, { split: split, fontStyle: addressFontStyle, children: split.grid ? (_jsx(GridBox, { view: view, press: press, nativeRef: nativeRef, grid: split.grid, split: split, webStyle: webStyle, background: background, children: children })) : press ? (_jsxs(NativePressable, { ...view, ref: nativeRef, ...press, disabled: hidden, children: [background, layoutChildren(children, split)] })) : (_jsxs(View, { ...view, ref: nativeRef, children: [background, layoutChildren(children, split)] })) }) }) }) }) }));
|
|
113
|
+
}
|
|
114
|
+
/** Paints the backdrop without participating in the box's layout, interaction or accessible name. */
|
|
115
|
+
function CoverImage({ src }) {
|
|
116
|
+
const uri = useImageSource(src, 'Box coverImage');
|
|
117
|
+
if (!uri)
|
|
118
|
+
return null;
|
|
119
|
+
return (_jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", pointerEvents: "none", style: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 }, children: _jsx(NativeImage, { source: { uri }, resizeMode: "cover", style: { width: '100%', height: '100%' } }) }));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* A Box whose classes make it a CSS grid: its view lays its children out in rows of cells.
|
|
123
|
+
*
|
|
124
|
+
* @param props - The Box's view props, its press handlers, its ref, its grid and split classes, its web
|
|
125
|
+
* style (a track list, gaps) and its children.
|
|
126
|
+
* @returns The grid's view.
|
|
127
|
+
*/
|
|
128
|
+
function GridBox({ view, press, nativeRef, grid, split, webStyle, background, children, }) {
|
|
129
|
+
const text = split.text;
|
|
130
|
+
const layout = useGridLayout({
|
|
131
|
+
grid,
|
|
132
|
+
webStyle,
|
|
133
|
+
text,
|
|
134
|
+
split: (className) => splitClasses(className, text),
|
|
135
|
+
children,
|
|
136
|
+
});
|
|
137
|
+
const style = [view.style, layout.style];
|
|
138
|
+
return press ? (_jsxs(NativePressable, { ...view, style: style, ref: nativeRef, ...press, disabled: view.accessibilityElementsHidden, children: [background, layout.rows] })) : (_jsxs(View, { ...view, style: style, ref: nativeRef, children: [background, layout.rows] }));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* How a box flows: a span is an inline box, any other tag a block, unless its classes say otherwise.
|
|
142
|
+
*
|
|
143
|
+
* @param props - Its props.
|
|
144
|
+
* @returns Its inline kind.
|
|
145
|
+
*/
|
|
146
|
+
function boxFlow(props) {
|
|
147
|
+
const data = dataAttributes(props);
|
|
148
|
+
return blockInInline(flowOf(props.className, props.as === 'span' || props.as === 'label' ? 'box' : null, data), props.children, isCssInline(props.className, props.as === 'span' || props.as === 'label', data));
|
|
149
|
+
}
|
|
150
|
+
registerInline(Box, boxFlow);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CheckField: a native checkbox or controlled radio.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type ReactElement, type Ref } from 'react';
|
|
7
|
+
import { type CheckFieldHandle, type CheckFieldProps } from '@molecule/app-ui';
|
|
8
|
+
/**
|
|
9
|
+
* Draws the check state, handles activation, and contributes a successful control to the form.
|
|
10
|
+
* An accessibility-hidden control retains its handle and registration without drawing a view.
|
|
11
|
+
*
|
|
12
|
+
* @param props - The checkbox or radio's props and ref.
|
|
13
|
+
* @returns The visible control, or null for a hidden one.
|
|
14
|
+
*/
|
|
15
|
+
export declare function CheckField(props: CheckFieldProps & {
|
|
16
|
+
ref?: Ref<CheckFieldHandle>;
|
|
17
|
+
}): ReactElement | null;
|
|
18
|
+
//# sourceMappingURL=CheckField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckField.d.ts","sourceRoot":"","sources":["../../src/elements/CheckField.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,GAAG,EAOT,MAAM,OAAO,CAAA;AAGd,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAe,MAAM,kBAAkB,CAAA;AAqB3F;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,eAAe,GAAG;IAAE,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAA;CAAE,GACvD,YAAY,GAAG,IAAI,CA0HrB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* CheckField: a native checkbox or controlled radio.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { useCallback, useContext, useImperativeHandle, useLayoutEffect, useRef, useState, } from 'react';
|
|
8
|
+
import { Pressable as NativePressable } from 'react-native';
|
|
9
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
10
|
+
import { nativeAccessibility } from './accessibility.js';
|
|
11
|
+
import { fieldEvent } from './events.js';
|
|
12
|
+
import { registerInline } from './flow.js';
|
|
13
|
+
import { DisabledScope, FormScope, useFieldValue, useFormRegistration } from './form.js';
|
|
14
|
+
import { useGridCell } from './grid.js';
|
|
15
|
+
import { dataAttributes, ElementScope, replacedFlow, splitClasses, useInheritedText, useLineStart, useTagClasses, } from './inherited.js';
|
|
16
|
+
import { useLabelable } from './labels.js';
|
|
17
|
+
import { activatePress, pressProps } from './press.js';
|
|
18
|
+
import { nativeStyle } from './style.js';
|
|
19
|
+
import { Path, Svg } from './Svg.js';
|
|
20
|
+
/**
|
|
21
|
+
* Draws the check state, handles activation, and contributes a successful control to the form.
|
|
22
|
+
* An accessibility-hidden control retains its handle and registration without drawing a view.
|
|
23
|
+
*
|
|
24
|
+
* @param props - The checkbox or radio's props and ref.
|
|
25
|
+
* @returns The visible control, or null for a hidden one.
|
|
26
|
+
*/
|
|
27
|
+
export function CheckField(props) {
|
|
28
|
+
const { as, type, name, checked, defaultChecked, indeterminate, className, style, webStyle, required, onChange, onClick, onCheckedChange, onFocus, onBlur, tabIndex, ref, } = props;
|
|
29
|
+
const value = props.value ?? 'on';
|
|
30
|
+
const form = useContext(FormScope);
|
|
31
|
+
const fieldsetDisabled = useContext(DisabledScope);
|
|
32
|
+
const disabled = props.disabled || fieldsetDisabled;
|
|
33
|
+
const hidden = props['aria-hidden'] === true || props['aria-hidden'] === 'true';
|
|
34
|
+
const field = useFieldValue(checked, defaultChecked ?? false);
|
|
35
|
+
const [mixed, setMixed] = useState(indeterminate ?? false);
|
|
36
|
+
useLayoutEffect(() => {
|
|
37
|
+
setMixed(indeterminate ?? false);
|
|
38
|
+
}, [indeterminate]);
|
|
39
|
+
const view = useRef(null);
|
|
40
|
+
const focus = useCallback(() => {
|
|
41
|
+
if (!disabled && !hidden)
|
|
42
|
+
view.current?.focus();
|
|
43
|
+
}, [disabled, hidden]);
|
|
44
|
+
const click = (event) => {
|
|
45
|
+
if (disabled)
|
|
46
|
+
return;
|
|
47
|
+
activatePress(onClick, () => {
|
|
48
|
+
const next = !field.read();
|
|
49
|
+
if (type === 'radio' && !next)
|
|
50
|
+
return;
|
|
51
|
+
setMixed(false);
|
|
52
|
+
field.change(next, () => {
|
|
53
|
+
onChange?.(fieldEvent({ checked: next, value, name: name ?? '', type }));
|
|
54
|
+
onCheckedChange?.(next);
|
|
55
|
+
});
|
|
56
|
+
}, event);
|
|
57
|
+
};
|
|
58
|
+
useImperativeHandle(ref, () => ({
|
|
59
|
+
focus,
|
|
60
|
+
blur: () => view.current?.blur(),
|
|
61
|
+
click: () => click(),
|
|
62
|
+
get checked() {
|
|
63
|
+
return field.read();
|
|
64
|
+
},
|
|
65
|
+
}));
|
|
66
|
+
const label = useLabelable(props.id, hidden ? undefined : () => click());
|
|
67
|
+
useFormRegistration(form?.fields, {
|
|
68
|
+
entries: () => (name && !disabled && field.read() ? [[name, value]] : []),
|
|
69
|
+
valid: () => disabled ||
|
|
70
|
+
!required ||
|
|
71
|
+
field.read() ||
|
|
72
|
+
(type === 'radio' && !!name && form?.hasCheckedRadio(name) === true),
|
|
73
|
+
checkedRadio: () => (type === 'radio' && field.read() ? name : undefined),
|
|
74
|
+
reset: field.reset,
|
|
75
|
+
focus,
|
|
76
|
+
});
|
|
77
|
+
// RN View.focus is available to focusable hosts, and hidden controls never acquire a host.
|
|
78
|
+
useLayoutEffect(() => {
|
|
79
|
+
if (props.autoFocus)
|
|
80
|
+
focus();
|
|
81
|
+
}, [props.autoFocus, focus]);
|
|
82
|
+
const classes = useTagClasses(className, as);
|
|
83
|
+
const marked = mixed || field.displayed;
|
|
84
|
+
const split = splitClasses(classes, useInheritedText(), {
|
|
85
|
+
...dataAttributes(props),
|
|
86
|
+
state: marked ? 'checked' : 'unchecked',
|
|
87
|
+
});
|
|
88
|
+
const lineStyle = useLineStart(replacedFlow(className, as));
|
|
89
|
+
const gridStyle = useGridCell();
|
|
90
|
+
if (hidden)
|
|
91
|
+
return null;
|
|
92
|
+
const mark = marked
|
|
93
|
+
? getClassMap().checkFieldMark?.(type === 'radio' ? 'radio' : mixed ? 'mixed' : 'checked', classes)
|
|
94
|
+
: undefined;
|
|
95
|
+
return (_jsx(ElementScope, { split: split, children: _jsx(NativePressable, { ...nativeAccessibility({
|
|
96
|
+
...props,
|
|
97
|
+
role: props.role ?? type,
|
|
98
|
+
'aria-checked': props['aria-checked'] ?? (mixed ? 'mixed' : field.displayed),
|
|
99
|
+
'aria-disabled': disabled || props['aria-disabled'],
|
|
100
|
+
'aria-label': props['aria-label'] ?? label,
|
|
101
|
+
}), ref: view, className: split.view || undefined, style: [nativeStyle(style, webStyle), lineStyle, gridStyle], disabled: disabled, ...pressProps({ onFocus, onBlur, tabIndex }), onPress: click, children: mark && (_jsx(Svg, { className: mark.className, width: "100%", height: "100%", viewBox: "0 0 16 16", "aria-hidden": true, children: _jsx(Path, { d: mark.path, fill: "currentColor" }) })) }) }));
|
|
102
|
+
}
|
|
103
|
+
registerInline(CheckField, (props) => replacedFlow(props.className, 'input'));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disclosure: a pressable summary and a mounted, collapsible body.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type ReactElement } from 'react';
|
|
7
|
+
import type { DisclosureProps } from '@molecule/app-ui';
|
|
8
|
+
import type { ElementNode, ElementRefProps } from './types.js';
|
|
9
|
+
/** Draws the summary as a button and keeps closed content mounted but inaccessible. */
|
|
10
|
+
export declare function Disclosure(props: DisclosureProps<ElementNode> & ElementRefProps): ReactElement;
|
|
11
|
+
//# sourceMappingURL=Disclosure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Disclosure.d.ts","sourceRoot":"","sources":["../../src/elements/Disclosure.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAkD,MAAM,OAAO,CAAA;AAGzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAevD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAgD9D,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,CAAC,WAAW,CAAC,GAAG,eAAe,GAAG,YAAY,CA8C9F"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Disclosure: a pressable summary and a mounted, collapsible body.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
8
|
+
import { Pressable, View } from 'react-native';
|
|
9
|
+
import { nativeAccessibility } from './accessibility.js';
|
|
10
|
+
import { registerInline } from './flow.js';
|
|
11
|
+
import { useGridCell } from './grid.js';
|
|
12
|
+
import { dataAttributes, ElementScope, layoutChildren, splitClasses, useInheritedText, useTagClasses, } from './inherited.js';
|
|
13
|
+
import { useNativeRef } from './ref.js';
|
|
14
|
+
import { nativeStyle } from './style.js';
|
|
15
|
+
/** Tracks the applied open state and coalesces changes into one queued notification. */
|
|
16
|
+
function useExpanded(open, onToggle) {
|
|
17
|
+
const [expanded, setExpanded] = useState(open ?? false);
|
|
18
|
+
const current = useRef(false);
|
|
19
|
+
const callback = useRef(onToggle);
|
|
20
|
+
const pending = useRef(false);
|
|
21
|
+
const task = useRef(undefined);
|
|
22
|
+
const queue = useCallback(() => {
|
|
23
|
+
pending.current = true;
|
|
24
|
+
if (task.current !== undefined)
|
|
25
|
+
return;
|
|
26
|
+
task.current = setTimeout(() => {
|
|
27
|
+
task.current = undefined;
|
|
28
|
+
pending.current = false;
|
|
29
|
+
callback.current?.(current.current);
|
|
30
|
+
}, 0);
|
|
31
|
+
}, []);
|
|
32
|
+
const transition = useCallback((next) => {
|
|
33
|
+
if (current.current === next)
|
|
34
|
+
return;
|
|
35
|
+
current.current = next;
|
|
36
|
+
setExpanded(next);
|
|
37
|
+
queue();
|
|
38
|
+
}, [queue]);
|
|
39
|
+
useLayoutEffect(() => {
|
|
40
|
+
callback.current = onToggle;
|
|
41
|
+
}, [onToggle]);
|
|
42
|
+
// Reapply only when the parent changes the supplied value, as React does for the open attribute.
|
|
43
|
+
useLayoutEffect(() => transition(open ?? false), [open, transition]);
|
|
44
|
+
useLayoutEffect(() => {
|
|
45
|
+
// React can replay effect setup after cleanup while keeping state, e.g. in StrictMode.
|
|
46
|
+
if (pending.current)
|
|
47
|
+
queue();
|
|
48
|
+
return () => {
|
|
49
|
+
clearTimeout(task.current);
|
|
50
|
+
task.current = undefined;
|
|
51
|
+
};
|
|
52
|
+
}, [queue]);
|
|
53
|
+
return { expanded, toggle: () => transition(!current.current) };
|
|
54
|
+
}
|
|
55
|
+
/** Draws the summary as a button and keeps closed content mounted but inaccessible. */
|
|
56
|
+
export function Disclosure(props) {
|
|
57
|
+
const { as, open, summary, summaryProps, onToggle, style, webStyle, children, ref } = props;
|
|
58
|
+
const { expanded, toggle } = useExpanded(open, onToggle);
|
|
59
|
+
const split = splitClasses(useTagClasses(props.className, as), useInheritedText(), dataAttributes(props));
|
|
60
|
+
const summarySplit = splitClasses(useTagClasses(summaryProps?.className, 'summary', { first: true, last: children == null }), split.text, summaryProps && dataAttributes(summaryProps));
|
|
61
|
+
return (_jsx(View, { ...nativeAccessibility(props, as), ref: useNativeRef(ref), className: split.view || undefined, style: [nativeStyle(style, webStyle), useGridCell()], children: _jsxs(ElementScope, { split: split, children: [_jsx(Pressable, { ...nativeAccessibility({
|
|
62
|
+
...summaryProps,
|
|
63
|
+
role: summaryProps?.role ?? 'button',
|
|
64
|
+
children: summary,
|
|
65
|
+
}), accessibilityState: { expanded }, "aria-expanded": expanded, className: summarySplit.view || undefined, onPress: toggle, style: nativeStyle(summaryProps?.style, summaryProps?.webStyle), children: _jsx(ElementScope, { split: summarySplit, children: layoutChildren(summary, summarySplit) }) }), _jsx(View, { accessibilityElementsHidden: expanded ? undefined : true, importantForAccessibility: expanded ? undefined : 'no-hide-descendants', pointerEvents: expanded ? undefined : 'none', style: expanded ? undefined : { display: 'none' }, children: layoutChildren(children, split) })] }) }));
|
|
66
|
+
}
|
|
67
|
+
registerInline(Disclosure, () => null);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fieldset: a native disabled scope with an optional layout box.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type ReactElement } from 'react';
|
|
7
|
+
import type { FieldsetProps } from '@molecule/app-ui';
|
|
8
|
+
import type { ElementNode, ElementRefProps } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Disables descendant controls, with no view when its classes set display contents.
|
|
11
|
+
*
|
|
12
|
+
* @param props - The fieldset's props and ref.
|
|
13
|
+
* @returns The fieldset and its content.
|
|
14
|
+
*/
|
|
15
|
+
export declare function Fieldset(props: FieldsetProps<ElementNode> & ElementRefProps): ReactElement;
|
|
16
|
+
//# sourceMappingURL=Fieldset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fieldset.d.ts","sourceRoot":"","sources":["../../src/elements/Fieldset.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,OAAO,CAAA;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAiBrD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE9D;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,eAAe,GAAG,YAAY,CAiC1F"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Fieldset: a native disabled scope with an optional layout box.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { useContext } from 'react';
|
|
8
|
+
import { View } from 'react-native';
|
|
9
|
+
import { nativeAccessibility } from './accessibility.js';
|
|
10
|
+
import { registerContents } from './flow.js';
|
|
11
|
+
import { DisabledScope } from './form.js';
|
|
12
|
+
import { useGridCell } from './grid.js';
|
|
13
|
+
import { dataAttributes, ElementScope, layoutChildren, splitClasses, useInheritedText, useTagClasses, wrapStrings, } from './inherited.js';
|
|
14
|
+
import { useNativeRef } from './ref.js';
|
|
15
|
+
import { nativeStyle } from './style.js';
|
|
16
|
+
/**
|
|
17
|
+
* Disables descendant controls, with no view when its classes set display contents.
|
|
18
|
+
*
|
|
19
|
+
* @param props - The fieldset's props and ref.
|
|
20
|
+
* @returns The fieldset and its content.
|
|
21
|
+
*/
|
|
22
|
+
export function Fieldset(props) {
|
|
23
|
+
const { as, className, style, webStyle, children, ref } = props;
|
|
24
|
+
const parentDisabled = useContext(DisabledScope);
|
|
25
|
+
const disabled = parentDisabled || props.disabled === true;
|
|
26
|
+
const split = splitClasses(useTagClasses(className, as), useInheritedText(), dataAttributes(props));
|
|
27
|
+
const nativeRef = useNativeRef(ref);
|
|
28
|
+
const gridCell = useGridCell();
|
|
29
|
+
return (_jsx(DisabledScope.Provider, { value: disabled, children: _jsx(ElementScope, { split: split, children: split.display === 'contents' ? (wrapStrings(children, split.text)) : (_jsx(View, { ...nativeAccessibility({ ...props, 'aria-disabled': disabled || props['aria-disabled'] }, as), ref: nativeRef, className: split.view || undefined, style: [nativeStyle(style, webStyle), gridCell], children: layoutChildren(children, split) })) }) }));
|
|
30
|
+
}
|
|
31
|
+
registerContents(Fieldset, (props) => {
|
|
32
|
+
const className = typeof props.className === 'string' ? props.className : undefined;
|
|
33
|
+
return splitClasses(className, '', dataAttributes(props)).display === 'contents';
|
|
34
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File chooser control for React Native.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type ReactNode } from 'react';
|
|
7
|
+
import type { FileFieldHandle, FileFieldProps } from '@molecule/app-ui';
|
|
8
|
+
/**
|
|
9
|
+
* Opens the bonded device picker from its browse target or the caller's `pick()` handle.
|
|
10
|
+
*/
|
|
11
|
+
export declare const FileField: import("react").ForwardRefExoticComponent<FileFieldProps<ReactNode> & import("react").RefAttributes<FileFieldHandle>>;
|
|
12
|
+
//# sourceMappingURL=FileField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileField.d.ts","sourceRoot":"","sources":["../../src/elements/FileField.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAc,KAAK,SAAS,EAAgD,MAAM,OAAO,CAAA;AAKhG,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAgBvE;;GAEG;AACH,eAAO,MAAM,SAAS,uHAwHrB,CAAA"}
|