@molecule/app-ui-react-native 2.0.1 → 2.2.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 +81 -10
- package/dist/components/Alert.d.ts.map +1 -1
- package/dist/components/Alert.js +2 -3
- package/dist/components/Button.d.ts +3 -1
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +35 -3
- package/dist/components/Skeleton.d.ts.map +1 -1
- package/dist/components/Skeleton.js +13 -12
- package/dist/components/Spinner.js +2 -2
- 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 +157 -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 +108 -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 +266 -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 +117 -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 +535 -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 +244 -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 +53 -0
- package/dist/elements/drag.d.ts.map +1 -0
- package/dist/elements/drag.js +520 -0
- package/dist/elements/dragModifiers.d.ts +22 -0
- package/dist/elements/dragModifiers.d.ts.map +1 -0
- package/dist/elements/dragModifiers.js +62 -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 +368 -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 +12 -0
- package/dist/elements/wheelZoom.d.ts.map +1 -0
- package/dist/elements/wheelZoom.js +8 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/platform/focus.d.ts +31 -0
- package/dist/platform/focus.d.ts.map +1 -0
- package/dist/platform/focus.js +93 -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 +67 -8
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-27T20:10:27.153Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-ui-react-native
|
|
@@ -11,11 +11,11 @@ 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,
|
|
17
|
-
FormField, Grid, Input, Label, Modal, Pagination, Progress, RadioGroup,
|
|
18
|
-
Select, Separator, Skeleton, Spacer, Spinner, Switch, Table, Tabs,
|
|
16
|
+
CardContent/CardFooter), Checkbox, Container, Dropdown, FileField, Flex, Form,
|
|
17
|
+
FormArea, FormField, Grid, Input, Label, Modal, Pagination, Progress, RadioGroup,
|
|
18
|
+
Select, Separator, Skeleton, Spacer, Spinner, Switch, Table, Tabs, TextField,
|
|
19
19
|
Textarea, Toast (+ ToastProvider / ToastContainer / useToast), Tooltip.
|
|
20
20
|
Prop types build on `@molecule/app-ui`. Web-only extras (Icon,
|
|
21
21
|
UserMenu, ThemeToggle, PageHeader, …) live in `@molecule/app-ui-react` and
|
|
@@ -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
|
|
@@ -1020,7 +1021,8 @@ function Badge({
|
|
|
1020
1021
|
|
|
1021
1022
|
#### `Button(props)`
|
|
1022
1023
|
|
|
1023
|
-
Renders a Button component.
|
|
1024
|
+
Renders a Button component. Submit buttons use the nearest FormArea, or
|
|
1025
|
+
the enclosing HTML form on React Native Web.
|
|
1024
1026
|
|
|
1025
1027
|
```typescript
|
|
1026
1028
|
function Button({
|
|
@@ -1036,6 +1038,7 @@ function Button({
|
|
|
1036
1038
|
className,
|
|
1037
1039
|
testId,
|
|
1038
1040
|
disabled,
|
|
1041
|
+
type = 'button',
|
|
1039
1042
|
onClick,
|
|
1040
1043
|
}: ButtonProps): React.JSX.Element
|
|
1041
1044
|
```
|
|
@@ -1053,6 +1056,7 @@ function Button({
|
|
|
1053
1056
|
- `props.className` — CSS class name override.
|
|
1054
1057
|
- `props.testId` — Test identifier.
|
|
1055
1058
|
- `props.disabled` — Whether disabled.
|
|
1059
|
+
- `props.type` — The button's form action.
|
|
1056
1060
|
- `props.onClick` — Called when the button is pressed.
|
|
1057
1061
|
|
|
1058
1062
|
**Returns:** The rendered Button element.
|
|
@@ -1875,6 +1879,39 @@ function Tooltip({ children, content, className, testId }: TooltipProps): React.
|
|
|
1875
1879
|
|
|
1876
1880
|
**Returns:** The rendered Tooltip element.
|
|
1877
1881
|
|
|
1882
|
+
#### `FormArea(props)`
|
|
1883
|
+
|
|
1884
|
+
Draws a form container and supplies its submit, reset and scoped label associations.
|
|
1885
|
+
|
|
1886
|
+
```typescript
|
|
1887
|
+
function FormArea(props: FormAreaProps<ElementNode> & { ref?: Ref<FormAreaHandle> }): ReactElement
|
|
1888
|
+
```
|
|
1889
|
+
|
|
1890
|
+
- `props` — The form's props and ref.
|
|
1891
|
+
|
|
1892
|
+
**Returns:** The form and its content.
|
|
1893
|
+
|
|
1894
|
+
#### `TextField(props)`
|
|
1895
|
+
|
|
1896
|
+
A text field: a native `TextInput`, multi-line for `textarea`. `onValueChange` receives the new
|
|
1897
|
+
text; `onChange` and `onInput` receive an event whose target's `value` is the new text.
|
|
1898
|
+
|
|
1899
|
+
Each key the device's keyboard sends fires `onKeyDown`, `onKeyPress` and `onKeyUp` in that
|
|
1900
|
+
order, before the text changes; a handler that calls `preventDefault()` on the first two keeps
|
|
1901
|
+
the change from reaching `onChange`, `onInput` and `onValueChange`, as on the web. `onClick`
|
|
1902
|
+
fires on a press, `title` is the accessibility hint, and `tabIndex` decides whether the field
|
|
1903
|
+
takes keyboard focus. A device has no hover or double click on a text field
|
|
1904
|
+
(`onMouseEnter`, `onMouseLeave`, `onDoubleClick`) and no character columns or line-wrap modes
|
|
1905
|
+
(`cols`, `wrap`). Inside a form, Return in a single-line field can submit it.
|
|
1906
|
+
|
|
1907
|
+
```typescript
|
|
1908
|
+
function TextField(props: TextFieldProps & ElementRefProps): ReactElement
|
|
1909
|
+
```
|
|
1910
|
+
|
|
1911
|
+
- `props` — See {@link TextFieldProps}.
|
|
1912
|
+
|
|
1913
|
+
**Returns:** The element.
|
|
1914
|
+
|
|
1878
1915
|
### Constants
|
|
1879
1916
|
|
|
1880
1917
|
#### `Input`
|
|
@@ -1947,28 +1984,62 @@ const Textarea: React.ForwardRefExoticComponent<
|
|
|
1947
1984
|
>
|
|
1948
1985
|
```
|
|
1949
1986
|
|
|
1987
|
+
#### `FileField`
|
|
1988
|
+
|
|
1989
|
+
Opens the bonded device picker from its browse target or the caller's `pick()` handle.
|
|
1990
|
+
|
|
1991
|
+
```typescript
|
|
1992
|
+
const FileField: ForwardRefExoticComponent<
|
|
1993
|
+
FileFieldProps<ReactNode> & RefAttributes<FileFieldHandle>
|
|
1994
|
+
>
|
|
1995
|
+
```
|
|
1996
|
+
|
|
1950
1997
|
## Injection Notes
|
|
1951
1998
|
|
|
1952
1999
|
### Requirements
|
|
1953
2000
|
|
|
1954
2001
|
Peer dependencies:
|
|
1955
2002
|
|
|
1956
|
-
- `@molecule/app-
|
|
2003
|
+
- `@molecule/app-clipboard` ^1.0.5
|
|
2004
|
+
- `@molecule/app-drag-drop` ^1.2.0
|
|
2005
|
+
- `@molecule/app-file-picker` ^1.0.0
|
|
2006
|
+
- `@molecule/app-filesystem` ^1.1.0
|
|
2007
|
+
- `@molecule/app-fonts` ^1.4.1
|
|
2008
|
+
- `@molecule/app-i18n` ^1.3.0
|
|
1957
2009
|
- `@molecule/app-icons` ^1.0.1 _(optional)_
|
|
1958
|
-
- `@molecule/app-
|
|
1959
|
-
- `@molecule/app-
|
|
2010
|
+
- `@molecule/app-logger` ^1.1.0
|
|
2011
|
+
- `@molecule/app-react` ^4.17.0
|
|
2012
|
+
- `@molecule/app-routing` ^1.5.3
|
|
2013
|
+
- `@molecule/app-ui` ^1.16.0
|
|
2014
|
+
- `@react-native-community/slider` ^4.5.6 _(optional)_
|
|
1960
2015
|
- `react` ^18.0.0 || ^19.0.0
|
|
1961
2016
|
- `react-native` >=0.72.0 _(optional)_
|
|
2017
|
+
- `react-native-safe-area-context` ^5.4.0 _(optional)_
|
|
2018
|
+
- `react-native-svg` ^15.11.2 _(optional)_
|
|
2019
|
+
- `react-native-url-polyfill` ^3.0.0 _(optional)_
|
|
1962
2020
|
|
|
1963
2021
|
### Runtime Dependencies
|
|
1964
2022
|
|
|
2023
|
+
- `@molecule/app-clipboard`
|
|
2024
|
+
- `@molecule/app-drag-drop`
|
|
2025
|
+
- `@molecule/app-file-picker`
|
|
2026
|
+
- `@molecule/app-filesystem`
|
|
2027
|
+
- `@molecule/app-fonts`
|
|
1965
2028
|
- `@molecule/app-i18n`
|
|
1966
2029
|
- `@molecule/app-icons` _(optional)_
|
|
2030
|
+
- `@molecule/app-logger`
|
|
1967
2031
|
- `@molecule/app-react`
|
|
2032
|
+
- `@molecule/app-routing`
|
|
1968
2033
|
- `@molecule/app-ui`
|
|
2034
|
+
- `@react-native-community/slider` _(optional)_
|
|
1969
2035
|
- `react`
|
|
1970
2036
|
- `react-native` _(optional)_
|
|
2037
|
+
- `react-native-safe-area-context` _(optional)_
|
|
2038
|
+
- `react-native-svg` _(optional)_
|
|
2039
|
+
- `react-native-url-polyfill` _(optional)_
|
|
1971
2040
|
|
|
2041
|
+
- Use `@molecule/app-ui-react-native/elements` for renderer-neutral device elements and
|
|
2042
|
+
`@molecule/app-ui-react-native/platform` for the device overlay host.
|
|
1972
2043
|
- **Styling requires NativeWind, not just setClassMap.** Components apply ClassMap classes via
|
|
1973
2044
|
`className` on React Native primitives — that prop only has an effect when the NativeWind
|
|
1974
2045
|
babel preset + Tailwind config are wired into the app AND `setClassMap(classMap)` from
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../src/components/Alert.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../src/components/Alert.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAmCtC,CAAA"}
|
package/dist/components/Alert.js
CHANGED
|
@@ -19,8 +19,7 @@ import { getClassMap } from '@molecule/app-ui';
|
|
|
19
19
|
export const Alert = ({ children, title, variant: _variant = 'subtle', status, icon, dismissible, onDismiss, className, testId, }) => {
|
|
20
20
|
const { t } = useTranslation();
|
|
21
21
|
const cm = getClassMap();
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
}), className);
|
|
22
|
+
const tone = status === 'primary' || status === 'secondary' ? 'default' : (status ?? 'default');
|
|
23
|
+
const classes = cm.cn(cm.alert({ variant: tone }), className);
|
|
25
24
|
return (_jsxs(View, { className: classes, testID: testId, accessibilityRole: "alert", children: [!!icon && _jsx(View, { className: cm.alertIconWrapper, children: icon }), _jsxs(View, { className: cm.alertContent, children: [!!title && _jsx(Text, { className: cm.alertTitle, children: title }), !!children && _jsx(Text, { className: cm.alertDescription, children: children })] }), dismissible && (_jsx(Pressable, { className: cm.alertDismiss, onPress: onDismiss, accessibilityLabel: t('ui.alert.dismiss', undefined, { defaultValue: 'Dismiss' }), accessibilityRole: "button", children: _jsx(Text, { children: t('ui.icon.close', undefined, { defaultValue: '✕' }) }) }))] }));
|
|
26
25
|
};
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import type { ButtonProps } from '../types.js';
|
|
8
8
|
/**
|
|
9
|
-
* Renders a Button component.
|
|
9
|
+
* Renders a Button component. Submit buttons use the nearest FormArea, or
|
|
10
|
+
* the enclosing HTML form on React Native Web.
|
|
10
11
|
* @param root0 - Component props.
|
|
11
12
|
* @param root0.children - Button content.
|
|
12
13
|
* @param root0.variant - Visual variant.
|
|
@@ -20,6 +21,7 @@ import type { ButtonProps } from '../types.js';
|
|
|
20
21
|
* @param root0.className - CSS class name override.
|
|
21
22
|
* @param root0.testId - Test identifier.
|
|
22
23
|
* @param root0.disabled - Whether disabled.
|
|
24
|
+
* @param root0.type - The button's form action.
|
|
23
25
|
* @param root0.onClick - Called when the button is pressed.
|
|
24
26
|
* @returns The rendered Button element.
|
|
25
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAkC,MAAM,OAAO,CAAA;AAMtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAiExC,CAAA"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Button component for React Native.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { useCallback, useContext } from 'react';
|
|
2
8
|
import { ActivityIndicator, Pressable, Text, View } from 'react-native';
|
|
3
9
|
import { getClassMap } from '@molecule/app-ui';
|
|
10
|
+
import { DisabledScope, FormScope, useFormRegistration } from '../elements/form.js';
|
|
4
11
|
/**
|
|
5
|
-
* Renders a Button component.
|
|
12
|
+
* Renders a Button component. Submit buttons use the nearest FormArea, or
|
|
13
|
+
* the enclosing HTML form on React Native Web.
|
|
6
14
|
* @param root0 - Component props.
|
|
7
15
|
* @param root0.children - Button content.
|
|
8
16
|
* @param root0.variant - Visual variant.
|
|
@@ -16,11 +24,35 @@ import { getClassMap } from '@molecule/app-ui';
|
|
|
16
24
|
* @param root0.className - CSS class name override.
|
|
17
25
|
* @param root0.testId - Test identifier.
|
|
18
26
|
* @param root0.disabled - Whether disabled.
|
|
27
|
+
* @param root0.type - The button's form action.
|
|
19
28
|
* @param root0.onClick - Called when the button is pressed.
|
|
20
29
|
* @returns The rendered Button element.
|
|
21
30
|
*/
|
|
22
|
-
export const Button = ({ children, variant = 'solid', color = 'primary', size = 'md', loading = false, loadingText, fullWidth = false, leftIcon, rightIcon, className, testId, disabled, onClick, }) => {
|
|
31
|
+
export const Button = ({ children, variant = 'solid', color = 'primary', size = 'md', loading = false, loadingText, fullWidth = false, leftIcon, rightIcon, className, testId, disabled, type = 'button', onClick, }) => {
|
|
23
32
|
const cm = getClassMap();
|
|
24
33
|
const classes = cm.cn(cm.button({ variant, color, size, fullWidth }), className);
|
|
25
|
-
|
|
34
|
+
const form = useContext(FormScope);
|
|
35
|
+
const fieldsetDisabled = useContext(DisabledScope);
|
|
36
|
+
const unavailable = Boolean(disabled || loading || fieldsetDisabled);
|
|
37
|
+
const submit = type === 'submit' ? form?.submit : undefined;
|
|
38
|
+
const activate = () => {
|
|
39
|
+
if (unavailable)
|
|
40
|
+
return;
|
|
41
|
+
onClick?.();
|
|
42
|
+
submit?.();
|
|
43
|
+
};
|
|
44
|
+
useFormRegistration(submit ? form?.buttons : undefined, {
|
|
45
|
+
type,
|
|
46
|
+
disabled: unavailable,
|
|
47
|
+
activate,
|
|
48
|
+
});
|
|
49
|
+
// RNW gives the host type="button". Hand the default action back to the browser
|
|
50
|
+
// only when there is no FormArea to perform validation and submit.
|
|
51
|
+
const webType = type === 'submit' && !form ? 'submit' : 'button';
|
|
52
|
+
const setWebType = useCallback((host) => {
|
|
53
|
+
if (typeof HTMLButtonElement !== 'undefined' && host instanceof HTMLButtonElement) {
|
|
54
|
+
host.type = webType;
|
|
55
|
+
}
|
|
56
|
+
}, [webType]);
|
|
57
|
+
return (_jsxs(Pressable, { ref: setWebType, className: classes, disabled: unavailable, onPress: onClick || submit ? activate : undefined, testID: testId, accessibilityRole: "button", accessibilityState: { disabled: unavailable, busy: loading }, children: [loading && _jsx(ActivityIndicator, { size: "small", className: cm.buttonIconLeft }), !loading && !!leftIcon && (_jsx(View, { className: cm.buttonIconLeft, children: leftIcon })), _jsx(Text, { children: loading && loadingText ? loadingText : children }), !loading && !!rightIcon && (_jsx(View, { className: cm.buttonIconRight, children: rightIcon }))] }));
|
|
26
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Skeleton.d.ts","sourceRoot":"","sources":["../../src/components/Skeleton.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAA8B,MAAM,OAAO,CAAA;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGrD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"Skeleton.d.ts","sourceRoot":"","sources":["../../src/components/Skeleton.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAA8B,MAAM,OAAO,CAAA;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGrD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA+C5C,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CASA,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAEA,CAAA"}
|
|
@@ -5,7 +5,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
import { useEffect, useState } from 'react';
|
|
8
|
-
import { Animated, View } from 'react-native';
|
|
8
|
+
import { Animated, Platform, View } from 'react-native';
|
|
9
9
|
import { getClassMap } from '@molecule/app-ui';
|
|
10
10
|
/**
|
|
11
11
|
* Renders a Skeleton component.
|
|
@@ -23,24 +23,25 @@ export const Skeleton = ({ width, height, circle, animation = 'pulse', className
|
|
|
23
23
|
// The animated value is created once per mount and kept in state; a ref would
|
|
24
24
|
// have to be read while rendering.
|
|
25
25
|
const [opacity] = useState(() => new Animated.Value(1));
|
|
26
|
+
// Web uses the ClassMap's CSS animation.
|
|
27
|
+
const nativePulse = animation === 'pulse' && Platform.OS !== 'web';
|
|
26
28
|
useEffect(() => {
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, [animation, opacity]);
|
|
29
|
+
if (!nativePulse)
|
|
30
|
+
return undefined;
|
|
31
|
+
const pulse = Animated.loop(Animated.sequence([
|
|
32
|
+
Animated.timing(opacity, { toValue: 0.5, duration: 1000, useNativeDriver: true }),
|
|
33
|
+
Animated.timing(opacity, { toValue: 1, duration: 1000, useNativeDriver: true }),
|
|
34
|
+
]));
|
|
35
|
+
pulse.start();
|
|
36
|
+
return () => pulse.stop();
|
|
37
|
+
}, [nativePulse, opacity]);
|
|
37
38
|
const classes = cm.cn(cm.skeleton(), animation === 'wave' && cm.skeletonWave, animation === 'none' && cm.skeletonNone, circle && cm.skeletonCircle, className);
|
|
38
39
|
const sizeStyle = {
|
|
39
40
|
...(width !== undefined ? { width: width } : {}),
|
|
40
41
|
...(height !== undefined ? { height: height } : {}),
|
|
41
42
|
...(circle && width ? { borderRadius: typeof width === 'number' ? width / 2 : undefined } : {}),
|
|
42
43
|
};
|
|
43
|
-
return (_jsx(Animated.View, { className: classes, style: [sizeStyle, { opacity:
|
|
44
|
+
return (_jsx(Animated.View, { className: classes, style: [sizeStyle, { opacity: nativePulse ? opacity : 1 }], testID: testId }));
|
|
44
45
|
};
|
|
45
46
|
/**
|
|
46
47
|
* Renders a SkeletonText component.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ActivityIndicator, View } from 'react-native';
|
|
2
|
+
import { ActivityIndicator, Platform, View } from 'react-native';
|
|
3
3
|
import { useTranslation } from '@molecule/app-react';
|
|
4
4
|
import { getClassMap } from '@molecule/app-ui';
|
|
5
5
|
const sizeMap = {
|
|
@@ -21,5 +21,5 @@ export const Spinner = ({ size = 'md', className, testId }) => {
|
|
|
21
21
|
const { t } = useTranslation();
|
|
22
22
|
const cm = getClassMap();
|
|
23
23
|
const classes = cm.cn(cm.spinner({ size }), className);
|
|
24
|
-
return (_jsx(View, { className: classes, testID: testId, accessibilityRole: "progressbar", accessibilityLabel: t('ui.spinner.loading', undefined, { defaultValue: 'Loading' }), children: _jsx(ActivityIndicator, { size: sizeMap[size] || 'small' }) }));
|
|
24
|
+
return (_jsx(View, { className: classes, testID: testId, accessibilityRole: "progressbar", accessibilityLabel: t('ui.spinner.loading', undefined, { defaultValue: 'Loading' }), children: Platform.OS !== 'web' && _jsx(ActivityIndicator, { size: sizeMap[size] || 'small' }) }));
|
|
25
25
|
};
|
|
@@ -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,157 @@
|
|
|
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
|
+
zoom: hidden ? undefined : props.zoom,
|
|
65
|
+
secondary,
|
|
66
|
+
press: interaction,
|
|
67
|
+
});
|
|
68
|
+
const resolvedStyle = nativeStyle(style && layoutStyle, webStyle);
|
|
69
|
+
const addressFontStyle = as === 'address' ? (resolvedStyle?.fontStyle ?? 'italic') : undefined;
|
|
70
|
+
if (as === 'address' && resolvedStyle)
|
|
71
|
+
delete resolvedStyle.fontStyle;
|
|
72
|
+
// Keep the individual cells accessible when the grid owns the gesture.
|
|
73
|
+
const grid = props.role === 'grid' && ownDrag;
|
|
74
|
+
const pressable = isPressable(dialog ? { ...props, tabIndex: undefined } : props);
|
|
75
|
+
const accessible = hidden || as === 'label' || dialog || grid
|
|
76
|
+
? false
|
|
77
|
+
: (props.accessibilityGroup ?? (responder && (secondary || pressable) ? true : undefined));
|
|
78
|
+
const view = {
|
|
79
|
+
...nativeAccessibility({ ...props, 'aria-label': props['aria-label'] ?? title }, as),
|
|
80
|
+
...dialogAccessibility,
|
|
81
|
+
accessible,
|
|
82
|
+
accessibilityElementsHidden: hidden || undefined,
|
|
83
|
+
importantForAccessibility: hidden ? 'no-hide-descendants' : undefined,
|
|
84
|
+
pointerEvents: hidden ? 'none' : undefined,
|
|
85
|
+
collapsable: ref ? false : 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
|
+
onLayout: ref || responder
|
|
98
|
+
? (event) => {
|
|
99
|
+
responder?.onLayout?.(event);
|
|
100
|
+
if (ref)
|
|
101
|
+
layoutChanged();
|
|
102
|
+
}
|
|
103
|
+
: undefined,
|
|
104
|
+
className: split.view || undefined,
|
|
105
|
+
style: [
|
|
106
|
+
resolvedStyle,
|
|
107
|
+
useLineStart(boxFlow(props)),
|
|
108
|
+
useGridCell(),
|
|
109
|
+
hidden && { display: 'none' },
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
const press = !responder && (activateLabel || pressable || paste) ? interaction : null;
|
|
113
|
+
const longPressScope = ownDrag
|
|
114
|
+
? ownDrag.touchStart === 'longPress'
|
|
115
|
+
? { frame, drag: ownDrag }
|
|
116
|
+
: null
|
|
117
|
+
: inheritedDrag;
|
|
118
|
+
const background = coverImage ? _jsx(CoverImage, { src: coverImage }) : null;
|
|
119
|
+
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)] })) }) }) }) }) }));
|
|
120
|
+
}
|
|
121
|
+
/** Paints the backdrop without participating in the box's layout, interaction or accessible name. */
|
|
122
|
+
function CoverImage({ src }) {
|
|
123
|
+
const uri = useImageSource(src, 'Box coverImage');
|
|
124
|
+
if (!uri)
|
|
125
|
+
return null;
|
|
126
|
+
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%' } }) }));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A Box whose classes make it a CSS grid: its view lays its children out in rows of cells.
|
|
130
|
+
*
|
|
131
|
+
* @param props - The Box's view props, its press handlers, its ref, its grid and split classes, its web
|
|
132
|
+
* style (a track list, gaps) and its children.
|
|
133
|
+
* @returns The grid's view.
|
|
134
|
+
*/
|
|
135
|
+
function GridBox({ view, press, nativeRef, grid, split, webStyle, background, children, }) {
|
|
136
|
+
const text = split.text;
|
|
137
|
+
const layout = useGridLayout({
|
|
138
|
+
grid,
|
|
139
|
+
webStyle,
|
|
140
|
+
text,
|
|
141
|
+
split: (className) => splitClasses(className, text),
|
|
142
|
+
children,
|
|
143
|
+
});
|
|
144
|
+
const style = [view.style, layout.style];
|
|
145
|
+
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] }));
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* How a box flows: a span is an inline box, any other tag a block, unless its classes say otherwise.
|
|
149
|
+
*
|
|
150
|
+
* @param props - Its props.
|
|
151
|
+
* @returns Its inline kind.
|
|
152
|
+
*/
|
|
153
|
+
function boxFlow(props) {
|
|
154
|
+
const data = dataAttributes(props);
|
|
155
|
+
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));
|
|
156
|
+
}
|
|
157
|
+
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"}
|