@gild-ui/react-native 0.0.0 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +79 -2
- package/dist/Button.cjs +193 -0
- package/dist/Button.d.cts +3 -0
- package/dist/Button.d.mts +3 -0
- package/dist/Button.mjs +192 -0
- package/dist/Button.types-Bb9gBlbS.d.mts +1402 -0
- package/dist/Flex.cjs +18 -0
- package/dist/Flex.d.cts +2 -0
- package/dist/Flex.d.mts +2 -0
- package/dist/Flex.mjs +17 -0
- package/dist/Modal.cjs +56 -0
- package/dist/Modal.d.cts +7 -0
- package/dist/Modal.d.mts +7 -0
- package/dist/Modal.mjs +55 -0
- package/dist/TextInput.cjs +169 -0
- package/dist/TextInput.d.cts +3 -0
- package/dist/TextInput.d.mts +3 -0
- package/dist/TextInput.mjs +169 -0
- package/dist/ThemeProvider-BgTIjOfL.mjs +49 -0
- package/dist/ThemeProvider-CsfZi16_.cjs +53 -0
- package/dist/ThemeProvider.cjs +3 -0
- package/dist/ThemeProvider.d.cts +2 -0
- package/dist/ThemeProvider.d.mts +2 -0
- package/dist/ThemeProvider.mjs +1 -0
- package/dist/Typography.cjs +68 -0
- package/dist/Typography.d.cts +3 -0
- package/dist/Typography.d.mts +3 -0
- package/dist/Typography.mjs +68 -0
- package/dist/View-B1PzjpDr.cjs +76 -0
- package/dist/View-tHL6rDa8.mjs +65 -0
- package/dist/View.cjs +3 -0
- package/dist/View.d.cts +2 -0
- package/dist/View.d.mts +2 -0
- package/dist/View.mjs +1 -0
- package/dist/bridge-B_MGN7QY.d.mts +10 -0
- package/dist/bridge-CH-RnxIe.d.cts +10 -0
- package/dist/engine-CpEhmg4W.mjs +38 -0
- package/dist/engine-D9Z9l9JU.cjs +42 -0
- package/dist/engine.cjs +49 -0
- package/dist/engine.d.cts +66 -0
- package/dist/engine.d.mts +66 -0
- package/dist/engine.mjs +19 -0
- package/dist/exact-DOxXx2ZR.d.cts +9 -0
- package/dist/exact-DOxXx2ZR.d.mts +9 -0
- package/dist/index-BqhozwWy.d.mts +41 -0
- package/dist/index-DcHJkXar.d.cts +41 -0
- package/dist/index.cjs +67 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.mjs +5 -0
- package/dist/phoneTheme-RIafDzgw.mjs +12 -0
- package/dist/phoneTheme-kvZTk6l5.cjs +29 -0
- package/dist/styled-CmWGOVKb.cjs +174 -0
- package/dist/styled-k66N0ABX.mjs +163 -0
- package/dist/themes-DK6h0IiW.d.cts +1402 -0
- package/dist/themes-rGHVhV5e.mjs +8 -0
- package/dist/useDefaultProps-1josiKIp.mjs +13 -0
- package/dist/useDefaultProps-DzaUOADT.cjs +18 -0
- package/dist/useTheme.cjs +8 -0
- package/dist/useTheme.d.cts +3 -0
- package/dist/useTheme.d.mts +3 -0
- package/dist/useTheme.mjs +1 -0
- package/package.json +168 -4
package/dist/Flex.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_styled = require("./styled-CmWGOVKb.cjs");
|
|
3
|
+
const require_View = require("./View-B1PzjpDr.cjs");
|
|
4
|
+
let _soroush_tech_styled_system = require("@soroush.tech/styled-system");
|
|
5
|
+
let _soroush_tech_styled_system_should_forward_prop = require("@soroush.tech/styled-system/should-forward-prop");
|
|
6
|
+
// ../react/src/Flex/Flex.tsx
|
|
7
|
+
const shouldForwardProp = (0, _soroush_tech_styled_system_should_forward_prop.createShouldForwardProp)([..._soroush_tech_styled_system_should_forward_prop.props, "layout"]);
|
|
8
|
+
const FlexRoot = require_styled.styled(require_View.View, {
|
|
9
|
+
name: "Flex",
|
|
10
|
+
label: "flex",
|
|
11
|
+
shouldForwardProp,
|
|
12
|
+
systemProps: [_soroush_tech_styled_system.flexbox, _soroush_tech_styled_system.space]
|
|
13
|
+
})({
|
|
14
|
+
display: "flex",
|
|
15
|
+
flexDirection: "column"
|
|
16
|
+
});
|
|
17
|
+
const Flex = require_View.withRootOverrides(FlexRoot);
|
|
18
|
+
exports.Flex = Flex;
|
package/dist/Flex.d.cts
ADDED
package/dist/Flex.d.mts
ADDED
package/dist/Flex.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { t as styled } from "./styled-k66N0ABX.mjs";
|
|
2
|
+
import { n as withRootOverrides, t as View } from "./View-tHL6rDa8.mjs";
|
|
3
|
+
import { flexbox, space } from "@soroush.tech/styled-system";
|
|
4
|
+
import { createShouldForwardProp, props } from "@soroush.tech/styled-system/should-forward-prop";
|
|
5
|
+
// ../react/src/Flex/Flex.tsx
|
|
6
|
+
const shouldForwardProp = createShouldForwardProp([...props, "layout"]);
|
|
7
|
+
const FlexRoot = styled(View, {
|
|
8
|
+
name: "Flex",
|
|
9
|
+
label: "flex",
|
|
10
|
+
shouldForwardProp,
|
|
11
|
+
systemProps: [flexbox, space]
|
|
12
|
+
})({
|
|
13
|
+
display: "flex",
|
|
14
|
+
flexDirection: "column"
|
|
15
|
+
});
|
|
16
|
+
const Flex = withRootOverrides(FlexRoot);
|
|
17
|
+
export { Flex };
|
package/dist/Modal.cjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_styled = require("./styled-CmWGOVKb.cjs");
|
|
3
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
|
+
let react_native = require("react-native");
|
|
5
|
+
// src/Modal/Modal.native.tsx
|
|
6
|
+
const ModalRoot = require_styled.styled("div", {
|
|
7
|
+
name: "Modal",
|
|
8
|
+
label: "Modal"
|
|
9
|
+
})({
|
|
10
|
+
flex: 1,
|
|
11
|
+
alignItems: "center",
|
|
12
|
+
justifyContent: "center"
|
|
13
|
+
});
|
|
14
|
+
const ModalBackdrop = require_styled.styled("button", { label: "ModalBackdrop" })(({ theme }) => ({
|
|
15
|
+
position: "absolute",
|
|
16
|
+
top: 0,
|
|
17
|
+
right: 0,
|
|
18
|
+
bottom: 0,
|
|
19
|
+
left: 0,
|
|
20
|
+
backgroundColor: theme.background.backdrop
|
|
21
|
+
}));
|
|
22
|
+
const closeEvent = (reason) => new Event(reason);
|
|
23
|
+
const takeFocus = (node) => {
|
|
24
|
+
const previous = document.activeElement;
|
|
25
|
+
node.focus();
|
|
26
|
+
return () => {
|
|
27
|
+
if (previous instanceof HTMLElement) previous.focus();
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* @description Accessible overlay primitive: the platform's modal, dimmed by a backdrop. It closes on
|
|
32
|
+
* the back button (`'escapeKey'`) and on a press of the backdrop (`'backdropClick'`).
|
|
33
|
+
*/
|
|
34
|
+
function Modal({ isOpen, children, onClose, hasBackdrop = true, style, className, slotProps }) {
|
|
35
|
+
const isWeb = react_native.Platform.OS === "web";
|
|
36
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Modal, {
|
|
37
|
+
visible: isOpen,
|
|
38
|
+
transparent: true,
|
|
39
|
+
animationType: "fade",
|
|
40
|
+
statusBarTranslucent: true,
|
|
41
|
+
onRequestClose: () => onClose?.(closeEvent("escapeKey"), "escapeKey"),
|
|
42
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ModalRoot, {
|
|
43
|
+
ref: isWeb ? takeFocus : void 0,
|
|
44
|
+
tabIndex: isWeb ? -1 : void 0,
|
|
45
|
+
...require_styled.mergeOverrides(slotProps?.root, {
|
|
46
|
+
style,
|
|
47
|
+
className
|
|
48
|
+
}),
|
|
49
|
+
children: [hasBackdrop ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModalBackdrop, {
|
|
50
|
+
"aria-hidden": true,
|
|
51
|
+
onClick: () => onClose?.(closeEvent("backdropClick"), "backdropClick")
|
|
52
|
+
}) : null, children]
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.Modal = Modal;
|
package/dist/Modal.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { C as ModalCloseReason, D as ModalSlot, E as ModalScroll, O as ModalThemeConfig, T as ModalProps, w as ModalOwnerState } from "./themes-DK6h0IiW.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* @description Accessible overlay primitive: the platform's modal, dimmed by a backdrop. It closes on
|
|
4
|
+
* the back button (`'escapeKey'`) and on a press of the backdrop (`'backdropClick'`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function Modal({ isOpen, children, onClose, hasBackdrop, style, className, slotProps }: Readonly<ModalProps>): import("react").JSX.Element;
|
|
7
|
+
export type { ModalCloseReason, ModalOwnerState, ModalProps, ModalScroll, ModalSlot, ModalThemeConfig };
|
package/dist/Modal.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { F as ModalProps, I as ModalScroll, L as ModalSlot, N as ModalCloseReason, P as ModalOwnerState, R as ModalThemeConfig } from "./Button.types-Bb9gBlbS.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* @description Accessible overlay primitive: the platform's modal, dimmed by a backdrop. It closes on
|
|
4
|
+
* the back button (`'escapeKey'`) and on a press of the backdrop (`'backdropClick'`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function Modal({ isOpen, children, onClose, hasBackdrop, style, className, slotProps }: Readonly<ModalProps>): import("react").JSX.Element;
|
|
7
|
+
export type { ModalCloseReason, ModalOwnerState, ModalProps, ModalScroll, ModalSlot, ModalThemeConfig };
|
package/dist/Modal.mjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { n as mergeOverrides, t as styled } from "./styled-k66N0ABX.mjs";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Modal as Modal$1, Platform } from "react-native";
|
|
4
|
+
// src/Modal/Modal.native.tsx
|
|
5
|
+
const ModalRoot = styled("div", {
|
|
6
|
+
name: "Modal",
|
|
7
|
+
label: "Modal"
|
|
8
|
+
})({
|
|
9
|
+
flex: 1,
|
|
10
|
+
alignItems: "center",
|
|
11
|
+
justifyContent: "center"
|
|
12
|
+
});
|
|
13
|
+
const ModalBackdrop = styled("button", { label: "ModalBackdrop" })(({ theme }) => ({
|
|
14
|
+
position: "absolute",
|
|
15
|
+
top: 0,
|
|
16
|
+
right: 0,
|
|
17
|
+
bottom: 0,
|
|
18
|
+
left: 0,
|
|
19
|
+
backgroundColor: theme.background.backdrop
|
|
20
|
+
}));
|
|
21
|
+
const closeEvent = (reason) => new Event(reason);
|
|
22
|
+
const takeFocus = (node) => {
|
|
23
|
+
const previous = document.activeElement;
|
|
24
|
+
node.focus();
|
|
25
|
+
return () => {
|
|
26
|
+
if (previous instanceof HTMLElement) previous.focus();
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @description Accessible overlay primitive: the platform's modal, dimmed by a backdrop. It closes on
|
|
31
|
+
* the back button (`'escapeKey'`) and on a press of the backdrop (`'backdropClick'`).
|
|
32
|
+
*/
|
|
33
|
+
function Modal({ isOpen, children, onClose, hasBackdrop = true, style, className, slotProps }) {
|
|
34
|
+
const isWeb = Platform.OS === "web";
|
|
35
|
+
return /* @__PURE__ */ jsx(Modal$1, {
|
|
36
|
+
visible: isOpen,
|
|
37
|
+
transparent: true,
|
|
38
|
+
animationType: "fade",
|
|
39
|
+
statusBarTranslucent: true,
|
|
40
|
+
onRequestClose: () => onClose?.(closeEvent("escapeKey"), "escapeKey"),
|
|
41
|
+
children: /* @__PURE__ */ jsxs(ModalRoot, {
|
|
42
|
+
ref: isWeb ? takeFocus : void 0,
|
|
43
|
+
tabIndex: isWeb ? -1 : void 0,
|
|
44
|
+
...mergeOverrides(slotProps?.root, {
|
|
45
|
+
style,
|
|
46
|
+
className
|
|
47
|
+
}),
|
|
48
|
+
children: [hasBackdrop ? /* @__PURE__ */ jsx(ModalBackdrop, {
|
|
49
|
+
"aria-hidden": true,
|
|
50
|
+
onClick: () => onClose?.(closeEvent("backdropClick"), "backdropClick")
|
|
51
|
+
}) : null, children]
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export { Modal };
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_engine = require("./engine-D9Z9l9JU.cjs");
|
|
3
|
+
const require_styled = require("./styled-CmWGOVKb.cjs");
|
|
4
|
+
let _umber_style_react_native = require("@umber-style/react-native");
|
|
5
|
+
let _gild_ui_core_theme = require("@gild-ui/core/theme");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let react = require("react");
|
|
8
|
+
let _soroush_tech_styled_system = require("@soroush.tech/styled-system");
|
|
9
|
+
let _soroush_tech_styled_system_should_forward_prop = require("@soroush.tech/styled-system/should-forward-prop");
|
|
10
|
+
// ../react/src/Form/FormContext.ts
|
|
11
|
+
const FormContext = (0, react.createContext)({});
|
|
12
|
+
// ../react/src/FormControl/FormControlContext.ts
|
|
13
|
+
const FormControlContext = (0, react.createContext)(null);
|
|
14
|
+
// ../react/src/FormControl/useFormControl.ts
|
|
15
|
+
/**
|
|
16
|
+
* Merges a control's explicit props with FormControl and Form context.
|
|
17
|
+
* Priority: explicit prop → FormControl → Form → default.
|
|
18
|
+
* `error` and `required` are field-only and never read from Form.
|
|
19
|
+
*/
|
|
20
|
+
function useFormControl(overrides = {}) {
|
|
21
|
+
const form = (0, react.useContext)(FormContext);
|
|
22
|
+
const control = (0, react.useContext)(FormControlContext);
|
|
23
|
+
const theme = (0, require_engine.engine_exports.useTheme)();
|
|
24
|
+
return {
|
|
25
|
+
id: overrides.id ?? control?.id,
|
|
26
|
+
error: overrides.error ?? control?.error ?? false,
|
|
27
|
+
disabled: overrides.disabled ?? control?.disabled ?? form.disabled ?? false,
|
|
28
|
+
required: overrides.required ?? control?.required ?? false,
|
|
29
|
+
size: overrides.size ?? control?.size ?? form.size ?? (0, _gild_ui_core_theme.themeDefault)(theme, "size", "md"),
|
|
30
|
+
fullWidth: overrides.fullWidth ?? control?.fullWidth ?? form.fullWidth ?? false,
|
|
31
|
+
color: overrides.color ?? control?.color ?? form.color,
|
|
32
|
+
textColor: overrides.textColor ?? control?.textColor ?? form.textColor,
|
|
33
|
+
"aria-describedby": control?.hasHelperText ? control.helperId : void 0,
|
|
34
|
+
labelId: control?.registeredLabelId ?? void 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
// src/TextInput/TextInput.native.tsx
|
|
38
|
+
const shouldForwardProp = (0, _soroush_tech_styled_system_should_forward_prop.createShouldForwardProp)([
|
|
39
|
+
..._soroush_tech_styled_system_should_forward_prop.props,
|
|
40
|
+
"as",
|
|
41
|
+
"color",
|
|
42
|
+
"variant",
|
|
43
|
+
"error",
|
|
44
|
+
"disabled",
|
|
45
|
+
"fullWidth",
|
|
46
|
+
"focused"
|
|
47
|
+
]);
|
|
48
|
+
const borderColor = ({ theme, color, error }, key) => error ? theme.palette.error.main : theme.palette[color][key];
|
|
49
|
+
const rootStyles = (root) => {
|
|
50
|
+
const { theme, variant = "default", borderRadius, fullWidth, disabled } = root;
|
|
51
|
+
const outline = {
|
|
52
|
+
borderStyle: "solid",
|
|
53
|
+
borderColor: borderColor(root, "light")
|
|
54
|
+
};
|
|
55
|
+
const borders = {
|
|
56
|
+
outlined: {
|
|
57
|
+
borderWidth: theme.borderWidths.thin,
|
|
58
|
+
...outline
|
|
59
|
+
},
|
|
60
|
+
underline: {
|
|
61
|
+
borderBottomWidth: theme.borderWidths.thin,
|
|
62
|
+
...outline
|
|
63
|
+
},
|
|
64
|
+
default: {},
|
|
65
|
+
text: {}
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
flexDirection: "row",
|
|
69
|
+
alignItems: "center",
|
|
70
|
+
minWidth: (0, _gild_ui_core_theme.themeDefault)(theme, "inputMinWidth", "12rem"),
|
|
71
|
+
backgroundColor: variant === "text" ? "transparent" : theme.background[(0, _gild_ui_core_theme.themeDefault)(theme, "inputBg", "terminal")],
|
|
72
|
+
...borders[variant],
|
|
73
|
+
...(variant === "default" || variant === "outlined") && borderRadius ? { borderRadius: theme.radii[borderRadius] } : {},
|
|
74
|
+
...fullWidth ? { width: "100%" } : {},
|
|
75
|
+
...disabled ? { opacity: .5 } : {},
|
|
76
|
+
...(0, _umber_style_react_native.at)((0, _umber_style_react_native.state)("focused"), { borderColor: borderColor(root, "main") })
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const TextInputRoot = require_styled.styled("div", {
|
|
80
|
+
name: "TextInput",
|
|
81
|
+
label: "TextInput",
|
|
82
|
+
shouldForwardProp,
|
|
83
|
+
systemProps: [_soroush_tech_styled_system.space, (0, _soroush_tech_styled_system.system)({
|
|
84
|
+
width: true,
|
|
85
|
+
minWidth: true,
|
|
86
|
+
maxWidth: true
|
|
87
|
+
})]
|
|
88
|
+
})((0, _umber_style_react_native.at)((0, _umber_style_react_native.state)("focused"), {}), rootStyles);
|
|
89
|
+
const shouldForwardInputProp = (prop) => ![
|
|
90
|
+
"size",
|
|
91
|
+
"color",
|
|
92
|
+
"textColor"
|
|
93
|
+
].includes(prop);
|
|
94
|
+
const StyledInput = require_styled.styled("input", {
|
|
95
|
+
name: "TextInput",
|
|
96
|
+
slot: "input",
|
|
97
|
+
label: "TextInputInput",
|
|
98
|
+
shouldForwardProp: shouldForwardInputProp
|
|
99
|
+
})(({ theme, size, color, textColor }) => {
|
|
100
|
+
const s = theme.sizes[size];
|
|
101
|
+
return {
|
|
102
|
+
flex: 1,
|
|
103
|
+
minWidth: 0,
|
|
104
|
+
paddingTop: theme.space[s.paddingTop],
|
|
105
|
+
paddingBottom: theme.space[s.paddingBottom],
|
|
106
|
+
paddingLeft: theme.space[s.paddingLeft],
|
|
107
|
+
paddingRight: theme.space[s.paddingRight],
|
|
108
|
+
fontSize: theme.fontSizes[s.fontSize],
|
|
109
|
+
color: textColor ? theme.text[textColor] : theme.palette[color].main
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
function TextInput({ autoComplete, autoFocus, borderRadius, color: colorProp, textColor: textColorProp, disabled: disabledProp, error: errorProp, fullWidth: fullWidthProp, id: idProp, inputProps, multiline = false, onChange, placeholder, readOnly, required: requiredProp, rows, size: sizeProp, type = "text", value, variant: variantProp, style, slotProps, "data-testid": dataTestid, className: _className, classes: _classes, components: _components, inputComponent: _inputComponent, inputSize: _inputSize, maxRows: _maxRows, minRows: _minRows, resize: _resize, name: _name, ...spaceProps }) {
|
|
113
|
+
const fc = useFormControl({
|
|
114
|
+
id: idProp,
|
|
115
|
+
error: errorProp,
|
|
116
|
+
disabled: disabledProp,
|
|
117
|
+
required: requiredProp,
|
|
118
|
+
size: sizeProp,
|
|
119
|
+
fullWidth: fullWidthProp,
|
|
120
|
+
color: colorProp,
|
|
121
|
+
textColor: textColorProp
|
|
122
|
+
});
|
|
123
|
+
const theme = (0, require_engine.engine_exports.useTheme)();
|
|
124
|
+
const color = fc.color ?? (0, _gild_ui_core_theme.themeDefault)(theme, "color", "primary");
|
|
125
|
+
const variant = variantProp ?? (0, _gild_ui_core_theme.themeDefault)(theme, "inputVariant", "default");
|
|
126
|
+
const [focused, setFocused] = (0, react.useState)(false);
|
|
127
|
+
const isMultiline = multiline || rows !== void 0 && Number(rows) > 1;
|
|
128
|
+
const { onFocus, onBlur } = inputProps ?? {};
|
|
129
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextInputRoot, {
|
|
130
|
+
color,
|
|
131
|
+
variant,
|
|
132
|
+
error: fc.error,
|
|
133
|
+
disabled: fc.disabled,
|
|
134
|
+
fullWidth: fc.fullWidth,
|
|
135
|
+
borderRadius,
|
|
136
|
+
focused,
|
|
137
|
+
...require_styled.mergeOverrides(slotProps?.root, { style }),
|
|
138
|
+
"data-testid": dataTestid,
|
|
139
|
+
...spaceProps,
|
|
140
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledInput, {
|
|
141
|
+
...inputProps,
|
|
142
|
+
as: isMultiline ? "textarea" : "input",
|
|
143
|
+
id: fc.id,
|
|
144
|
+
disabled: fc.disabled,
|
|
145
|
+
autoComplete,
|
|
146
|
+
autoFocus,
|
|
147
|
+
placeholder,
|
|
148
|
+
readOnly,
|
|
149
|
+
type,
|
|
150
|
+
rows: isMultiline && rows !== void 0 ? Number(rows) : void 0,
|
|
151
|
+
value: value === void 0 ? void 0 : String(value),
|
|
152
|
+
onChange,
|
|
153
|
+
size: fc.size,
|
|
154
|
+
color,
|
|
155
|
+
textColor: fc.textColor,
|
|
156
|
+
placeholderTextColor: (0, require_engine.engine_exports.alpha)(fc.textColor ? theme.text[fc.textColor] : theme.palette[color].main, .5),
|
|
157
|
+
...require_styled.mergeOverrides(slotProps?.input),
|
|
158
|
+
onFocus: (event) => {
|
|
159
|
+
setFocused(true);
|
|
160
|
+
onFocus?.(event);
|
|
161
|
+
},
|
|
162
|
+
onBlur: (event) => {
|
|
163
|
+
setFocused(false);
|
|
164
|
+
onBlur?.(event);
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
exports.TextInput = TextInput;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { S as TextInputVariant, _ as TextInputProps, b as TextInputTextColor, g as TextInputOwnerState, h as TextInputColor, m as TextInputClasses, v as TextInputSize, x as TextInputThemeConfig, y as TextInputSlot } from "./themes-DK6h0IiW.cjs";
|
|
2
|
+
export declare function TextInput({ autoComplete, autoFocus, borderRadius, color: colorProp, textColor: textColorProp, disabled: disabledProp, error: errorProp, fullWidth: fullWidthProp, id: idProp, inputProps, multiline, onChange, placeholder, readOnly, required: requiredProp, rows, size: sizeProp, type, value, variant: variantProp, style, slotProps, 'data-testid': dataTestid, className: _className, classes: _classes, components: _components, inputComponent: _inputComponent, inputSize: _inputSize, maxRows: _maxRows, minRows: _minRows, resize: _resize, name: _name, ...spaceProps }: Readonly<TextInputProps>): import("react").JSX.Element;
|
|
3
|
+
export type { TextInputClasses, TextInputColor, TextInputOwnerState, TextInputProps, TextInputSize, TextInputSlot, TextInputTextColor, TextInputThemeConfig, TextInputVariant };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { A as TextInputTextColor, D as TextInputProps, E as TextInputOwnerState, M as TextInputVariant, O as TextInputSize, T as TextInputColor, j as TextInputThemeConfig, k as TextInputSlot, w as TextInputClasses } from "./Button.types-Bb9gBlbS.mjs";
|
|
2
|
+
export declare function TextInput({ autoComplete, autoFocus, borderRadius, color: colorProp, textColor: textColorProp, disabled: disabledProp, error: errorProp, fullWidth: fullWidthProp, id: idProp, inputProps, multiline, onChange, placeholder, readOnly, required: requiredProp, rows, size: sizeProp, type, value, variant: variantProp, style, slotProps, 'data-testid': dataTestid, className: _className, classes: _classes, components: _components, inputComponent: _inputComponent, inputSize: _inputSize, maxRows: _maxRows, minRows: _minRows, resize: _resize, name: _name, ...spaceProps }: Readonly<TextInputProps>): import("react").JSX.Element;
|
|
3
|
+
export type { TextInputClasses, TextInputColor, TextInputOwnerState, TextInputProps, TextInputSize, TextInputSlot, TextInputTextColor, TextInputThemeConfig, TextInputVariant };
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import "./themes-rGHVhV5e.mjs";
|
|
2
|
+
import { t as engine_exports } from "./engine-CpEhmg4W.mjs";
|
|
3
|
+
import { n as mergeOverrides, t as styled$1 } from "./styled-k66N0ABX.mjs";
|
|
4
|
+
import { at, state } from "@umber-style/react-native";
|
|
5
|
+
import { themeDefault } from "@gild-ui/core/theme";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { createContext, useContext, useState } from "react";
|
|
8
|
+
import { space, system } from "@soroush.tech/styled-system";
|
|
9
|
+
import { createShouldForwardProp, props } from "@soroush.tech/styled-system/should-forward-prop";
|
|
10
|
+
// ../react/src/Form/FormContext.ts
|
|
11
|
+
const FormContext = createContext({});
|
|
12
|
+
// ../react/src/FormControl/FormControlContext.ts
|
|
13
|
+
const FormControlContext = createContext(null);
|
|
14
|
+
// ../react/src/FormControl/useFormControl.ts
|
|
15
|
+
/**
|
|
16
|
+
* Merges a control's explicit props with FormControl and Form context.
|
|
17
|
+
* Priority: explicit prop → FormControl → Form → default.
|
|
18
|
+
* `error` and `required` are field-only and never read from Form.
|
|
19
|
+
*/
|
|
20
|
+
function useFormControl(overrides = {}) {
|
|
21
|
+
const form = useContext(FormContext);
|
|
22
|
+
const control = useContext(FormControlContext);
|
|
23
|
+
const theme = (0, engine_exports.useTheme)();
|
|
24
|
+
return {
|
|
25
|
+
id: overrides.id ?? control?.id,
|
|
26
|
+
error: overrides.error ?? control?.error ?? false,
|
|
27
|
+
disabled: overrides.disabled ?? control?.disabled ?? form.disabled ?? false,
|
|
28
|
+
required: overrides.required ?? control?.required ?? false,
|
|
29
|
+
size: overrides.size ?? control?.size ?? form.size ?? themeDefault(theme, "size", "md"),
|
|
30
|
+
fullWidth: overrides.fullWidth ?? control?.fullWidth ?? form.fullWidth ?? false,
|
|
31
|
+
color: overrides.color ?? control?.color ?? form.color,
|
|
32
|
+
textColor: overrides.textColor ?? control?.textColor ?? form.textColor,
|
|
33
|
+
"aria-describedby": control?.hasHelperText ? control.helperId : void 0,
|
|
34
|
+
labelId: control?.registeredLabelId ?? void 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
// src/TextInput/TextInput.native.tsx
|
|
38
|
+
const shouldForwardProp = createShouldForwardProp([
|
|
39
|
+
...props,
|
|
40
|
+
"as",
|
|
41
|
+
"color",
|
|
42
|
+
"variant",
|
|
43
|
+
"error",
|
|
44
|
+
"disabled",
|
|
45
|
+
"fullWidth",
|
|
46
|
+
"focused"
|
|
47
|
+
]);
|
|
48
|
+
const borderColor = ({ theme, color, error }, key) => error ? theme.palette.error.main : theme.palette[color][key];
|
|
49
|
+
const rootStyles = (root) => {
|
|
50
|
+
const { theme, variant = "default", borderRadius, fullWidth, disabled } = root;
|
|
51
|
+
const outline = {
|
|
52
|
+
borderStyle: "solid",
|
|
53
|
+
borderColor: borderColor(root, "light")
|
|
54
|
+
};
|
|
55
|
+
const borders = {
|
|
56
|
+
outlined: {
|
|
57
|
+
borderWidth: theme.borderWidths.thin,
|
|
58
|
+
...outline
|
|
59
|
+
},
|
|
60
|
+
underline: {
|
|
61
|
+
borderBottomWidth: theme.borderWidths.thin,
|
|
62
|
+
...outline
|
|
63
|
+
},
|
|
64
|
+
default: {},
|
|
65
|
+
text: {}
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
flexDirection: "row",
|
|
69
|
+
alignItems: "center",
|
|
70
|
+
minWidth: themeDefault(theme, "inputMinWidth", "12rem"),
|
|
71
|
+
backgroundColor: variant === "text" ? "transparent" : theme.background[themeDefault(theme, "inputBg", "terminal")],
|
|
72
|
+
...borders[variant],
|
|
73
|
+
...(variant === "default" || variant === "outlined") && borderRadius ? { borderRadius: theme.radii[borderRadius] } : {},
|
|
74
|
+
...fullWidth ? { width: "100%" } : {},
|
|
75
|
+
...disabled ? { opacity: .5 } : {},
|
|
76
|
+
...at(state("focused"), { borderColor: borderColor(root, "main") })
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const TextInputRoot = styled$1("div", {
|
|
80
|
+
name: "TextInput",
|
|
81
|
+
label: "TextInput",
|
|
82
|
+
shouldForwardProp,
|
|
83
|
+
systemProps: [space, system({
|
|
84
|
+
width: true,
|
|
85
|
+
minWidth: true,
|
|
86
|
+
maxWidth: true
|
|
87
|
+
})]
|
|
88
|
+
})(at(state("focused"), {}), rootStyles);
|
|
89
|
+
const shouldForwardInputProp = (prop) => ![
|
|
90
|
+
"size",
|
|
91
|
+
"color",
|
|
92
|
+
"textColor"
|
|
93
|
+
].includes(prop);
|
|
94
|
+
const StyledInput = styled$1("input", {
|
|
95
|
+
name: "TextInput",
|
|
96
|
+
slot: "input",
|
|
97
|
+
label: "TextInputInput",
|
|
98
|
+
shouldForwardProp: shouldForwardInputProp
|
|
99
|
+
})(({ theme, size, color, textColor }) => {
|
|
100
|
+
const s = theme.sizes[size];
|
|
101
|
+
return {
|
|
102
|
+
flex: 1,
|
|
103
|
+
minWidth: 0,
|
|
104
|
+
paddingTop: theme.space[s.paddingTop],
|
|
105
|
+
paddingBottom: theme.space[s.paddingBottom],
|
|
106
|
+
paddingLeft: theme.space[s.paddingLeft],
|
|
107
|
+
paddingRight: theme.space[s.paddingRight],
|
|
108
|
+
fontSize: theme.fontSizes[s.fontSize],
|
|
109
|
+
color: textColor ? theme.text[textColor] : theme.palette[color].main
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
function TextInput({ autoComplete, autoFocus, borderRadius, color: colorProp, textColor: textColorProp, disabled: disabledProp, error: errorProp, fullWidth: fullWidthProp, id: idProp, inputProps, multiline = false, onChange, placeholder, readOnly, required: requiredProp, rows, size: sizeProp, type = "text", value, variant: variantProp, style, slotProps, "data-testid": dataTestid, className: _className, classes: _classes, components: _components, inputComponent: _inputComponent, inputSize: _inputSize, maxRows: _maxRows, minRows: _minRows, resize: _resize, name: _name, ...spaceProps }) {
|
|
113
|
+
const fc = useFormControl({
|
|
114
|
+
id: idProp,
|
|
115
|
+
error: errorProp,
|
|
116
|
+
disabled: disabledProp,
|
|
117
|
+
required: requiredProp,
|
|
118
|
+
size: sizeProp,
|
|
119
|
+
fullWidth: fullWidthProp,
|
|
120
|
+
color: colorProp,
|
|
121
|
+
textColor: textColorProp
|
|
122
|
+
});
|
|
123
|
+
const theme = (0, engine_exports.useTheme)();
|
|
124
|
+
const color = fc.color ?? themeDefault(theme, "color", "primary");
|
|
125
|
+
const variant = variantProp ?? themeDefault(theme, "inputVariant", "default");
|
|
126
|
+
const [focused, setFocused] = useState(false);
|
|
127
|
+
const isMultiline = multiline || rows !== void 0 && Number(rows) > 1;
|
|
128
|
+
const { onFocus, onBlur } = inputProps ?? {};
|
|
129
|
+
return /* @__PURE__ */ jsx(TextInputRoot, {
|
|
130
|
+
color,
|
|
131
|
+
variant,
|
|
132
|
+
error: fc.error,
|
|
133
|
+
disabled: fc.disabled,
|
|
134
|
+
fullWidth: fc.fullWidth,
|
|
135
|
+
borderRadius,
|
|
136
|
+
focused,
|
|
137
|
+
...mergeOverrides(slotProps?.root, { style }),
|
|
138
|
+
"data-testid": dataTestid,
|
|
139
|
+
...spaceProps,
|
|
140
|
+
children: /* @__PURE__ */ jsx(StyledInput, {
|
|
141
|
+
...inputProps,
|
|
142
|
+
as: isMultiline ? "textarea" : "input",
|
|
143
|
+
id: fc.id,
|
|
144
|
+
disabled: fc.disabled,
|
|
145
|
+
autoComplete,
|
|
146
|
+
autoFocus,
|
|
147
|
+
placeholder,
|
|
148
|
+
readOnly,
|
|
149
|
+
type,
|
|
150
|
+
rows: isMultiline && rows !== void 0 ? Number(rows) : void 0,
|
|
151
|
+
value: value === void 0 ? void 0 : String(value),
|
|
152
|
+
onChange,
|
|
153
|
+
size: fc.size,
|
|
154
|
+
color,
|
|
155
|
+
textColor: fc.textColor,
|
|
156
|
+
placeholderTextColor: (0, engine_exports.alpha)(fc.textColor ? theme.text[fc.textColor] : theme.palette[color].main, .5),
|
|
157
|
+
...mergeOverrides(slotProps?.input),
|
|
158
|
+
onFocus: (event) => {
|
|
159
|
+
setFocused(true);
|
|
160
|
+
onFocus?.(event);
|
|
161
|
+
},
|
|
162
|
+
onBlur: (event) => {
|
|
163
|
+
setFocused(false);
|
|
164
|
+
onBlur?.(event);
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
export { TextInput };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { t as baseTheme$1 } from "./themes-rGHVhV5e.mjs";
|
|
2
|
+
import { t as phoneTheme } from "./phoneTheme-RIafDzgw.mjs";
|
|
3
|
+
import { ThemeProvider as ThemeProvider$1 } from "@umber-style/react-native";
|
|
4
|
+
import { createTheme } from "@gild-ui/core/theme";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// ../react/src/theme/derivedTheme.ts
|
|
7
|
+
/**
|
|
8
|
+
* A function that gives the same result for the same two objects, so a provider hands the engine
|
|
9
|
+
* the same theme object on every render. The engine keeps a theme's declarations by the object,
|
|
10
|
+
* and on a server `useMemo` keeps nothing between renders: a theme made anew each render is
|
|
11
|
+
* declared anew each render.
|
|
12
|
+
*/
|
|
13
|
+
function derivedBy(derive) {
|
|
14
|
+
const results = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
return (first, second) => {
|
|
16
|
+
let bySecond = results.get(first);
|
|
17
|
+
if (!bySecond) {
|
|
18
|
+
bySecond = /* @__PURE__ */ new WeakMap();
|
|
19
|
+
results.set(first, bySecond);
|
|
20
|
+
}
|
|
21
|
+
let result = bySecond.get(second);
|
|
22
|
+
if (!result) {
|
|
23
|
+
result = derive(first, second);
|
|
24
|
+
bySecond.set(second, result);
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// src/ThemeProvider/ThemeProvider.tsx
|
|
30
|
+
const noDefaults = {};
|
|
31
|
+
const known = /* @__PURE__ */ new Map();
|
|
32
|
+
const sameDefaults = (defaults) => {
|
|
33
|
+
const key = JSON.stringify(defaults);
|
|
34
|
+
const first = known.get(key);
|
|
35
|
+
if (first) return first;
|
|
36
|
+
known.set(key, defaults);
|
|
37
|
+
return defaults;
|
|
38
|
+
};
|
|
39
|
+
const withDefaults = derivedBy((theme, defaults) => {
|
|
40
|
+
if (defaults !== noDefaults) return phoneTheme(createTheme(theme, { defaults }));
|
|
41
|
+
return phoneTheme("up" in theme.breakpoints ? theme : createTheme(theme, {}));
|
|
42
|
+
});
|
|
43
|
+
function ThemeProvider({ children, theme, defaults }) {
|
|
44
|
+
return /* @__PURE__ */ jsx(ThemeProvider$1, {
|
|
45
|
+
theme: withDefaults(theme ?? baseTheme$1, defaults ? sameDefaults(defaults) : noDefaults),
|
|
46
|
+
children
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export { ThemeProvider as t };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const require_phoneTheme = require("./phoneTheme-kvZTk6l5.cjs");
|
|
2
|
+
let _umber_style_react_native = require("@umber-style/react-native");
|
|
3
|
+
let _gild_ui_core_theme = require("@gild-ui/core/theme");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
// ../react/src/theme/derivedTheme.ts
|
|
6
|
+
/**
|
|
7
|
+
* A function that gives the same result for the same two objects, so a provider hands the engine
|
|
8
|
+
* the same theme object on every render. The engine keeps a theme's declarations by the object,
|
|
9
|
+
* and on a server `useMemo` keeps nothing between renders: a theme made anew each render is
|
|
10
|
+
* declared anew each render.
|
|
11
|
+
*/
|
|
12
|
+
function derivedBy(derive) {
|
|
13
|
+
const results = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
return (first, second) => {
|
|
15
|
+
let bySecond = results.get(first);
|
|
16
|
+
if (!bySecond) {
|
|
17
|
+
bySecond = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
results.set(first, bySecond);
|
|
19
|
+
}
|
|
20
|
+
let result = bySecond.get(second);
|
|
21
|
+
if (!result) {
|
|
22
|
+
result = derive(first, second);
|
|
23
|
+
bySecond.set(second, result);
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// src/ThemeProvider/ThemeProvider.tsx
|
|
29
|
+
const noDefaults = {};
|
|
30
|
+
const known = /* @__PURE__ */ new Map();
|
|
31
|
+
const sameDefaults = (defaults) => {
|
|
32
|
+
const key = JSON.stringify(defaults);
|
|
33
|
+
const first = known.get(key);
|
|
34
|
+
if (first) return first;
|
|
35
|
+
known.set(key, defaults);
|
|
36
|
+
return defaults;
|
|
37
|
+
};
|
|
38
|
+
const withDefaults = derivedBy((theme, defaults) => {
|
|
39
|
+
if (defaults !== noDefaults) return require_phoneTheme.phoneTheme((0, _gild_ui_core_theme.createTheme)(theme, { defaults }));
|
|
40
|
+
return require_phoneTheme.phoneTheme("up" in theme.breakpoints ? theme : (0, _gild_ui_core_theme.createTheme)(theme, {}));
|
|
41
|
+
});
|
|
42
|
+
function ThemeProvider({ children, theme, defaults }) {
|
|
43
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_umber_style_react_native.ThemeProvider, {
|
|
44
|
+
theme: withDefaults(theme ?? require_phoneTheme.baseTheme, defaults ? sameDefaults(defaults) : noDefaults),
|
|
45
|
+
children
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
Object.defineProperty(exports, "ThemeProvider", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function() {
|
|
51
|
+
return ThemeProvider;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as ThemeProvider } from "./ThemeProvider-BgTIjOfL.mjs";
|