@majoo-ui/react 2.0.0 → 2.1.0-rc.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/charts.esm.js +3 -1453
- package/colors/Colors.esm.js +93 -0
- package/components/accordion/Accordion.esm.js +109 -0
- package/components/alertDialog/AlertDialog.esm.js +440 -0
- package/components/avatar/Avatar.esm.js +83 -0
- package/components/badge/Badge.esm.js +255 -0
- package/components/banner/Banner.esm.js +341 -0
- package/components/barChart/BarChart.esm.js +212 -0
- package/components/breadcrumb/Breadcrumb.esm.js +65 -0
- package/components/breadcrumb/index.esm.js +19 -0
- package/components/button/Button.esm.js +331 -0
- package/components/buttonGroup/ButtonGroup.esm.js +350 -0
- package/components/card/Card.esm.js +236 -0
- package/components/chart/assets/data_kosong.png.esm.js +3 -0
- package/components/chart/lineChart/LineChart.esm.js +358 -0
- package/components/chart/lineChart/components/Comparator.esm.js +82 -0
- package/components/chart/lineChart/components/ComparatorController.esm.js +112 -0
- package/components/chart/lineChart/components/ComparatorItem.esm.js +104 -0
- package/components/chart/lineChart/components/ProductList.esm.js +78 -0
- package/components/chart/lineChart/components/TitleLegend.esm.js +107 -0
- package/components/chart/lineChart/components/Tooltip.esm.js +90 -0
- package/components/chart/utils/index.esm.js +109 -0
- package/components/checkboxTable/CheckboxTable.esm.js +287 -0
- package/components/colorPicker/ColorPicker.esm.js +342 -0
- package/components/colorPicker/InputColorPicker.esm.js +120 -0
- package/components/colorPicker/assets/img_colormap.gif.esm.js +3 -0
- package/components/colorPicker/components/ColorFields.esm.js +144 -0
- package/components/colorPicker/components/ColorMap.esm.js +1188 -0
- package/components/contentEditor/ContentEditor.esm.js +251 -0
- package/components/contentEditor/assets/Inline-code-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Link-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/List-bulleted-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/List-numbered-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Redo-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-bold-filled.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-clear-format-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-italic-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-strikethrough-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-underline-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Undo-outline.svg.esm.js +3 -0
- package/components/contextMenu/ContextMenu.esm.js +298 -0
- package/components/datePicker/AdvancedOption.esm.js +37 -0
- package/components/datePicker/CustomDatePicker.esm.js +121 -0
- package/components/datePicker/DatePicker.esm.js +244 -0
- package/components/datePicker/DatePickerMulti.esm.js +70 -0
- package/components/datePicker/InputDatePicker.esm.js +290 -0
- package/components/datePicker/InputDateRangePicker.esm.js +174 -0
- package/components/datePicker/components/Calendar.esm.js +654 -0
- package/components/datePicker/components/CalendarMulti.esm.js +407 -0
- package/components/datePicker/components/CalendarTimePicker.esm.js +104 -0
- package/components/datePicker/components/DateNumber.esm.js +89 -0
- package/components/datePicker/components/MobileCalendar.esm.js +522 -0
- package/components/datePicker/state/reducer.esm.js +286 -0
- package/components/datePicker/timePicker/InputTimePicker.esm.js +205 -0
- package/components/datePicker/timePicker/TimePicker.esm.js +481 -0
- package/components/devicePreview/DevicePreview.esm.js +631 -0
- package/components/devicePreview/deviceFrame/android-transparant.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/android-wide-transparant.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-email.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-notification.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-sms.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-whatsapp.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/desktop-transparant.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/ic-majoo-profpic.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/iphone-transparant.png.esm.js +3 -0
- package/components/dialog/Dialog.esm.js +106 -0
- package/components/drawer/Drawer.esm.js +294 -0
- package/components/dropdownMenu/DropdownMenu.esm.js +281 -0
- package/components/editableTable/EditableMobile.esm.js +361 -0
- package/components/editableTable/EditableTable.esm.js +618 -0
- package/components/editableTable/transition.esm.js +37 -0
- package/components/form/components/FormGroup/FormGroup.esm.js +142 -0
- package/components/form/components/FormHelper/Helper.esm.js +50 -0
- package/components/form/components/FormLabel/Label.esm.js +90 -0
- package/components/form/components/InputAddon/InputAddon.esm.js +105 -0
- package/components/form/components/InputCheckbox/CheckboxGroup.esm.js +60 -0
- package/components/form/components/InputCheckbox/InputCheckbox.esm.js +129 -0
- package/components/form/components/InputCheckbox/icon/CheckOutline.esm.js +33 -0
- package/components/form/components/InputCheckbox/icon/MinusOutline.esm.js +33 -0
- package/components/form/components/InputCombobox/InputCombobox.esm.js +169 -0
- package/components/form/components/InputCounter/InputCounter.esm.js +226 -0
- package/components/form/components/InputCreatable/InputCreatable.esm.js +229 -0
- package/components/form/components/InputDateRange/InputDateRange.esm.js +46 -0
- package/components/form/components/InputElement/InputElement.esm.js +35 -0
- package/components/form/components/InputGroup/InputGroup.esm.js +188 -0
- package/components/form/components/InputLetter/InputLetter.esm.js +68 -0
- package/components/form/components/InputNumber/InputNumber.esm.js +248 -0
- package/components/form/components/InputNumber/NumberFormat.esm.js +1263 -0
- package/components/form/components/InputOTP/InputOTP.esm.js +70 -0
- package/components/form/components/InputRadio/InputRadio.esm.js +273 -0
- package/components/form/components/InputRadio/InputRadioGroup.esm.js +35 -0
- package/components/form/components/InputRadio/context.esm.js +5 -0
- package/components/form/components/InputResourceList/InputResourceList.esm.js +429 -0
- package/components/form/components/InputSearchbox/CloseFilled.esm.js +34 -0
- package/components/form/components/InputSearchbox/InputSearchbox.esm.js +90 -0
- package/components/form/components/InputSearchbox/SearchOutline.esm.js +26 -0
- package/components/form/components/InputSelect/InputSelect.esm.js +964 -0
- package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +1388 -0
- package/components/form/components/InputSelectCheck/OptionGroupItem.esm.js +39 -0
- package/components/form/components/InputSelectCheck/icon/CheckOutline.esm.js +33 -0
- package/components/form/components/InputSelectTag/InputSelectTag.esm.js +62 -0
- package/components/form/components/InputSignature/InputSignature.esm.js +122 -0
- package/components/form/components/InputSignature/SignatureModal.esm.js +67 -0
- package/components/form/components/InputSwitch/InputSwitch.esm.js +96 -0
- package/components/form/components/InputSwitch/InputSwitchWithImage.esm.js +136 -0
- package/components/form/components/InputTags/InputTags.esm.js +268 -0
- package/components/form/components/InputText/InputText.esm.js +197 -0
- package/components/form/components/InputTextArea/InputTextArea.esm.js +77 -0
- package/components/heading/Heading.esm.js +64 -0
- package/components/iconButton/IconButton.esm.js +71 -0
- package/components/image/Image.esm.js +141 -0
- package/components/link/Link.esm.js +59 -0
- package/components/loadingBar/LoadingBar.esm.js +113 -0
- package/components/mapPicker/InputMapPicker.esm.js +160 -0
- package/components/mapPicker/MapPicker.esm.js +122 -0
- package/components/mapPicker/MapPicker.styles.esm.js +70 -0
- package/components/mapPicker/assets/images/Mapsicle.png.esm.js +3 -0
- package/components/mapPicker/components/AddressCard.esm.js +25 -0
- package/components/mapPicker/components/ButtonSelect.esm.js +46 -0
- package/components/mapPicker/components/ChangeView.esm.js +20 -0
- package/components/mapPicker/components/InputSearch.esm.js +74 -0
- package/components/mapPicker/components/MarkerIcon.esm.js +22 -0
- package/components/mapPicker/components/MarkerSvg.esm.js +62 -0
- package/components/mapPicker/components/ZoomControls.esm.js +36 -0
- package/components/mapPicker/hooks/useMapSearch.esm.js +161 -0
- package/components/modalDialog/ModalDialog.esm.js +247 -0
- package/components/notificationBadge/NotificationBadge.esm.js +149 -0
- package/components/pageDialog/PageDialog.esm.js +291 -0
- package/components/pageDialog/logo.svg.esm.js +3 -0
- package/components/pagination/Pagination.esm.js +94 -0
- package/components/pagination/PaginationButton.esm.js +346 -0
- package/components/pagination/PaginationInfo.esm.js +146 -0
- package/components/paper/Paper.esm.js +76 -0
- package/components/paragraph/Paragraph.esm.js +52 -0
- package/components/pieChart/PieChart.esm.js +287 -0
- package/components/popover/Popover.esm.js +142 -0
- package/components/progress/Progress.esm.js +170 -0
- package/components/progressIndicator/ProgressIndicator.esm.js +287 -0
- package/components/scrollSync/ScrollSync.esm.js +172 -0
- package/components/scrollSync/ScrollSyncNode.esm.js +87 -0
- package/components/scrollSync/utils.esm.js +9 -0
- package/components/separator/Separator.esm.js +43 -0
- package/components/skeleton/Skeleton.esm.js +131 -0
- package/components/slider/Slider.esm.js +345 -0
- package/components/stepWizard/StepWizard.esm.js +451 -0
- package/components/stepWizard/index.esm.js +14 -0
- package/components/table/MobileTable.esm.js +415 -0
- package/components/table/Table.esm.js +1472 -0
- package/components/table/components/columns/DateColumn.esm.js +26 -0
- package/components/table/components/columns/DecimalColumn.esm.js +36 -0
- package/components/table/components/columns/PriceColumn.esm.js +57 -0
- package/components/table/components/columns/RowDraggableColumn.esm.js +24 -0
- package/components/table/components/columns/RowExpanderColumn.esm.js +32 -0
- package/components/table/components/columns/RowExpanderMultipleColumn.esm.js +24 -0
- package/components/table/components/columns/RowMenuColumn.esm.js +101 -0
- package/components/table/components/columns/RowSelectionCallbackColumn.esm.js +38 -0
- package/components/table/components/columns/RowSelectionColumn.esm.js +34 -0
- package/components/table/images/img-emptydata.webp.esm.js +3 -0
- package/components/table/images/img-emptysearchdata.webp.esm.js +3 -0
- package/components/tableOfContent/TableOfContent.esm.js +267 -0
- package/components/tableOfContent/index.esm.js +18 -0
- package/components/tableOfContent/transition.esm.js +38 -0
- package/components/tabs/Tabs.esm.js +282 -0
- package/components/tag/Tag.esm.js +161 -0
- package/components/tagList/TagList.esm.js +90 -0
- package/components/tagStatus/TagStatus.esm.js +134 -0
- package/components/text/Text.esm.js +140 -0
- package/components/toast/Toast.esm.js +297 -0
- package/components/toast/ToastContainer.esm.js +73 -0
- package/components/toast/context/ToastContext.esm.js +5 -0
- package/components/toast/context/ToastProvider.esm.js +96 -0
- package/components/tooltip/Tooltip.esm.js +175 -0
- package/components/upload/Upload.esm.js +1103 -0
- package/components/upload/utils/canvasPreview.esm.js +39 -0
- package/components/upload/utils/imgPreview.esm.js +21 -0
- package/config/stitches.config.esm.js +216 -0
- package/editor.esm.js +1 -264
- package/hooks/useListOption/useListOption.esm.js +56 -0
- package/hooks/useToggle/useToggle.esm.js +8 -0
- package/index.esm.js +106 -42293
- package/layout/box/Box.esm.js +24 -0
- package/layout/flex/Flex.esm.js +135 -0
- package/layout/grid/Grid.esm.js +270 -0
- package/layout/pageContainer/PageContainer.esm.js +60 -0
- package/majoo-provider/MajooProvider.esm.js +42 -0
- package/majoo-provider/ThemeProvider.esm.js +41 -0
- package/majoo-provider/globalStyles.esm.js +242 -0
- package/majoo-provider/styles/modern-normalize.esm.js +95 -0
- package/map.esm.js +2 -734
- package/package.json +16 -5
- package/utils/calendar.esm.js +26 -0
- package/utils/element.esm.js +21 -0
- package/utils/object.esm.js +12 -0
- package/utils/request.esm.js +74 -0
- package/utils/strings.esm.js +6 -0
- package/{useMediaQuery.esm.js → utils/useMediaQuery.esm.js} +1 -1
- package/utils/useNavigatorOnline.esm.js +19 -0
- package/utils/variant.esm.js +12 -0
- package/wrapper/ConditionalWrapper.esm.js +9 -0
- package/ModalDialog.esm.js +0 -2669
- package/Separator.esm.js +0 -3002
- package/stitches.config.esm.js +0 -2284
- package/{index.esm.css → charts.esm.css} +4 -4
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import OTPInput, { ResendOTP as ResendOTP$1 } from 'otp-input-react';
|
|
3
|
+
import Paragraph from '../../../paragraph/Paragraph.esm.js';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { foundations } from '@majoo-ui/core';
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
colors
|
|
9
|
+
} = foundations;
|
|
10
|
+
function InputOTP(props) {
|
|
11
|
+
const {
|
|
12
|
+
isError
|
|
13
|
+
} = props;
|
|
14
|
+
const inputStyles = {
|
|
15
|
+
width: 48,
|
|
16
|
+
height: 48,
|
|
17
|
+
border: `1px solid ${isError ? colors.textRed : colors.gray300}`,
|
|
18
|
+
borderRadius: 4,
|
|
19
|
+
fontWeight: 600,
|
|
20
|
+
fontSize: 24,
|
|
21
|
+
textAlign: 'center',
|
|
22
|
+
color: colors.textPrimary
|
|
23
|
+
};
|
|
24
|
+
return jsx(OTPInput, Object.assign({
|
|
25
|
+
inputStyles: inputStyles
|
|
26
|
+
}, props));
|
|
27
|
+
}
|
|
28
|
+
InputOTP.defaultProps = {
|
|
29
|
+
OTPLength: 4,
|
|
30
|
+
value: '',
|
|
31
|
+
disabled: false,
|
|
32
|
+
autoFocus: false,
|
|
33
|
+
otpType: 'any',
|
|
34
|
+
secure: false
|
|
35
|
+
};
|
|
36
|
+
function ResendOTP(props) {
|
|
37
|
+
const {
|
|
38
|
+
t
|
|
39
|
+
} = useTranslation(['MajooUI/inputOtp', 'translation']);
|
|
40
|
+
function renderButton() {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
function renderTime(time) {
|
|
44
|
+
function handleClick() {
|
|
45
|
+
var _a;
|
|
46
|
+
if (time < 1) {
|
|
47
|
+
(_a = props === null || props === void 0 ? void 0 : props.onResendClick) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return jsx(Paragraph, {
|
|
51
|
+
color: "brand",
|
|
52
|
+
css: {
|
|
53
|
+
cursor: time > 0 ? 'not-allowed' : 'pointer',
|
|
54
|
+
userSelect: 'none'
|
|
55
|
+
},
|
|
56
|
+
onClick: handleClick,
|
|
57
|
+
children: `${t('resendingText', 'Kirim Ulang')} ${time > 0 ? `(${time}s)` : ''}`
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return jsx(ResendOTP$1, Object.assign({
|
|
61
|
+
renderButton: renderButton,
|
|
62
|
+
renderTime: renderTime
|
|
63
|
+
}, props));
|
|
64
|
+
}
|
|
65
|
+
ResendOTP.defaultProps = {
|
|
66
|
+
maxTime: 60,
|
|
67
|
+
timeInterval: 1000
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { ResendOTP, InputOTP as default };
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import 'react';
|
|
2
|
+
import { styled } from '../../../../config/stitches.config.esm.js';
|
|
3
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
4
|
+
import Flex from '../../../../layout/flex/Flex.esm.js';
|
|
5
|
+
import FormLabel from '../FormLabel/Label.esm.js';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { InputRadioContext } from './context.esm.js';
|
|
8
|
+
import { InputNumber } from '../InputNumber/InputNumber.esm.js';
|
|
9
|
+
import { InputText } from '../InputText/InputText.esm.js';
|
|
10
|
+
import Text from '../../../text/Text.esm.js';
|
|
11
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
12
|
+
|
|
13
|
+
const INDICATOR_BASE_STYLES = {
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
display: 'flex',
|
|
16
|
+
height: '100%',
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
width: '100%',
|
|
19
|
+
position: 'relative',
|
|
20
|
+
'&::after': {
|
|
21
|
+
content: '""',
|
|
22
|
+
display: 'block',
|
|
23
|
+
minWidth: '8px',
|
|
24
|
+
minHeight: '8px',
|
|
25
|
+
width: '8px',
|
|
26
|
+
height: '8px',
|
|
27
|
+
borderRadius: '$round',
|
|
28
|
+
backgroundColor: '$primary500'
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const StyledIndicator = styled(RadioGroupPrimitive.Indicator, INDICATOR_BASE_STYLES);
|
|
32
|
+
const RADIO_BASE_STYLES = {
|
|
33
|
+
all: 'unset',
|
|
34
|
+
userSelect: 'none',
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
appearance: 'none',
|
|
37
|
+
display: 'inline-flex',
|
|
38
|
+
justifyContent: 'center',
|
|
39
|
+
lineHeight: '1',
|
|
40
|
+
margin: '0',
|
|
41
|
+
outline: 'none',
|
|
42
|
+
padding: '0',
|
|
43
|
+
textDecoration: 'none',
|
|
44
|
+
WWebkitTapHighlightColor: 'rgba(0,0,0,0)',
|
|
45
|
+
borderRadius: '$round',
|
|
46
|
+
border: '2px solid $bgOutline',
|
|
47
|
+
overflow: 'hidden',
|
|
48
|
+
'&[data-state=checked]': {
|
|
49
|
+
border: '2px solid $primary500'
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const StyledRadio = styled(RadioGroupPrimitive.Item, RADIO_BASE_STYLES, {
|
|
53
|
+
minWidth: '12px',
|
|
54
|
+
minHeight: '12px',
|
|
55
|
+
width: '12px',
|
|
56
|
+
height: '12px',
|
|
57
|
+
'&:hover': {
|
|
58
|
+
cursor: 'pointer',
|
|
59
|
+
// boxShadow: 'inset 0 0 0 2px $colors$primary600',
|
|
60
|
+
border: '2px solid $primary600',
|
|
61
|
+
[`& ${StyledIndicator}`]: {
|
|
62
|
+
'&::after': {
|
|
63
|
+
backgroundColor: '$primary600'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
'&:focus': {
|
|
68
|
+
outline: '2px solid #82C4E0',
|
|
69
|
+
outlineOffset: '1px'
|
|
70
|
+
},
|
|
71
|
+
'&:disabled': {
|
|
72
|
+
pointerEvents: 'none',
|
|
73
|
+
border: '2px solid $gray200',
|
|
74
|
+
'&::placeholder': {
|
|
75
|
+
color: '$textDisable'
|
|
76
|
+
},
|
|
77
|
+
[`& ${StyledIndicator}`]: {
|
|
78
|
+
'&::after': {
|
|
79
|
+
backgroundColor: '$gray200'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
variants: {
|
|
84
|
+
readOnly: {
|
|
85
|
+
true: {
|
|
86
|
+
'&[data-state=checked]': {
|
|
87
|
+
border: '2px solid $primary500 !important'
|
|
88
|
+
},
|
|
89
|
+
[`& ${StyledIndicator}`]: {
|
|
90
|
+
'&::after': {
|
|
91
|
+
backgroundColor: '$primary500 !important'
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const Container = styled(Flex, {
|
|
99
|
+
variants: {
|
|
100
|
+
outlined: {
|
|
101
|
+
true: {
|
|
102
|
+
border: '1px solid $bgOutline',
|
|
103
|
+
borderRadius: '$lg',
|
|
104
|
+
padding: '$spacing-03',
|
|
105
|
+
'& > input': {
|
|
106
|
+
border: 'none !important',
|
|
107
|
+
padding: '0px !important',
|
|
108
|
+
height: '24px !important',
|
|
109
|
+
'&:disabled': {
|
|
110
|
+
backgroundColor: '$transparent !important'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
disabledOutlined: {
|
|
116
|
+
true: {
|
|
117
|
+
backgroundColor: '$gray150 !important'
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
active: {
|
|
121
|
+
true: {
|
|
122
|
+
border: '1px solid $primary400 !important'
|
|
123
|
+
},
|
|
124
|
+
false: {
|
|
125
|
+
'& > input': {
|
|
126
|
+
color: '$textPrimary !important'
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
disabled: {
|
|
131
|
+
true: {
|
|
132
|
+
'& > input': {
|
|
133
|
+
color: '$textSecondary !important'
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
withInputProps: {
|
|
138
|
+
true: {
|
|
139
|
+
padding: '0 $spacing-03'
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
block: {
|
|
143
|
+
true: {
|
|
144
|
+
flex: 1
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
compoundVariants: [{
|
|
149
|
+
outlined: true,
|
|
150
|
+
withInputProps: true,
|
|
151
|
+
css: {
|
|
152
|
+
padding: '0 $spacing-03'
|
|
153
|
+
}
|
|
154
|
+
}]
|
|
155
|
+
});
|
|
156
|
+
const ContainerLabel = styled('label', {
|
|
157
|
+
width: 'fit-content',
|
|
158
|
+
cursor: 'pointer',
|
|
159
|
+
variants: {
|
|
160
|
+
outlined: {
|
|
161
|
+
true: {
|
|
162
|
+
display: 'contents'
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
const InputRadio = ({
|
|
168
|
+
id,
|
|
169
|
+
disabled,
|
|
170
|
+
css,
|
|
171
|
+
inputType,
|
|
172
|
+
inputProps,
|
|
173
|
+
description,
|
|
174
|
+
readOnly,
|
|
175
|
+
...props
|
|
176
|
+
}) => {
|
|
177
|
+
function renderInputType(type, checkedValue, onValueChange) {
|
|
178
|
+
switch (type) {
|
|
179
|
+
case 'number':
|
|
180
|
+
return /*#__PURE__*/jsx(InputNumber, {
|
|
181
|
+
...inputProps,
|
|
182
|
+
readOnly: readOnly,
|
|
183
|
+
onFocus: () => {
|
|
184
|
+
onValueChange(props.value);
|
|
185
|
+
inputProps?.onFocus?.();
|
|
186
|
+
},
|
|
187
|
+
asChild: true
|
|
188
|
+
});
|
|
189
|
+
case 'text':
|
|
190
|
+
return /*#__PURE__*/jsx(InputText, {
|
|
191
|
+
...inputProps,
|
|
192
|
+
disabled: disabled,
|
|
193
|
+
readOnly: readOnly,
|
|
194
|
+
onFocus: () => {
|
|
195
|
+
onValueChange(props.value);
|
|
196
|
+
inputProps?.onFocus?.();
|
|
197
|
+
},
|
|
198
|
+
asChild: true
|
|
199
|
+
});
|
|
200
|
+
default:
|
|
201
|
+
return /*#__PURE__*/jsx(FormLabel, {
|
|
202
|
+
htmlFor: id,
|
|
203
|
+
mb: 0,
|
|
204
|
+
labelCss: {
|
|
205
|
+
fontSize: '$long-content-regular',
|
|
206
|
+
lineHeight: '$long-content-regular',
|
|
207
|
+
letterSpacing: '$long-content-regular',
|
|
208
|
+
fontWeight: '400',
|
|
209
|
+
cursor: 'pointer',
|
|
210
|
+
color: disabled || readOnly && checkedValue !== props.value ? '$textDisable' : '$textPrimary'
|
|
211
|
+
},
|
|
212
|
+
children: props.label
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return /*#__PURE__*/jsx(InputRadioContext.Consumer, {
|
|
217
|
+
children: ({
|
|
218
|
+
defaultValue,
|
|
219
|
+
value,
|
|
220
|
+
outlined,
|
|
221
|
+
onValueChange,
|
|
222
|
+
block
|
|
223
|
+
}) => {
|
|
224
|
+
const checkedValue = value ?? defaultValue;
|
|
225
|
+
return /*#__PURE__*/jsx(ContainerLabel, {
|
|
226
|
+
htmlFor: id,
|
|
227
|
+
outlined: outlined,
|
|
228
|
+
children: /*#__PURE__*/jsxs(Container, {
|
|
229
|
+
direction: "column",
|
|
230
|
+
outlined: outlined,
|
|
231
|
+
disabledOutlined: outlined && (readOnly || disabled),
|
|
232
|
+
disabled: disabled,
|
|
233
|
+
active: outlined && checkedValue === props.value && !disabled && !readOnly,
|
|
234
|
+
withInputProps: !!inputProps,
|
|
235
|
+
block: block,
|
|
236
|
+
css: css,
|
|
237
|
+
children: [/*#__PURE__*/jsxs(Flex, {
|
|
238
|
+
align: "center",
|
|
239
|
+
gap: 4,
|
|
240
|
+
children: [/*#__PURE__*/jsx(StyledRadio, {
|
|
241
|
+
id: id,
|
|
242
|
+
disabled: disabled || readOnly,
|
|
243
|
+
readOnly: readOnly,
|
|
244
|
+
...props,
|
|
245
|
+
children: /*#__PURE__*/jsx(StyledIndicator, {})
|
|
246
|
+
}), renderInputType(inputType, checkedValue, onValueChange)]
|
|
247
|
+
}), description && /*#__PURE__*/jsx(Text, {
|
|
248
|
+
variant: "caption",
|
|
249
|
+
color: "secondary",
|
|
250
|
+
css: {
|
|
251
|
+
marginLeft: '29px'
|
|
252
|
+
},
|
|
253
|
+
children: description
|
|
254
|
+
})]
|
|
255
|
+
})
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
InputRadio.propTypes = {
|
|
261
|
+
id: PropTypes.string,
|
|
262
|
+
disabled: PropTypes.bool,
|
|
263
|
+
value: PropTypes.string,
|
|
264
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
265
|
+
css: PropTypes.object,
|
|
266
|
+
inputType: PropTypes.oneOf(['number', 'text', 'default']),
|
|
267
|
+
onChange: PropTypes.func,
|
|
268
|
+
description: PropTypes.string,
|
|
269
|
+
readOnly: PropTypes.bool
|
|
270
|
+
};
|
|
271
|
+
InputRadio.displayName = 'InputRadio';
|
|
272
|
+
|
|
273
|
+
export { INDICATOR_BASE_STYLES, InputRadio, RADIO_BASE_STYLES, InputRadio as default };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import 'core-js/modules/es.iterator.constructor.js';
|
|
2
|
+
import 'core-js/modules/es.iterator.map.js';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
import { styled } from '../../../../config/stitches.config.esm.js';
|
|
5
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
6
|
+
import Flex from '../../../../layout/flex/Flex.esm.js';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { InputRadioContext } from './context.esm.js';
|
|
9
|
+
import { jsx } from 'react/jsx-runtime';
|
|
10
|
+
|
|
11
|
+
const RadioGroup = styled(RadioGroupPrimitive.Root, Flex);
|
|
12
|
+
function InputRadioGroup(props) {
|
|
13
|
+
return props?.children && /*#__PURE__*/jsx(InputRadioContext.Provider, {
|
|
14
|
+
value: props,
|
|
15
|
+
children: /*#__PURE__*/jsx(RadioGroup, {
|
|
16
|
+
...props,
|
|
17
|
+
children: React__default.Children.map(props?.children, child => /*#__PURE__*/React__default.cloneElement(child, {
|
|
18
|
+
style: {
|
|
19
|
+
...child.props.style,
|
|
20
|
+
opacity: 1
|
|
21
|
+
}
|
|
22
|
+
}))
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
InputRadioGroup.propTypes = {
|
|
27
|
+
defaultValue: PropTypes.string,
|
|
28
|
+
value: PropTypes.string,
|
|
29
|
+
onValueChange: PropTypes.func,
|
|
30
|
+
outlined: PropTypes.bool,
|
|
31
|
+
block: PropTypes.bool
|
|
32
|
+
};
|
|
33
|
+
InputRadioGroup.displayName = 'InputRadioGroup';
|
|
34
|
+
|
|
35
|
+
export { InputRadioGroup, InputRadioGroup as default };
|