@molecule/app-ui-react-native 1.0.10 → 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 +211 -331
- package/dist/components/Button.d.ts +2 -2
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +2 -2
- package/dist/components/Card.d.ts +3 -2
- package/dist/components/Card.d.ts.map +1 -1
- package/dist/components/Card.js +11 -3
- package/dist/components/Checkbox.d.ts +2 -2
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +4 -7
- package/dist/components/Input.d.ts +13 -2
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/Input.js +5 -11
- package/dist/components/Layout.d.ts +3 -2
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/Layout.js +2 -2
- package/dist/components/Select.d.ts +2 -2
- package/dist/components/Select.d.ts.map +1 -1
- package/dist/components/Select.js +4 -6
- package/dist/components/Switch.d.ts +2 -2
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Switch.js +3 -7
- package/dist/components/Textarea.d.ts +13 -2
- package/dist/components/Textarea.d.ts.map +1 -1
- package/dist/components/Textarea.js +2 -6
- 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 +11 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- 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/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +66 -8
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import type { ButtonProps } from '
|
|
7
|
+
import type { ButtonProps } from '../types.js';
|
|
8
8
|
/**
|
|
9
9
|
* Renders a Button component.
|
|
10
10
|
* @param root0 - Component props.
|
|
@@ -20,7 +20,7 @@ import type { ButtonProps } from '@molecule/app-ui';
|
|
|
20
20
|
* @param root0.className - CSS class name override.
|
|
21
21
|
* @param root0.testId - Test identifier.
|
|
22
22
|
* @param root0.disabled - Whether disabled.
|
|
23
|
-
* @param root0.onClick -
|
|
23
|
+
* @param root0.onClick - Called when the button is pressed.
|
|
24
24
|
* @returns The rendered Button element.
|
|
25
25
|
*/
|
|
26
26
|
export declare const Button: React.FC<ButtonProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAqCxC,CAAA"}
|
|
@@ -16,11 +16,11 @@ import { getClassMap } from '@molecule/app-ui';
|
|
|
16
16
|
* @param root0.className - CSS class name override.
|
|
17
17
|
* @param root0.testId - Test identifier.
|
|
18
18
|
* @param root0.disabled - Whether disabled.
|
|
19
|
-
* @param root0.onClick -
|
|
19
|
+
* @param root0.onClick - Called when the button is pressed.
|
|
20
20
|
* @returns The rendered Button element.
|
|
21
21
|
*/
|
|
22
22
|
export const Button = ({ children, variant = 'solid', color = 'primary', size = 'md', loading = false, loadingText, fullWidth = false, leftIcon, rightIcon, className, testId, disabled, onClick, }) => {
|
|
23
23
|
const cm = getClassMap();
|
|
24
24
|
const classes = cm.cn(cm.button({ variant, color, size, fullWidth }), className);
|
|
25
|
-
return (_jsxs(Pressable, { className: classes, disabled: disabled || loading, onPress: onClick, testID: testId, accessibilityRole: "button", accessibilityState: { disabled: disabled || loading, 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 }))] }));
|
|
25
|
+
return (_jsxs(Pressable, { className: classes, disabled: disabled || loading, onPress: onClick ? () => onClick() : undefined, testID: testId, accessibilityRole: "button", accessibilityState: { disabled: disabled || loading, 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
26
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import type { CardProps } from '
|
|
7
|
+
import type { CardProps } from '../types.js';
|
|
8
8
|
/**
|
|
9
9
|
* Renders a Card component.
|
|
10
10
|
* @param root0 - Component props.
|
|
@@ -15,7 +15,8 @@ import type { CardProps } from '@molecule/app-ui';
|
|
|
15
15
|
* @param root0.className - CSS class name override.
|
|
16
16
|
* @param root0.style - Inline style object.
|
|
17
17
|
* @param root0.testId - Test identifier.
|
|
18
|
-
* @param root0.onClick -
|
|
18
|
+
* @param root0.onClick - Called when the card is pressed.
|
|
19
|
+
* @param root0.disabled - Whether the card is disabled.
|
|
19
20
|
* @returns The rendered Card element.
|
|
20
21
|
*/
|
|
21
22
|
export declare const Card: React.FC<CardProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAsCpC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAM1E,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAMzE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAM/E,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAM3E,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAM1E,CAAA"}
|
package/dist/components/Card.js
CHANGED
|
@@ -11,14 +11,22 @@ import { getClassMap } from '@molecule/app-ui';
|
|
|
11
11
|
* @param root0.className - CSS class name override.
|
|
12
12
|
* @param root0.style - Inline style object.
|
|
13
13
|
* @param root0.testId - Test identifier.
|
|
14
|
-
* @param root0.onClick -
|
|
14
|
+
* @param root0.onClick - Called when the card is pressed.
|
|
15
|
+
* @param root0.disabled - Whether the card is disabled.
|
|
15
16
|
* @returns The rendered Card element.
|
|
16
17
|
*/
|
|
17
|
-
export const Card = ({ children, variant = 'elevated', padding = 'md', interactive, className, style, testId, onClick, }) => {
|
|
18
|
+
export const Card = ({ children, variant = 'elevated', padding = 'md', interactive, className, style, testId, onClick, disabled, }) => {
|
|
18
19
|
const cm = getClassMap();
|
|
19
20
|
const classes = cm.cn(cm.card({ variant: variant }), cm.cardPadding(padding), interactive && cm.cardInteractive, className);
|
|
20
21
|
const Wrapper = onClick || interactive ? Pressable : View;
|
|
21
|
-
return (_jsx(Wrapper, { className: classes, style: style, testID: testId, ...(onClick
|
|
22
|
+
return (_jsx(Wrapper, { className: classes, style: style, testID: testId, ...(onClick
|
|
23
|
+
? {
|
|
24
|
+
onPress: () => onClick(),
|
|
25
|
+
disabled,
|
|
26
|
+
accessibilityRole: 'button',
|
|
27
|
+
accessibilityState: { disabled },
|
|
28
|
+
}
|
|
29
|
+
: {}), children: children }));
|
|
22
30
|
};
|
|
23
31
|
/**
|
|
24
32
|
* Renders a CardHeader component.
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import type { CheckboxProps } from '
|
|
7
|
+
import type { CheckboxProps } from '../types.js';
|
|
8
8
|
/**
|
|
9
9
|
* Renders a Checkbox component.
|
|
10
10
|
* @param root0 - Component props.
|
|
11
11
|
* @param root0.label - Checkbox label text.
|
|
12
12
|
* @param root0.checked - Whether checked.
|
|
13
13
|
* @param root0.indeterminate - Whether indeterminate.
|
|
14
|
-
* @param root0.
|
|
14
|
+
* @param root0.onCheckedChange - Receives the new checked state.
|
|
15
15
|
* @param root0.error - Error message.
|
|
16
16
|
* @param root0.disabled - Whether disabled.
|
|
17
17
|
* @param root0.className - CSS class name override.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../src/components/Checkbox.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../src/components/Checkbox.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAyC5C,CAAA"}
|
|
@@ -8,23 +8,20 @@ import { getClassMap } from '@molecule/app-ui';
|
|
|
8
8
|
* @param root0.label - Checkbox label text.
|
|
9
9
|
* @param root0.checked - Whether checked.
|
|
10
10
|
* @param root0.indeterminate - Whether indeterminate.
|
|
11
|
-
* @param root0.
|
|
11
|
+
* @param root0.onCheckedChange - Receives the new checked state.
|
|
12
12
|
* @param root0.error - Error message.
|
|
13
13
|
* @param root0.disabled - Whether disabled.
|
|
14
14
|
* @param root0.className - CSS class name override.
|
|
15
15
|
* @param root0.testId - Test identifier.
|
|
16
16
|
* @returns The rendered Checkbox element.
|
|
17
17
|
*/
|
|
18
|
-
export const Checkbox = ({ label, checked, indeterminate,
|
|
18
|
+
export const Checkbox = ({ label, checked, indeterminate, onCheckedChange, error, disabled, className, testId, }) => {
|
|
19
19
|
const { t } = useTranslation();
|
|
20
20
|
const cm = getClassMap();
|
|
21
21
|
const boxClasses = cm.cn(cm.checkbox({ error: !!error }), className);
|
|
22
22
|
return (_jsxs(Pressable, { className: cm.controlLabel, onPress: () => {
|
|
23
|
-
if (!disabled
|
|
24
|
-
|
|
25
|
-
target: { checked: !checked },
|
|
26
|
-
});
|
|
27
|
-
}
|
|
23
|
+
if (!disabled)
|
|
24
|
+
onCheckedChange?.(!checked);
|
|
28
25
|
}, disabled: disabled, testID: testId, accessibilityRole: "checkbox", accessibilityState: {
|
|
29
26
|
checked: indeterminate ? 'mixed' : !!checked,
|
|
30
27
|
disabled,
|
|
@@ -5,9 +5,20 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { TextInput } from 'react-native';
|
|
8
|
-
import type { InputProps } from '@molecule/app-ui';
|
|
9
8
|
/**
|
|
10
9
|
* Text input component.
|
|
11
10
|
*/
|
|
12
|
-
export declare const Input: React.ForwardRefExoticComponent<InputProps &
|
|
11
|
+
export declare const Input: React.ForwardRefExoticComponent<Omit<import("@molecule/app-ui").InputProps, "onChange" | "onClick" | "onDoubleClick" | "onMouseEnter" | "onMouseLeave" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "onKeyPress" | "onInput"> & {
|
|
12
|
+
onChange?: undefined;
|
|
13
|
+
onClick?: undefined;
|
|
14
|
+
onDoubleClick?: undefined;
|
|
15
|
+
onMouseEnter?: undefined;
|
|
16
|
+
onMouseLeave?: undefined;
|
|
17
|
+
onFocus?: (() => void) | undefined;
|
|
18
|
+
onBlur?: (() => void) | undefined;
|
|
19
|
+
onKeyDown?: undefined;
|
|
20
|
+
onKeyUp?: undefined;
|
|
21
|
+
onKeyPress?: undefined;
|
|
22
|
+
onInput?: undefined;
|
|
23
|
+
} & React.RefAttributes<TextInput>>;
|
|
13
24
|
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../src/components/Input.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAkC,MAAM,OAAO,CAAA;AACtD,OAAO,EAAmB,SAAS,EAAQ,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../src/components/Input.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAkC,MAAM,OAAO,CAAA;AACtD,OAAO,EAAmB,SAAS,EAAQ,MAAM,cAAc,CAAA;AAO/D;;GAEG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;mCAmGjB,CAAA"}
|
package/dist/components/Input.js
CHANGED
|
@@ -11,16 +11,14 @@ import { getClassMap } from '@molecule/app-ui';
|
|
|
11
11
|
/**
|
|
12
12
|
* Text input component.
|
|
13
13
|
*/
|
|
14
|
-
export const Input = forwardRef(({ label, error, hint, size = 'md', leftElement, rightElement, clearable, className, style, testId, disabled, type, placeholder, value,
|
|
14
|
+
export const Input = forwardRef(({ label, error, hint, size = 'md', leftElement, rightElement, clearable, clearLabel, onClear, className, style, testId, disabled, type, placeholder, value, onValueChange, onFocus, onBlur, required, ..._rest }, ref) => {
|
|
15
15
|
const { t } = useTranslation();
|
|
16
16
|
const cm = getClassMap();
|
|
17
17
|
const inputClasses = cm.cn(cm.input({ error: !!error, size }), !!leftElement && cm.inputPadLeft, !!(rightElement || clearable) && cm.inputPadRight, className);
|
|
18
18
|
const handleClear = useCallback(() => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
}, [onChange]);
|
|
19
|
+
onClear?.();
|
|
20
|
+
onValueChange?.('');
|
|
21
|
+
}, [onClear, onValueChange]);
|
|
24
22
|
const secureTextEntry = type === 'password';
|
|
25
23
|
const keyboardType = type === 'email'
|
|
26
24
|
? 'email-address'
|
|
@@ -29,9 +27,5 @@ export const Input = forwardRef(({ label, error, hint, size = 'md', leftElement,
|
|
|
29
27
|
: type === 'url'
|
|
30
28
|
? 'url'
|
|
31
29
|
: 'default';
|
|
32
|
-
return (_jsxs(View, { className: cm.inputWrapper, children: [!!label && (_jsx(Text, { className: cm.cn(cm.labelBlock, cm.label({ required: !!required })), children: label })), _jsxs(View, { className: cm.inputInner, children: [!!leftElement && (_jsx(View, { className: cm.inputLeftElement, children: leftElement })), _jsx(TextInput, { ref: ref, className: inputClasses, style: style, testID: testId, editable: !disabled, placeholder: placeholder, value: value, onChangeText: (
|
|
33
|
-
if (onChange) {
|
|
34
|
-
onChange({ target: { value: text } });
|
|
35
|
-
}
|
|
36
|
-
}, onFocus: onFocus, onBlur: onBlur, secureTextEntry: secureTextEntry, keyboardType: keyboardType, accessibilityLabel: typeof label === 'string' ? label : undefined }), clearable && !!value && (_jsx(Pressable, { className: cm.inputClearButton, onPress: handleClear, accessibilityRole: "button", accessibilityLabel: t('ui.input.clear', undefined, { defaultValue: 'Clear' }), children: _jsx(Text, { children: t('ui.icon.close', undefined, { defaultValue: '✕' }) }) })), !!rightElement && !clearable && (_jsx(View, { className: cm.inputRightElement, children: rightElement }))] }), !!error && typeof error === 'string' && _jsx(Text, { className: cm.formError, children: error }), !!hint && !error && _jsx(Text, { className: cm.formHint, children: hint })] }));
|
|
30
|
+
return (_jsxs(View, { className: cm.inputWrapper, children: [!!label && (_jsx(Text, { className: cm.cn(cm.labelBlock, cm.label({ required: !!required })), children: label })), _jsxs(View, { className: cm.inputInner, children: [!!leftElement && (_jsx(View, { className: cm.inputLeftElement, children: leftElement })), _jsx(TextInput, { ref: ref, className: inputClasses, style: style, testID: testId, editable: !disabled, placeholder: placeholder, value: value === undefined ? undefined : String(value), onChangeText: onValueChange, onFocus: onFocus ? () => onFocus() : undefined, onBlur: onBlur ? () => onBlur() : undefined, secureTextEntry: secureTextEntry, keyboardType: keyboardType, accessibilityLabel: typeof label === 'string' ? label : undefined }), clearable && !!value && (_jsx(Pressable, { className: cm.inputClearButton, onPress: handleClear, disabled: disabled, accessibilityRole: "button", accessibilityLabel: clearLabel ?? t('ui.input.clear', undefined, { defaultValue: 'Clear' }), children: _jsx(Text, { children: t('ui.icon.close', undefined, { defaultValue: '✕' }) }) })), !!rightElement && !clearable && (_jsx(View, { className: cm.inputRightElement, children: rightElement }))] }), !!error && typeof error === 'string' && _jsx(Text, { className: cm.formError, children: error }), !!hint && !error && _jsx(Text, { className: cm.formHint, children: hint })] }));
|
|
37
31
|
});
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import type { ContainerProps,
|
|
7
|
+
import type { ContainerProps, GridProps, SpacerProps } from '@molecule/app-ui';
|
|
8
|
+
import type { FlexProps } from '../types.js';
|
|
8
9
|
/**
|
|
9
10
|
* Renders a Container component.
|
|
10
11
|
* @param root0 - Component props.
|
|
@@ -29,7 +30,7 @@ export declare const Container: React.FC<ContainerProps>;
|
|
|
29
30
|
* @param root0.className - CSS class name override.
|
|
30
31
|
* @param root0.style - Inline style object.
|
|
31
32
|
* @param root0.testId - Test identifier.
|
|
32
|
-
* @param root0.onClick -
|
|
33
|
+
* @param root0.onClick - Called on touch release.
|
|
33
34
|
* @returns The rendered Flex element.
|
|
34
35
|
*/
|
|
35
36
|
export declare const Flex: React.FC<FlexProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../src/components/Layout.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../src/components/Layout.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAQ,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAGpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAoB9C,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAgDpC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAgBpC,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA0BxC,CAAA"}
|
|
@@ -29,7 +29,7 @@ export const Container = ({ children, maxWidth = 'lg', centered = true, classNam
|
|
|
29
29
|
* @param root0.className - CSS class name override.
|
|
30
30
|
* @param root0.style - Inline style object.
|
|
31
31
|
* @param root0.testId - Test identifier.
|
|
32
|
-
* @param root0.onClick -
|
|
32
|
+
* @param root0.onClick - Called on touch release.
|
|
33
33
|
* @returns The rendered Flex element.
|
|
34
34
|
*/
|
|
35
35
|
export const Flex = ({ children, direction = 'row', justify, align, wrap, gap, className, style, testId, onClick, }) => {
|
|
@@ -51,7 +51,7 @@ export const Flex = ({ children, direction = 'row', justify, align, wrap, gap, c
|
|
|
51
51
|
wrap: wrap,
|
|
52
52
|
gap: cmGap,
|
|
53
53
|
}), className);
|
|
54
|
-
return (_jsx(View, { className: flexClasses, style: style, testID: testId,
|
|
54
|
+
return (_jsx(View, { className: flexClasses, style: style, testID: testId, onTouchEnd: onClick ? () => onClick() : undefined, children: children }));
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
57
|
* Renders a Grid component.
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
import React from 'react';
|
|
10
|
-
import type { SelectProps } from '
|
|
10
|
+
import type { SelectProps } from '../types.js';
|
|
11
11
|
/**
|
|
12
12
|
* Renders a Select component.
|
|
13
13
|
* @param root0 - Component props.
|
|
14
14
|
* @param root0.label - Select label text.
|
|
15
15
|
* @param root0.options - Select options array.
|
|
16
16
|
* @param root0.value - Selected value.
|
|
17
|
-
* @param root0.
|
|
17
|
+
* @param root0.onValueChange - Receives the selected value.
|
|
18
18
|
* @param root0.placeholder - Placeholder text.
|
|
19
19
|
* @param root0.error - Error message.
|
|
20
20
|
* @param root0.hint - Hint text.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../src/components/Select.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../src/components/Select.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAA;AAMvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA6FxC,CAAA"}
|
|
@@ -17,7 +17,7 @@ import { getClassMap } from '@molecule/app-ui';
|
|
|
17
17
|
* @param root0.label - Select label text.
|
|
18
18
|
* @param root0.options - Select options array.
|
|
19
19
|
* @param root0.value - Selected value.
|
|
20
|
-
* @param root0.
|
|
20
|
+
* @param root0.onValueChange - Receives the selected value.
|
|
21
21
|
* @param root0.placeholder - Placeholder text.
|
|
22
22
|
* @param root0.error - Error message.
|
|
23
23
|
* @param root0.hint - Hint text.
|
|
@@ -28,7 +28,7 @@ import { getClassMap } from '@molecule/app-ui';
|
|
|
28
28
|
* @param root0.testId - Test identifier.
|
|
29
29
|
* @returns The rendered Select element.
|
|
30
30
|
*/
|
|
31
|
-
export const Select = ({ label, options = [], value,
|
|
31
|
+
export const Select = ({ label, options = [], value, onValueChange, placeholder, error, hint, size = 'md', disabled, required, className, testId, }) => {
|
|
32
32
|
const { t } = useTranslation();
|
|
33
33
|
const cm = getClassMap();
|
|
34
34
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -44,10 +44,8 @@ export const Select = ({ label, options = [], value, onChange, placeholder, erro
|
|
|
44
44
|
const optLabel = typeof item === 'string' ? item : item.label;
|
|
45
45
|
const isSelected = optValue === value;
|
|
46
46
|
return (_jsx(Pressable, { className: cm.cn(cm.dropdownItem, isSelected && cm.textPrimary), onPress: () => {
|
|
47
|
-
|
|
48
|
-
onChange({ target: { value: optValue } });
|
|
49
|
-
}
|
|
47
|
+
onValueChange?.(optValue);
|
|
50
48
|
setIsOpen(false);
|
|
51
|
-
}, children: _jsx(Text, { children: optLabel }) }));
|
|
49
|
+
}, disabled: disabled || (typeof item !== 'string' && item.disabled), children: _jsx(Text, { children: optLabel }) }));
|
|
52
50
|
} })] }) }) }), !!error && typeof error === 'string' && _jsx(Text, { className: cm.formError, children: error }), !!hint && !error && _jsx(Text, { className: cm.formHint, children: hint })] }));
|
|
53
51
|
};
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import type { SwitchProps } from '
|
|
7
|
+
import type { SwitchProps } from '../types.js';
|
|
8
8
|
/**
|
|
9
9
|
* Renders a Switch component.
|
|
10
10
|
* @param root0 - Component props.
|
|
11
11
|
* @param root0.label - Switch label text.
|
|
12
12
|
* @param root0.checked - Whether checked.
|
|
13
|
-
* @param root0.
|
|
13
|
+
* @param root0.onCheckedChange - Receives the new checked state.
|
|
14
14
|
* @param root0.size - Switch size (unused in RN).
|
|
15
15
|
* @param root0.disabled - Whether disabled.
|
|
16
16
|
* @param root0.className - CSS class name override.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../src/components/Switch.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../src/components/Switch.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA2BxC,CAAA"}
|
|
@@ -6,18 +6,14 @@ import { getClassMap } from '@molecule/app-ui';
|
|
|
6
6
|
* @param root0 - Component props.
|
|
7
7
|
* @param root0.label - Switch label text.
|
|
8
8
|
* @param root0.checked - Whether checked.
|
|
9
|
-
* @param root0.
|
|
9
|
+
* @param root0.onCheckedChange - Receives the new checked state.
|
|
10
10
|
* @param root0.size - Switch size (unused in RN).
|
|
11
11
|
* @param root0.disabled - Whether disabled.
|
|
12
12
|
* @param root0.className - CSS class name override.
|
|
13
13
|
* @param root0.testId - Test identifier.
|
|
14
14
|
* @returns The rendered Switch element.
|
|
15
15
|
*/
|
|
16
|
-
export const Switch = ({ label, checked,
|
|
16
|
+
export const Switch = ({ label, checked, onCheckedChange, size: _size = 'md', disabled, className, testId, }) => {
|
|
17
17
|
const cm = getClassMap();
|
|
18
|
-
return (_jsxs(View, { className: cm.cn(cm.controlLabel, className), testID: testId, children: [_jsx(RNSwitch, { value: !!checked, onValueChange: (
|
|
19
|
-
if (onChange) {
|
|
20
|
-
onChange({ target: { checked: value } });
|
|
21
|
-
}
|
|
22
|
-
}, disabled: disabled, accessibilityRole: "switch", accessibilityState: { checked: !!checked, disabled } }), !!label && (_jsx(Text, { className: cm.cn(cm.controlText, disabled && cm.controlDisabled), children: label }))] }));
|
|
18
|
+
return (_jsxs(View, { className: cm.cn(cm.controlLabel, className), testID: testId, children: [_jsx(RNSwitch, { value: !!checked, onValueChange: onCheckedChange, disabled: disabled, accessibilityRole: "switch", accessibilityState: { checked: !!checked, disabled } }), !!label && (_jsx(Text, { className: cm.cn(cm.controlText, disabled && cm.controlDisabled), children: label }))] }));
|
|
23
19
|
};
|
|
@@ -5,9 +5,20 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { TextInput } from 'react-native';
|
|
8
|
-
import type { TextareaProps } from '@molecule/app-ui';
|
|
9
8
|
/**
|
|
10
9
|
* Multi-line text input component.
|
|
11
10
|
*/
|
|
12
|
-
export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps &
|
|
11
|
+
export declare const Textarea: React.ForwardRefExoticComponent<Omit<import("@molecule/app-ui").TextareaProps, "onChange" | "onClick" | "onDoubleClick" | "onMouseEnter" | "onMouseLeave" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "onKeyPress" | "onInput"> & {
|
|
12
|
+
onChange?: undefined;
|
|
13
|
+
onClick?: undefined;
|
|
14
|
+
onDoubleClick?: undefined;
|
|
15
|
+
onMouseEnter?: undefined;
|
|
16
|
+
onMouseLeave?: undefined;
|
|
17
|
+
onFocus?: (() => void) | undefined;
|
|
18
|
+
onBlur?: (() => void) | undefined;
|
|
19
|
+
onKeyDown?: undefined;
|
|
20
|
+
onKeyUp?: undefined;
|
|
21
|
+
onKeyPress?: undefined;
|
|
22
|
+
onInput?: undefined;
|
|
23
|
+
} & React.RefAttributes<TextInput>>;
|
|
13
24
|
//# sourceMappingURL=Textarea.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../src/components/Textarea.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAA;AACzC,OAAO,EAAQ,SAAS,EAAQ,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../src/components/Textarea.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAA;AACzC,OAAO,EAAQ,SAAS,EAAQ,MAAM,cAAc,CAAA;AAMpD;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;mCAmDpB,CAAA"}
|
|
@@ -10,12 +10,8 @@ import { getClassMap } from '@molecule/app-ui';
|
|
|
10
10
|
/**
|
|
11
11
|
* Multi-line text input component.
|
|
12
12
|
*/
|
|
13
|
-
export const Textarea = forwardRef(({ label, error, hint, rows = 3, className, style, testId, disabled, placeholder, value,
|
|
13
|
+
export const Textarea = forwardRef(({ label, error, hint, rows = 3, className, style, testId, disabled, placeholder, value, onValueChange, onFocus, onBlur, required, }, ref) => {
|
|
14
14
|
const cm = getClassMap();
|
|
15
15
|
const classes = cm.cn(cm.textarea({ error: !!error }), className);
|
|
16
|
-
return (_jsxs(View, { className: cm.inputWrapper, children: [!!label && (_jsx(Text, { className: cm.cn(cm.labelBlock, cm.label({ required: !!required })), children: label })), _jsx(TextInput, { ref: ref, className: classes, style: style, testID: testId, editable: !disabled, placeholder: placeholder, value: value, multiline: true, numberOfLines: rows, textAlignVertical: "top", onChangeText: (
|
|
17
|
-
if (onChange) {
|
|
18
|
-
onChange({ target: { value: text } });
|
|
19
|
-
}
|
|
20
|
-
}, onFocus: onFocus, onBlur: onBlur, accessibilityLabel: typeof label === 'string' ? label : undefined }), !!error && typeof error === 'string' && _jsx(Text, { className: cm.formError, children: error }), !!hint && !error && _jsx(Text, { className: cm.formHint, children: hint })] }));
|
|
16
|
+
return (_jsxs(View, { className: cm.inputWrapper, children: [!!label && (_jsx(Text, { className: cm.cn(cm.labelBlock, cm.label({ required: !!required })), children: label })), _jsx(TextInput, { ref: ref, className: classes, style: style, testID: testId, editable: !disabled, placeholder: placeholder, value: value, multiline: true, numberOfLines: rows, textAlignVertical: "top", onChangeText: onValueChange, onFocus: onFocus ? () => onFocus() : undefined, onBlur: onBlur ? () => onBlur() : undefined, accessibilityLabel: typeof label === 'string' ? label : undefined }), !!error && typeof error === 'string' && _jsx(Text, { className: cm.formError, children: error }), !!hint && !error && _jsx(Text, { className: cm.formHint, children: hint })] }));
|
|
21
17
|
});
|
|
@@ -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"}
|