@tecsinapse/react-native-kit 3.4.1 → 3.5.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/LICENSE.md +1 -1
- package/README.md +9 -7
- package/dist/cjs/components/atoms/Modal/ModalGroupManager.js +1 -0
- package/dist/cjs/components/atoms/Modal/ModalLifecycleHandler.js +5 -0
- package/dist/cjs/components/atoms/Modal/ui/BaseModalView.js +3 -6
- package/dist/cjs/components/molecules/Select/Select.js +42 -157
- package/dist/cjs/components/molecules/Select/components/Flat.js +24 -0
- package/dist/cjs/components/molecules/Select/components/Modal.js +96 -0
- package/dist/cjs/components/molecules/Select/components/Option.js +50 -0
- package/dist/cjs/components/molecules/Select/components/Section.js +29 -0
- package/dist/cjs/components/molecules/Select/functions.js +43 -0
- package/dist/cjs/components/molecules/Select/hooks/useModal.js +109 -0
- package/dist/cjs/components/molecules/Select/hooks/useSelect.js +147 -0
- package/dist/cjs/components/molecules/Select/styled.js +12 -2
- package/dist/esm/components/atoms/Modal/ModalGroupManager.js +1 -0
- package/dist/esm/components/atoms/Modal/ModalLifecycleHandler.js +5 -0
- package/dist/esm/components/atoms/Modal/ui/BaseModalView.js +3 -6
- package/dist/esm/components/molecules/Select/Select.js +44 -141
- package/dist/esm/components/molecules/Select/components/Flat.js +22 -0
- package/dist/esm/components/molecules/Select/components/Modal.js +94 -0
- package/dist/esm/components/molecules/Select/components/Option.js +48 -0
- package/dist/esm/components/molecules/Select/components/Section.js +27 -0
- package/dist/esm/components/molecules/Select/functions.js +35 -0
- package/dist/esm/components/molecules/Select/hooks/useModal.js +107 -0
- package/dist/esm/components/molecules/Select/hooks/useSelect.js +145 -0
- package/dist/esm/components/molecules/Select/styled.js +11 -3
- package/dist/types/components/atoms/Modal/ModalLifecycleHandler.d.ts +1 -0
- package/dist/types/components/molecules/Select/Select.d.ts +2 -23
- package/dist/types/components/molecules/Select/components/Flat.d.ts +8 -0
- package/dist/types/components/molecules/Select/components/Modal.d.ts +4 -0
- package/dist/types/components/molecules/Select/components/Option.d.ts +10 -0
- package/dist/types/components/molecules/Select/components/Section.d.ts +8 -0
- package/dist/types/components/molecules/Select/functions.d.ts +9 -0
- package/dist/types/components/molecules/Select/hooks/useModal.d.ts +66 -0
- package/dist/types/components/molecules/Select/hooks/useSelect.d.ts +58 -0
- package/dist/types/components/molecules/Select/index.d.ts +1 -1
- package/dist/types/components/molecules/Select/styled.d.ts +12 -0
- package/dist/types/components/molecules/Select/types.d.ts +33 -0
- package/package.json +9 -6
- package/dist/cjs/components/molecules/Select/Modal.js +0 -224
- package/dist/esm/components/molecules/Select/Modal.js +0 -203
- package/dist/types/components/molecules/Select/Modal.d.ts +0 -8
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://github.com/tecsinapse/design-system/) [](./LICENSE.md) [](CODE_OF_CONDUCT.md)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
[TecSinapse Design System](https://tecsinapse.github.io/design-system) is the hybrid implementation of the [TecSinapse](https://www.tecsinapse.com.br/) Design System.
|
|
7
|
+
[TecSinapse Design System](https://tecsinapse.github.io/design-system) is the hybrid implementation of the [TecSinapse](https://www.tecsinapse.com.br/) Design System.
|
|
9
8
|
Our primary goal is to create a system that can be used to build a wide variety of TecSinapase websites and apps, while providing a consistent and inclusive user experience to our end users.
|
|
10
9
|
In addition, the design system and component library should be easy to use for developers and designers.
|
|
11
10
|
|
|
@@ -24,11 +23,12 @@ Here are a few helpful links for getting started:
|
|
|
24
23
|
## Packages
|
|
25
24
|
|
|
26
25
|
| Package | Content | Version |
|
|
27
|
-
|
|
26
|
+
| --------------------------------------------------------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
28
27
|
| **[@tecsinapse/react-core](./packages/react-core)** | the core hybrid React component library | [](https://badge.fury.io/js/%40tecsinapse%2Freact-core) |
|
|
29
28
|
| **[@tecsinapse/react-web-kit](./packages/react-web-kit)** | the React component library focused on web | [](https://badge.fury.io/js/%40tecsinapse%2Freact-web-kit) |
|
|
30
29
|
| **[@tecsinapse/react-native-kit](./packages/react-native-kit)** | the React native component library focused on mobile | [](https://badge.fury.io/js/%40tecsinapse%2Freact-native-kit) |
|
|
31
30
|
| **[@tecsinapse/react-charts](./packages/react-charts)** | Charts for React based on SVG | [](https://badge.fury.io/js/%40tecsinapse%2Freact-charts) |
|
|
31
|
+
| **[@tecsinapse/cortex-core](./packages/cortex-core)** | The core library for tailwindcss based design | [](https://badge.fury.io/js/%40tecsinapse%2Fcortex-core) |
|
|
32
32
|
|
|
33
33
|
## Code of conduct
|
|
34
34
|
|
|
@@ -41,27 +41,29 @@ If you feel another member of the community violated our code or you are experie
|
|
|
41
41
|
At times, it may be necessary to test changes directly in a product, and not in the design system, and for this to work in a less laborious way, we can follow the steps below:
|
|
42
42
|
|
|
43
43
|
3 terminal tabs should open:
|
|
44
|
+
|
|
44
45
|
- In one run the JS code watch:
|
|
46
|
+
|
|
45
47
|
```
|
|
46
48
|
yarn build:watch
|
|
47
49
|
```
|
|
50
|
+
|
|
48
51
|
- In another run the watch of the TS code watch
|
|
52
|
+
|
|
49
53
|
```
|
|
50
54
|
yarn build:declarations:watch
|
|
51
55
|
```
|
|
56
|
+
|
|
52
57
|
- On another run yalc push (this script updates linked local projects)
|
|
58
|
+
|
|
53
59
|
```
|
|
54
60
|
yarn yalc:push
|
|
55
61
|
```
|
|
56
62
|
|
|
57
63
|
With that, all changes will be in yalc locally.
|
|
58
64
|
|
|
59
|
-
To access in your application, see this [example](https://github.com/tecsinapse/vendas-web-poc-playground#tools) in topic "**Yalc link Design System:**"
|
|
60
|
-
|
|
61
|
-
|
|
62
65
|
### Maintainers
|
|
63
66
|
|
|
64
|
-
- [Beatriz Silva](mailto:beatriz.silva@tecsinapse.com.br)
|
|
65
67
|
- [Denner Vidal](mailto:denner.vidal@tecsinapse.com.br)
|
|
66
68
|
- [Gabriel Sanches](mailto:gabriel.sanches@tecsinapse.com.br)
|
|
67
69
|
- [Lucas Ramos](mailto:lucas.ramos@tecsinapse.com.br)
|
|
@@ -121,6 +121,11 @@ class ModalLifecycleHandler {
|
|
|
121
121
|
savedNode && this.nodeGroup.set(id, { ...savedNode, visible: false });
|
|
122
122
|
this.update();
|
|
123
123
|
};
|
|
124
|
+
closeLastOpenedModal = () => {
|
|
125
|
+
const [modals] = this.state || [];
|
|
126
|
+
const lastModal = modals?.pop();
|
|
127
|
+
lastModal?.props?.close?.();
|
|
128
|
+
};
|
|
124
129
|
}
|
|
125
130
|
const createModalLifecycleHandler = () => {
|
|
126
131
|
return new ModalLifecycleHandler();
|
|
@@ -29,8 +29,7 @@ const ModalView = ({
|
|
|
29
29
|
const opacityCarrier = React.useRef(new reactNative.Animated.Value(0)).current;
|
|
30
30
|
const offset = isLastShown && keyboardOpened > 0 ? 0 : bottom;
|
|
31
31
|
const getKeyboardHeight = (keyboard) => {
|
|
32
|
-
if (keyboard === 0)
|
|
33
|
-
return 0;
|
|
32
|
+
if (keyboard === 0) return 0;
|
|
34
33
|
const wHeight = Math.ceil(reactNative.Dimensions.get("window").height);
|
|
35
34
|
const sHeight = Math.ceil(reactNative.Dimensions.get("screen").height);
|
|
36
35
|
if (wHeight !== sHeight) {
|
|
@@ -101,14 +100,12 @@ const ModalView = ({
|
|
|
101
100
|
[show, ready, visible, setReady]
|
|
102
101
|
);
|
|
103
102
|
React.useEffect(() => {
|
|
104
|
-
if (visible && ready)
|
|
105
|
-
requestAnimationFrame(() => show());
|
|
103
|
+
if (visible && ready) requestAnimationFrame(() => show());
|
|
106
104
|
if (!visible && !ready) {
|
|
107
105
|
reactNative.Keyboard.dismiss();
|
|
108
106
|
requestAnimationFrame(() => hide(boxHeight));
|
|
109
107
|
}
|
|
110
|
-
if (!visible && ready)
|
|
111
|
-
setReady(false);
|
|
108
|
+
if (!visible && ready) setReady(false);
|
|
112
109
|
}, [ready, visible]);
|
|
113
110
|
React.useEffect(() => {
|
|
114
111
|
const showEvent = reactNative.Keyboard.addListener(
|
|
@@ -2,158 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
var reactCore = require('@tecsinapse/react-core');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
require('react-native');
|
|
6
|
-
require('react-native-safe-area-context');
|
|
7
|
-
require('../../atoms/Modal/ui/styled.js');
|
|
8
|
-
var useLazyModalManager = require('../../atoms/Modal/useLazyModalManager.js');
|
|
9
5
|
var Text = require('../../atoms/Text/Text.js');
|
|
10
|
-
var Modal = require('./Modal.js');
|
|
6
|
+
var Modal = require('./components/Modal.js');
|
|
11
7
|
var styled = require('./styled.js');
|
|
8
|
+
var useSelect = require('./hooks/useSelect.js');
|
|
12
9
|
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
searchBarPlaceholder,
|
|
49
|
-
hideSearchBar,
|
|
50
|
-
confirmButtonText,
|
|
51
|
-
rightComponent,
|
|
52
|
-
variant = "default",
|
|
53
|
-
hintComponent,
|
|
54
|
-
hint,
|
|
55
|
-
style,
|
|
56
|
-
controlComponent,
|
|
57
|
-
closeOnPick = type === "single",
|
|
58
|
-
label,
|
|
59
|
-
numberOfLines,
|
|
60
|
-
...rest
|
|
61
|
-
}) {
|
|
62
|
-
const { focused, handleBlur, handleFocus } = reactCore.useInputFocus(
|
|
63
|
-
onFocus,
|
|
64
|
-
onBlur,
|
|
65
|
-
!disabled
|
|
66
|
-
);
|
|
67
|
-
const [selectOptions, setSelectOptions] = React.useState([]);
|
|
68
|
-
const modal = useLazyModalManager.useLazyModalManager();
|
|
69
|
-
const [loading, setLoading] = React.useState(false);
|
|
70
|
-
const onlyLabel = label && !placeholder;
|
|
71
|
-
const hasValue = type === "single" ? !!value : (value || []).length > 0;
|
|
72
|
-
const _placeholder = onlyLabel ? label : placeholder;
|
|
73
|
-
const _label = hasValue ? label : void 0;
|
|
74
|
-
React.useEffect(() => {
|
|
75
|
-
if (typeof options !== "function") {
|
|
76
|
-
setSelectOptions(options);
|
|
77
|
-
}
|
|
78
|
-
}, [options]);
|
|
79
|
-
const handleLazyFocus = React__namespace.useCallback(async () => {
|
|
80
|
-
if (typeof options === "function" && !onSearch) {
|
|
81
|
-
setLoading(true);
|
|
82
|
-
try {
|
|
83
|
-
const result = await options();
|
|
84
|
-
if (result) {
|
|
85
|
-
if (value && !result.find((v) => keyExtractor(value) === keyExtractor(v))) {
|
|
86
|
-
setSelectOptions([value, ...result]);
|
|
87
|
-
} else
|
|
88
|
-
setSelectOptions(result);
|
|
89
|
-
}
|
|
90
|
-
} catch (e) {
|
|
91
|
-
} finally {
|
|
92
|
-
setLoading(false);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}, [options, value, setSelectOptions]);
|
|
96
|
-
const handleOnSearch = React__namespace.useCallback(
|
|
97
|
-
async (searchInput) => {
|
|
98
|
-
if (searchInput !== void 0 && onSearch) {
|
|
99
|
-
setLoading(true);
|
|
100
|
-
modal.requestUpdate();
|
|
101
|
-
try {
|
|
102
|
-
const result = await onSearch(searchInput);
|
|
103
|
-
if (result) {
|
|
104
|
-
if (type === "single") {
|
|
105
|
-
if (value && !result.find(
|
|
106
|
-
(v) => keyExtractor(value) === keyExtractor(v)
|
|
107
|
-
)) {
|
|
108
|
-
setSelectOptions([value, ...result]);
|
|
109
|
-
} else
|
|
110
|
-
setSelectOptions(result);
|
|
111
|
-
} else {
|
|
112
|
-
if (value?.length) {
|
|
113
|
-
const selectedValues = value.filter(
|
|
114
|
-
(v) => !result.find(
|
|
115
|
-
(current) => keyExtractor(v) === keyExtractor(current)
|
|
116
|
-
)
|
|
117
|
-
) || [];
|
|
118
|
-
setSelectOptions([...selectedValues, ...result]);
|
|
119
|
-
} else {
|
|
120
|
-
setSelectOptions(result);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
} catch (e) {
|
|
125
|
-
} finally {
|
|
126
|
-
modal.requestUpdate();
|
|
127
|
-
setLoading(false);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
[options, value, keyExtractor]
|
|
132
|
-
);
|
|
133
|
-
const getDisplayValue = React__namespace.useCallback(() => {
|
|
134
|
-
if (Array.isArray(value)) {
|
|
135
|
-
if (value.length === 0)
|
|
136
|
-
return _placeholder;
|
|
137
|
-
else {
|
|
138
|
-
const options2 = selectOptions.length > 0 ? selectOptions : value;
|
|
139
|
-
return options2?.reduce(
|
|
140
|
-
(acc, option, index) => value.find(
|
|
141
|
-
(key) => keyExtractor(option, index) == keyExtractor(key, index)
|
|
142
|
-
) ? acc + labelExtractor(option) + ", " : acc,
|
|
143
|
-
""
|
|
144
|
-
).slice(0, -2);
|
|
145
|
-
}
|
|
146
|
-
} else {
|
|
147
|
-
if (!value)
|
|
148
|
-
return _placeholder;
|
|
149
|
-
const selectedOption = selectOptions?.find(
|
|
150
|
-
(option, index) => keyExtractor(option, index) == keyExtractor(value, index)
|
|
151
|
-
);
|
|
152
|
-
return labelExtractor(selectedOption ?? value);
|
|
153
|
-
}
|
|
154
|
-
}, [_placeholder, value, selectOptions]);
|
|
10
|
+
function Select(props) {
|
|
11
|
+
const {
|
|
12
|
+
groupKeyExtractor,
|
|
13
|
+
onSelect,
|
|
14
|
+
selectModalTitle,
|
|
15
|
+
selectModalTitleComponent,
|
|
16
|
+
searchBarPlaceholder,
|
|
17
|
+
hideSearchBar,
|
|
18
|
+
confirmButtonText,
|
|
19
|
+
rightComponent,
|
|
20
|
+
variant = "default",
|
|
21
|
+
hintComponent,
|
|
22
|
+
hint,
|
|
23
|
+
style,
|
|
24
|
+
controlComponent,
|
|
25
|
+
type,
|
|
26
|
+
numberOfLines,
|
|
27
|
+
closeOnPick = type === "single",
|
|
28
|
+
modal,
|
|
29
|
+
selectOptions,
|
|
30
|
+
keyExtractor,
|
|
31
|
+
labelExtractor,
|
|
32
|
+
value,
|
|
33
|
+
handleOnSearch,
|
|
34
|
+
loading,
|
|
35
|
+
options,
|
|
36
|
+
setSelectOptions,
|
|
37
|
+
handleBlur,
|
|
38
|
+
handlePressInput,
|
|
39
|
+
getDisplayValue,
|
|
40
|
+
focused,
|
|
41
|
+
disabled,
|
|
42
|
+
_label,
|
|
43
|
+
...rest
|
|
44
|
+
} = useSelect(props);
|
|
155
45
|
modal.sync(
|
|
156
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ React.createElement(
|
|
157
47
|
Modal.Modal,
|
|
158
48
|
{
|
|
159
49
|
options: selectOptions || [],
|
|
@@ -181,14 +71,10 @@ function Select({
|
|
|
181
71
|
}
|
|
182
72
|
)
|
|
183
73
|
);
|
|
184
|
-
|
|
185
|
-
modal.show();
|
|
186
|
-
handleFocus();
|
|
187
|
-
await handleLazyFocus();
|
|
188
|
-
};
|
|
189
|
-
return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, controlComponent ? controlComponent(handlePressInput, getDisplayValue() || "") : /* @__PURE__ */ React__namespace.createElement(
|
|
74
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, controlComponent ? controlComponent(handlePressInput, getDisplayValue() || "") : /* @__PURE__ */ React.createElement(
|
|
190
75
|
reactCore.HintInputContainer,
|
|
191
76
|
{
|
|
77
|
+
...rest,
|
|
192
78
|
viewStyle: style,
|
|
193
79
|
onPress: handlePressInput,
|
|
194
80
|
focused,
|
|
@@ -198,10 +84,9 @@ function Select({
|
|
|
198
84
|
hint,
|
|
199
85
|
hintComponent,
|
|
200
86
|
label: _label,
|
|
201
|
-
rightComponent: /* @__PURE__ */
|
|
202
|
-
...rest
|
|
87
|
+
rightComponent: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(styled.SelectIcon, { name: "chevron-down", type: "ionicon", size: "centi" }), rightComponent)
|
|
203
88
|
},
|
|
204
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ React.createElement(
|
|
205
90
|
styled.StyledSelectionText,
|
|
206
91
|
{
|
|
207
92
|
numberOfLines,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var styled = require('../styled.js');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
|
|
7
|
+
const Flat = ({ options, keyExtractor, renderItem, getData }) => {
|
|
8
|
+
const data = React.useMemo(
|
|
9
|
+
() => typeof options !== "function" ? getData(options) : [],
|
|
10
|
+
[options, getData]
|
|
11
|
+
);
|
|
12
|
+
return /* @__PURE__ */ React.createElement(
|
|
13
|
+
reactNative.FlatList,
|
|
14
|
+
{
|
|
15
|
+
data,
|
|
16
|
+
keyExtractor,
|
|
17
|
+
fadingEdgeLength: 200,
|
|
18
|
+
ItemSeparatorComponent: styled.Divider,
|
|
19
|
+
renderItem
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
module.exports = Flat;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var Button = require('../../../atoms/Button/Button.js');
|
|
5
|
+
var reactCore = require('@tecsinapse/react-core');
|
|
6
|
+
var Text = require('../../../atoms/Text/Text.js');
|
|
7
|
+
var Header = require('../../../atoms/Header/Header.js');
|
|
8
|
+
var Input = require('../../../atoms/Input/Input.js');
|
|
9
|
+
require('react-native');
|
|
10
|
+
var BaseModalView = require('../../../atoms/Modal/ui/BaseModalView.js');
|
|
11
|
+
var styled = require('../styled.js');
|
|
12
|
+
var Section = require('./Section.js');
|
|
13
|
+
var Flat = require('./Flat.js');
|
|
14
|
+
var useModal = require('../hooks/useModal.js');
|
|
15
|
+
|
|
16
|
+
const ModalTitle = ({ title }) => title ? /* @__PURE__ */ React.createElement(
|
|
17
|
+
styled.TextTitleModal,
|
|
18
|
+
{
|
|
19
|
+
typography: "h4",
|
|
20
|
+
fontWeight: "bold",
|
|
21
|
+
numberOfLines: 3,
|
|
22
|
+
style: { maxWidth: reactCore.RFValue(250) }
|
|
23
|
+
},
|
|
24
|
+
title
|
|
25
|
+
) : null;
|
|
26
|
+
const Component = (props) => {
|
|
27
|
+
const {
|
|
28
|
+
ModalComponent,
|
|
29
|
+
selectModalTitleComponent,
|
|
30
|
+
selectModalTitle,
|
|
31
|
+
hideSearchBar,
|
|
32
|
+
searchBarPlaceholder,
|
|
33
|
+
searchArg,
|
|
34
|
+
setSearchArg,
|
|
35
|
+
loading,
|
|
36
|
+
options,
|
|
37
|
+
getData,
|
|
38
|
+
renderItem,
|
|
39
|
+
keyExtractor,
|
|
40
|
+
closeOnPick,
|
|
41
|
+
confirmButtonText,
|
|
42
|
+
handleConfirm,
|
|
43
|
+
close,
|
|
44
|
+
...others
|
|
45
|
+
} = useModal(props);
|
|
46
|
+
return /* @__PURE__ */ React.createElement(BaseModalView.ModalView, { ...others, BoxComponent: ModalComponent, showCloseBar: false }, /* @__PURE__ */ React.createElement(
|
|
47
|
+
Header,
|
|
48
|
+
{
|
|
49
|
+
rightButton: {
|
|
50
|
+
onPress: close,
|
|
51
|
+
icon: {
|
|
52
|
+
name: "close",
|
|
53
|
+
type: "material-community",
|
|
54
|
+
fontColor: "light"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
selectModalTitleComponent ? selectModalTitleComponent : /* @__PURE__ */ React.createElement(ModalTitle, { title: selectModalTitle })
|
|
59
|
+
), !hideSearchBar ? /* @__PURE__ */ React.createElement(styled.SearchBarContainer, null, /* @__PURE__ */ React.createElement(
|
|
60
|
+
Input,
|
|
61
|
+
{
|
|
62
|
+
placeholder: searchBarPlaceholder,
|
|
63
|
+
value: searchArg,
|
|
64
|
+
onChange: setSearchArg,
|
|
65
|
+
leftComponent: /* @__PURE__ */ React.createElement(styled.SelectIcon, { name: "search", type: "ionicon", size: "centi" })
|
|
66
|
+
}
|
|
67
|
+
)) : null, loading ? /* @__PURE__ */ React.createElement(styled.FetchIndicator, { animating: true, color: "grey", size: "large" }) : null, options instanceof Map ? /* @__PURE__ */ React.createElement(
|
|
68
|
+
Section,
|
|
69
|
+
{
|
|
70
|
+
options,
|
|
71
|
+
getData,
|
|
72
|
+
renderItem,
|
|
73
|
+
keyExtractor
|
|
74
|
+
}
|
|
75
|
+
) : /* @__PURE__ */ React.createElement(
|
|
76
|
+
Flat,
|
|
77
|
+
{
|
|
78
|
+
renderItem,
|
|
79
|
+
getData,
|
|
80
|
+
options,
|
|
81
|
+
keyExtractor
|
|
82
|
+
}
|
|
83
|
+
), !closeOnPick ? /* @__PURE__ */ React.createElement(styled.ModalFooter, null, /* @__PURE__ */ React.createElement(
|
|
84
|
+
Button.Button,
|
|
85
|
+
{
|
|
86
|
+
variant: "filled",
|
|
87
|
+
color: "primary",
|
|
88
|
+
onPress: handleConfirm,
|
|
89
|
+
disabled: loading
|
|
90
|
+
},
|
|
91
|
+
/* @__PURE__ */ React.createElement(Text, { fontColor: "light", fontWeight: "bold" }, confirmButtonText)
|
|
92
|
+
)) : null);
|
|
93
|
+
};
|
|
94
|
+
const Modal = Component;
|
|
95
|
+
|
|
96
|
+
exports.Modal = Modal;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var styled = require('../styled.js');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
var reactCore = require('@tecsinapse/react-core');
|
|
7
|
+
|
|
8
|
+
const Component = ({
|
|
9
|
+
handlePressItem,
|
|
10
|
+
labelExtractor,
|
|
11
|
+
item,
|
|
12
|
+
type
|
|
13
|
+
}) => {
|
|
14
|
+
const label = labelExtractor(item);
|
|
15
|
+
return /* @__PURE__ */ React.createElement(styled.ListItem, { onPress: () => handlePressItem(item) }, /* @__PURE__ */ React.createElement(reactNative.View, { pointerEvents: "none" }, type === "multi" ? /* @__PURE__ */ React.createElement(
|
|
16
|
+
reactCore.Checkbox,
|
|
17
|
+
{
|
|
18
|
+
color: "primary",
|
|
19
|
+
labelPosition: "right",
|
|
20
|
+
checked: item._checked
|
|
21
|
+
},
|
|
22
|
+
/* @__PURE__ */ React.createElement(
|
|
23
|
+
styled.StyledTextItemSelect,
|
|
24
|
+
{
|
|
25
|
+
fontWeight: item._checked ? "bold" : "regular",
|
|
26
|
+
ellipsizeMode: "tail",
|
|
27
|
+
numberOfLines: 1
|
|
28
|
+
},
|
|
29
|
+
label
|
|
30
|
+
)
|
|
31
|
+
) : /* @__PURE__ */ React.createElement(
|
|
32
|
+
reactCore.RadioButton,
|
|
33
|
+
{
|
|
34
|
+
color: "primary",
|
|
35
|
+
labelPosition: "right",
|
|
36
|
+
checked: item._checked
|
|
37
|
+
},
|
|
38
|
+
/* @__PURE__ */ React.createElement(
|
|
39
|
+
styled.StyledTextItemSelect,
|
|
40
|
+
{
|
|
41
|
+
fontWeight: item._checked ? "bold" : "regular",
|
|
42
|
+
ellipsizeMode: "tail",
|
|
43
|
+
numberOfLines: 1
|
|
44
|
+
},
|
|
45
|
+
label
|
|
46
|
+
)
|
|
47
|
+
)));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
module.exports = Component;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var styled = require('../styled.js');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
var Text = require('../../../atoms/Text/Text.js');
|
|
7
|
+
|
|
8
|
+
const SectionHead = ({ section: { title } }) => /* @__PURE__ */ React.createElement(styled.SectionHeader, null, /* @__PURE__ */ React.createElement(Text, { fontWeight: "bold" }, title));
|
|
9
|
+
const Section = ({ options, renderItem, getData, keyExtractor }) => {
|
|
10
|
+
const sectionList = React.useMemo(
|
|
11
|
+
() => options instanceof Map ? [...options].map(([key, value]) => ({
|
|
12
|
+
title: key,
|
|
13
|
+
data: getData(value)
|
|
14
|
+
})) : [],
|
|
15
|
+
[options, getData]
|
|
16
|
+
);
|
|
17
|
+
return /* @__PURE__ */ React.createElement(
|
|
18
|
+
reactNative.SectionList,
|
|
19
|
+
{
|
|
20
|
+
sections: sectionList,
|
|
21
|
+
renderItem,
|
|
22
|
+
ItemSeparatorComponent: styled.Divider,
|
|
23
|
+
renderSectionHeader: SectionHead,
|
|
24
|
+
keyExtractor
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
module.exports = Section;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const findValue = (array, value, keyExtractor, idx) => array.find((it) => keyExtractor(value, idx) === keyExtractor(it, idx));
|
|
4
|
+
const isOptionChecked = (type, option, src, keyExtractor, idx) => type === "multi" ? !!findValue(src, option, keyExtractor, idx) : keyExtractor(src[0] ?? {}, idx) == keyExtractor(option, idx);
|
|
5
|
+
const multiBuilder = (option, src, keyExtractor) => {
|
|
6
|
+
const array = [];
|
|
7
|
+
let found = false;
|
|
8
|
+
for (const value of src) {
|
|
9
|
+
if (keyExtractor(value) != keyExtractor(option)) array.push(value);
|
|
10
|
+
else found = true;
|
|
11
|
+
}
|
|
12
|
+
if (!found) array.push(option);
|
|
13
|
+
return array;
|
|
14
|
+
};
|
|
15
|
+
const singleBuilder = (option, src, keyExtractor) => keyExtractor(src[0] ?? {}) === keyExtractor(option) ? [] : [option];
|
|
16
|
+
const mapToArray = (map) => [...map.values()].flatMap((v) => v);
|
|
17
|
+
const getMultiLabel = (value, placeholder, options, keyExtractor, labelExtractor) => {
|
|
18
|
+
if (value.length === 0) return placeholder;
|
|
19
|
+
else {
|
|
20
|
+
const optionsArray = options instanceof Map ? mapToArray(options) : options;
|
|
21
|
+
const available = optionsArray.length > 0 ? optionsArray : value;
|
|
22
|
+
return available?.reduce(
|
|
23
|
+
(acc, option, index) => findValue(value, option, keyExtractor, index) ? acc + labelExtractor(option) + ", " : acc,
|
|
24
|
+
""
|
|
25
|
+
).slice(0, -2);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const getSingleLabel = (value, placeholder, options, keyExtractor, labelExtractor) => {
|
|
29
|
+
if (!value) return placeholder;
|
|
30
|
+
const optionsArray = options instanceof Map ? mapToArray(options) : options;
|
|
31
|
+
const selectedOption = optionsArray?.find(
|
|
32
|
+
(option, index) => keyExtractor(option, index) == keyExtractor(value, index)
|
|
33
|
+
);
|
|
34
|
+
return labelExtractor(selectedOption ?? value);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.findValue = findValue;
|
|
38
|
+
exports.getMultiLabel = getMultiLabel;
|
|
39
|
+
exports.getSingleLabel = getSingleLabel;
|
|
40
|
+
exports.isOptionChecked = isOptionChecked;
|
|
41
|
+
exports.mapToArray = mapToArray;
|
|
42
|
+
exports.multiBuilder = multiBuilder;
|
|
43
|
+
exports.singleBuilder = singleBuilder;
|