@majoo-ui/react 2.0.1 → 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.
Files changed (203) hide show
  1. package/charts.esm.js +3 -1453
  2. package/colors/Colors.esm.js +93 -0
  3. package/components/accordion/Accordion.esm.js +109 -0
  4. package/components/alertDialog/AlertDialog.esm.js +440 -0
  5. package/components/avatar/Avatar.esm.js +83 -0
  6. package/components/badge/Badge.esm.js +255 -0
  7. package/components/banner/Banner.esm.js +341 -0
  8. package/components/barChart/BarChart.esm.js +212 -0
  9. package/components/breadcrumb/Breadcrumb.esm.js +65 -0
  10. package/components/breadcrumb/index.esm.js +19 -0
  11. package/components/button/Button.esm.js +331 -0
  12. package/components/buttonGroup/ButtonGroup.esm.js +350 -0
  13. package/components/card/Card.esm.js +236 -0
  14. package/components/chart/assets/data_kosong.png.esm.js +3 -0
  15. package/components/chart/lineChart/LineChart.esm.js +358 -0
  16. package/components/chart/lineChart/components/Comparator.esm.js +82 -0
  17. package/components/chart/lineChart/components/ComparatorController.esm.js +112 -0
  18. package/components/chart/lineChart/components/ComparatorItem.esm.js +104 -0
  19. package/components/chart/lineChart/components/ProductList.esm.js +78 -0
  20. package/components/chart/lineChart/components/TitleLegend.esm.js +107 -0
  21. package/components/chart/lineChart/components/Tooltip.esm.js +90 -0
  22. package/components/chart/utils/index.esm.js +109 -0
  23. package/components/checkboxTable/CheckboxTable.esm.js +287 -0
  24. package/components/colorPicker/ColorPicker.esm.js +342 -0
  25. package/components/colorPicker/InputColorPicker.esm.js +120 -0
  26. package/components/colorPicker/assets/img_colormap.gif.esm.js +3 -0
  27. package/components/colorPicker/components/ColorFields.esm.js +144 -0
  28. package/components/colorPicker/components/ColorMap.esm.js +1188 -0
  29. package/components/contentEditor/ContentEditor.esm.js +251 -0
  30. package/components/contentEditor/assets/Inline-code-outline.svg.esm.js +3 -0
  31. package/components/contentEditor/assets/Link-outline.svg.esm.js +3 -0
  32. package/components/contentEditor/assets/List-bulleted-outline.svg.esm.js +3 -0
  33. package/components/contentEditor/assets/List-numbered-outline.svg.esm.js +3 -0
  34. package/components/contentEditor/assets/Redo-outline.svg.esm.js +3 -0
  35. package/components/contentEditor/assets/Text-bold-filled.svg.esm.js +3 -0
  36. package/components/contentEditor/assets/Text-clear-format-outline.svg.esm.js +3 -0
  37. package/components/contentEditor/assets/Text-italic-outline.svg.esm.js +3 -0
  38. package/components/contentEditor/assets/Text-strikethrough-outline.svg.esm.js +3 -0
  39. package/components/contentEditor/assets/Text-underline-outline.svg.esm.js +3 -0
  40. package/components/contentEditor/assets/Undo-outline.svg.esm.js +3 -0
  41. package/components/contextMenu/ContextMenu.esm.js +298 -0
  42. package/components/datePicker/AdvancedOption.esm.js +37 -0
  43. package/components/datePicker/CustomDatePicker.esm.js +121 -0
  44. package/components/datePicker/DatePicker.esm.js +244 -0
  45. package/components/datePicker/DatePickerMulti.esm.js +70 -0
  46. package/components/datePicker/InputDatePicker.esm.js +290 -0
  47. package/components/datePicker/InputDateRangePicker.esm.js +174 -0
  48. package/components/datePicker/components/Calendar.esm.js +654 -0
  49. package/components/datePicker/components/CalendarMulti.esm.js +407 -0
  50. package/components/datePicker/components/CalendarTimePicker.esm.js +104 -0
  51. package/components/datePicker/components/DateNumber.esm.js +89 -0
  52. package/components/datePicker/components/MobileCalendar.esm.js +522 -0
  53. package/components/datePicker/state/reducer.esm.js +286 -0
  54. package/components/datePicker/timePicker/InputTimePicker.esm.js +205 -0
  55. package/components/datePicker/timePicker/TimePicker.esm.js +481 -0
  56. package/components/devicePreview/DevicePreview.esm.js +631 -0
  57. package/components/devicePreview/deviceFrame/android-transparant.png.esm.js +3 -0
  58. package/components/devicePreview/deviceFrame/android-wide-transparant.png.esm.js +3 -0
  59. package/components/devicePreview/deviceFrame/bg-email.png.esm.js +3 -0
  60. package/components/devicePreview/deviceFrame/bg-notification.png.esm.js +3 -0
  61. package/components/devicePreview/deviceFrame/bg-sms.png.esm.js +3 -0
  62. package/components/devicePreview/deviceFrame/bg-whatsapp.png.esm.js +3 -0
  63. package/components/devicePreview/deviceFrame/desktop-transparant.png.esm.js +3 -0
  64. package/components/devicePreview/deviceFrame/ic-majoo-profpic.png.esm.js +3 -0
  65. package/components/devicePreview/deviceFrame/iphone-transparant.png.esm.js +3 -0
  66. package/components/dialog/Dialog.esm.js +106 -0
  67. package/components/drawer/Drawer.esm.js +294 -0
  68. package/components/dropdownMenu/DropdownMenu.esm.js +281 -0
  69. package/components/editableTable/EditableMobile.esm.js +361 -0
  70. package/components/editableTable/EditableTable.esm.js +618 -0
  71. package/components/editableTable/transition.esm.js +37 -0
  72. package/components/form/components/FormGroup/FormGroup.esm.js +142 -0
  73. package/components/form/components/FormHelper/Helper.esm.js +50 -0
  74. package/components/form/components/FormLabel/Label.esm.js +90 -0
  75. package/components/form/components/InputAddon/InputAddon.esm.js +105 -0
  76. package/components/form/components/InputCheckbox/CheckboxGroup.esm.js +60 -0
  77. package/components/form/components/InputCheckbox/InputCheckbox.esm.js +129 -0
  78. package/components/form/components/InputCheckbox/icon/CheckOutline.esm.js +33 -0
  79. package/components/form/components/InputCheckbox/icon/MinusOutline.esm.js +33 -0
  80. package/components/form/components/InputCombobox/InputCombobox.esm.js +169 -0
  81. package/components/form/components/InputCounter/InputCounter.esm.js +226 -0
  82. package/components/form/components/InputCreatable/InputCreatable.esm.js +229 -0
  83. package/components/form/components/InputDateRange/InputDateRange.esm.js +46 -0
  84. package/components/form/components/InputElement/InputElement.esm.js +35 -0
  85. package/components/form/components/InputGroup/InputGroup.esm.js +188 -0
  86. package/components/form/components/InputLetter/InputLetter.esm.js +68 -0
  87. package/components/form/components/InputNumber/InputNumber.esm.js +248 -0
  88. package/components/form/components/InputNumber/NumberFormat.esm.js +1263 -0
  89. package/components/form/components/InputOTP/InputOTP.esm.js +70 -0
  90. package/components/form/components/InputRadio/InputRadio.esm.js +273 -0
  91. package/components/form/components/InputRadio/InputRadioGroup.esm.js +35 -0
  92. package/components/form/components/InputRadio/context.esm.js +5 -0
  93. package/components/form/components/InputResourceList/InputResourceList.esm.js +429 -0
  94. package/components/form/components/InputSearchbox/CloseFilled.esm.js +34 -0
  95. package/components/form/components/InputSearchbox/InputSearchbox.esm.js +90 -0
  96. package/components/form/components/InputSearchbox/SearchOutline.esm.js +26 -0
  97. package/components/form/components/InputSelect/InputSelect.esm.js +964 -0
  98. package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +1388 -0
  99. package/components/form/components/InputSelectCheck/OptionGroupItem.esm.js +39 -0
  100. package/components/form/components/InputSelectCheck/icon/CheckOutline.esm.js +33 -0
  101. package/components/form/components/InputSelectTag/InputSelectTag.esm.js +62 -0
  102. package/components/form/components/InputSignature/InputSignature.esm.js +122 -0
  103. package/components/form/components/InputSignature/SignatureModal.esm.js +67 -0
  104. package/components/form/components/InputSwitch/InputSwitch.esm.js +96 -0
  105. package/components/form/components/InputSwitch/InputSwitchWithImage.esm.js +136 -0
  106. package/components/form/components/InputTags/InputTags.esm.js +268 -0
  107. package/components/form/components/InputText/InputText.esm.js +197 -0
  108. package/components/form/components/InputTextArea/InputTextArea.esm.js +77 -0
  109. package/components/heading/Heading.esm.js +64 -0
  110. package/components/iconButton/IconButton.esm.js +71 -0
  111. package/components/image/Image.esm.js +141 -0
  112. package/components/link/Link.esm.js +59 -0
  113. package/components/loadingBar/LoadingBar.esm.js +113 -0
  114. package/components/mapPicker/InputMapPicker.esm.js +160 -0
  115. package/components/mapPicker/MapPicker.esm.js +122 -0
  116. package/components/mapPicker/MapPicker.styles.esm.js +70 -0
  117. package/components/mapPicker/assets/images/Mapsicle.png.esm.js +3 -0
  118. package/components/mapPicker/components/AddressCard.esm.js +25 -0
  119. package/components/mapPicker/components/ButtonSelect.esm.js +46 -0
  120. package/components/mapPicker/components/ChangeView.esm.js +20 -0
  121. package/components/mapPicker/components/InputSearch.esm.js +74 -0
  122. package/components/mapPicker/components/MarkerIcon.esm.js +22 -0
  123. package/components/mapPicker/components/MarkerSvg.esm.js +62 -0
  124. package/components/mapPicker/components/ZoomControls.esm.js +36 -0
  125. package/components/mapPicker/hooks/useMapSearch.esm.js +161 -0
  126. package/components/modalDialog/ModalDialog.esm.js +247 -0
  127. package/components/notificationBadge/NotificationBadge.esm.js +149 -0
  128. package/components/pageDialog/PageDialog.esm.js +291 -0
  129. package/components/pageDialog/logo.svg.esm.js +3 -0
  130. package/components/pagination/Pagination.esm.js +94 -0
  131. package/components/pagination/PaginationButton.esm.js +346 -0
  132. package/components/pagination/PaginationInfo.esm.js +146 -0
  133. package/components/paper/Paper.esm.js +76 -0
  134. package/components/paragraph/Paragraph.esm.js +52 -0
  135. package/components/pieChart/PieChart.esm.js +287 -0
  136. package/components/popover/Popover.esm.js +142 -0
  137. package/components/progress/Progress.esm.js +170 -0
  138. package/components/progressIndicator/ProgressIndicator.esm.js +287 -0
  139. package/components/scrollSync/ScrollSync.esm.js +172 -0
  140. package/components/scrollSync/ScrollSyncNode.esm.js +87 -0
  141. package/components/scrollSync/utils.esm.js +9 -0
  142. package/components/separator/Separator.esm.js +43 -0
  143. package/components/skeleton/Skeleton.esm.js +131 -0
  144. package/components/slider/Slider.esm.js +345 -0
  145. package/components/stepWizard/StepWizard.esm.js +451 -0
  146. package/components/stepWizard/index.esm.js +14 -0
  147. package/components/table/MobileTable.esm.js +415 -0
  148. package/components/table/Table.esm.js +1472 -0
  149. package/components/table/components/columns/DateColumn.esm.js +26 -0
  150. package/components/table/components/columns/DecimalColumn.esm.js +36 -0
  151. package/components/table/components/columns/PriceColumn.esm.js +57 -0
  152. package/components/table/components/columns/RowDraggableColumn.esm.js +24 -0
  153. package/components/table/components/columns/RowExpanderColumn.esm.js +32 -0
  154. package/components/table/components/columns/RowExpanderMultipleColumn.esm.js +24 -0
  155. package/components/table/components/columns/RowMenuColumn.esm.js +101 -0
  156. package/components/table/components/columns/RowSelectionCallbackColumn.esm.js +38 -0
  157. package/components/table/components/columns/RowSelectionColumn.esm.js +34 -0
  158. package/components/table/images/img-emptydata.webp.esm.js +3 -0
  159. package/components/table/images/img-emptysearchdata.webp.esm.js +3 -0
  160. package/components/tableOfContent/TableOfContent.esm.js +267 -0
  161. package/components/tableOfContent/index.esm.js +18 -0
  162. package/components/tableOfContent/transition.esm.js +38 -0
  163. package/components/tabs/Tabs.esm.js +282 -0
  164. package/components/tag/Tag.esm.js +161 -0
  165. package/components/tagList/TagList.esm.js +90 -0
  166. package/components/tagStatus/TagStatus.esm.js +134 -0
  167. package/components/text/Text.esm.js +140 -0
  168. package/components/toast/Toast.esm.js +297 -0
  169. package/components/toast/ToastContainer.esm.js +73 -0
  170. package/components/toast/context/ToastContext.esm.js +5 -0
  171. package/components/toast/context/ToastProvider.esm.js +96 -0
  172. package/components/tooltip/Tooltip.esm.js +175 -0
  173. package/components/upload/Upload.esm.js +1103 -0
  174. package/components/upload/utils/canvasPreview.esm.js +39 -0
  175. package/components/upload/utils/imgPreview.esm.js +21 -0
  176. package/config/stitches.config.esm.js +216 -0
  177. package/editor.esm.js +1 -264
  178. package/hooks/useListOption/useListOption.esm.js +56 -0
  179. package/hooks/useToggle/useToggle.esm.js +8 -0
  180. package/index.esm.js +106 -42293
  181. package/layout/box/Box.esm.js +24 -0
  182. package/layout/flex/Flex.esm.js +135 -0
  183. package/layout/grid/Grid.esm.js +270 -0
  184. package/layout/pageContainer/PageContainer.esm.js +60 -0
  185. package/majoo-provider/MajooProvider.esm.js +42 -0
  186. package/majoo-provider/ThemeProvider.esm.js +41 -0
  187. package/majoo-provider/globalStyles.esm.js +242 -0
  188. package/majoo-provider/styles/modern-normalize.esm.js +95 -0
  189. package/map.esm.js +2 -734
  190. package/package.json +8 -4
  191. package/utils/calendar.esm.js +26 -0
  192. package/utils/element.esm.js +21 -0
  193. package/utils/object.esm.js +12 -0
  194. package/utils/request.esm.js +74 -0
  195. package/utils/strings.esm.js +6 -0
  196. package/{useMediaQuery.esm.js → utils/useMediaQuery.esm.js} +1 -1
  197. package/utils/useNavigatorOnline.esm.js +19 -0
  198. package/utils/variant.esm.js +12 -0
  199. package/wrapper/ConditionalWrapper.esm.js +9 -0
  200. package/ModalDialog.esm.js +0 -2669
  201. package/Separator.esm.js +0 -3002
  202. package/stitches.config.esm.js +0 -2284
  203. package/{index.esm.css → charts.esm.css} +4 -4
@@ -0,0 +1,267 @@
1
+ import 'core-js/modules/es.array.push.js';
2
+ import 'core-js/modules/es.iterator.constructor.js';
3
+ import 'core-js/modules/es.iterator.map.js';
4
+ import { ChevronUpOutline, ChevronDownOutline } from '@majoo-ui/icons';
5
+ import { useState, forwardRef } from 'react';
6
+ import { styled, colors } from '../../config/stitches.config.esm.js';
7
+ import Box from '../../layout/box/Box.esm.js';
8
+ import Flex from '../../layout/flex/Flex.esm.js';
9
+ import { Card } from '../card/Card.esm.js';
10
+ import Collapse from './transition.esm.js';
11
+ import PropTypes from 'prop-types';
12
+ import ScrollSpy from 'react-ui-scrollspy';
13
+ import { jsx, jsxs } from 'react/jsx-runtime';
14
+
15
+ const DesktopContainer = styled(Flex, {
16
+ display: 'none',
17
+ '& .active-scroll-spy': {
18
+ borderLeft: `4px solid ${colors.primary500} !important`
19
+ },
20
+ '& .active-scroll-spy .link-title': {
21
+ color: `${colors.primary500} !important`
22
+ },
23
+ '@md': {
24
+ display: 'unset'
25
+ }
26
+ });
27
+ const MobileContainer = styled(Flex, {
28
+ backgroundColor: '$white',
29
+ border: `1px solid ${colors.gray150}`,
30
+ borderRadius: 8,
31
+ padding: '8px 8px',
32
+ width: '100%',
33
+ transition: '0.4s max-height',
34
+ position: 'relative',
35
+ '@md': {
36
+ display: 'none'
37
+ }
38
+ });
39
+ const ListWrap = styled('ul', {
40
+ listStyleType: 'none',
41
+ margin: 0,
42
+ padding: 0,
43
+ transitionDuration: '0.4s'
44
+ });
45
+ const List = styled('li', {
46
+ '&:not(:last-child)': {
47
+ marginBottom: 20
48
+ }
49
+ });
50
+ const Title = styled('a', {
51
+ fontWeight: '600',
52
+ fontSize: '$short-content-bold',
53
+ color: '$textSecondary !important',
54
+ paddingRight: 2,
55
+ transitionDuration: '0.1s',
56
+ userSelect: 'none',
57
+ textDecoration: 'none !important',
58
+ '&:hover': {
59
+ color: '$gray300 !important'
60
+ },
61
+ variants: {
62
+ active: {
63
+ true: {
64
+ color: '$textBrand !important'
65
+ }
66
+ }
67
+ }
68
+ });
69
+ const Separator = styled('div', {
70
+ width: 4,
71
+ borderRadius: 2,
72
+ backgroundColor: '$gray150 !important',
73
+ transitionDuration: '0.2s',
74
+ padding: '4px 0px',
75
+ variants: {
76
+ isCollapse: {
77
+ false: {
78
+ backgroundColor: '$primary500 !important'
79
+ }
80
+ }
81
+ }
82
+ });
83
+ const StyledCard = styled(Card, {
84
+ height: 'fit-content',
85
+ maxWidth: 311,
86
+ padding: '24px !important',
87
+ boxShadow: '0px 1px 4px rgba(0, 0, 0, 0.04)'
88
+ });
89
+ function Content({
90
+ content,
91
+ activeId,
92
+ isCollapse,
93
+ isDialog,
94
+ onNavClick
95
+ }) {
96
+ function getDatasets(content, activeId, isCollapse) {
97
+ const datasets = [];
98
+ for (let i = 0; i < content?.length; i++) {
99
+ if (content[i]?.id === activeId) {
100
+ datasets.unshift(content[i]);
101
+ } else {
102
+ datasets.push(content[i]);
103
+ }
104
+ }
105
+ if (isCollapse) {
106
+ return content;
107
+ } else {
108
+ return datasets;
109
+ }
110
+ }
111
+ return /*#__PURE__*/jsxs(Collapse, {
112
+ isOpen: isCollapse,
113
+ children: [/*#__PURE__*/jsx(Separator, {
114
+ isCollapse: isCollapse
115
+ }), /*#__PURE__*/jsx(ListWrap, {
116
+ css: {
117
+ position: 'relative'
118
+ },
119
+ children: getDatasets(content, activeId, isCollapse)?.map((item, index) => {
120
+ return /*#__PURE__*/jsx(List, {
121
+ children: /*#__PURE__*/jsxs(Flex, {
122
+ direction: "row",
123
+ gap: 5,
124
+ align: "center",
125
+ css: {
126
+ marginLeft: '-4px !important',
127
+ borderLeftWidth: '4px !important',
128
+ borderLeftStyle: 'solid !important',
129
+ borderLeftColor: `${item?.id === activeId ? colors.primary500 : 'transparent'} !important`,
130
+ paddingLeft: '16px !important',
131
+ minHeight: 25
132
+ },
133
+ "data-to-scrollspy-id": item?.id,
134
+ children: [/*#__PURE__*/jsx(Title, {
135
+ className: "link-title",
136
+ active: item?.id === activeId,
137
+ href: `#${item?.id}`,
138
+ onClick: e => {
139
+ e.preventDefault();
140
+ onNavClick?.(e?.currentTarget?.href?.split('#')?.[1]);
141
+ const target = window.document.getElementById(e?.currentTarget?.href?.split('#')?.[1]);
142
+ if (target) {
143
+ var headerOffset = 20;
144
+ var elementPosition = target.getBoundingClientRect().top;
145
+ var offsetPosition = elementPosition - headerOffset;
146
+ if (!isDialog) {
147
+ window.scrollBy({
148
+ top: offsetPosition,
149
+ behavior: 'smooth'
150
+ });
151
+ } else {
152
+ target.scrollIntoView({
153
+ behavior: 'smooth',
154
+ block: 'start'
155
+ });
156
+ }
157
+ }
158
+ },
159
+ children: item?.title
160
+ }), item?.icon]
161
+ })
162
+ }, index);
163
+ })
164
+ })]
165
+ });
166
+ }
167
+ function TableOfContent({
168
+ content,
169
+ css,
170
+ isMobile,
171
+ isDialog,
172
+ activeId,
173
+ onNavClick
174
+ }) {
175
+ const [mobileCollapse, setMobileCollapse] = useState(false);
176
+ function toggleCollapse() {
177
+ setMobileCollapse(!mobileCollapse);
178
+ }
179
+ return isMobile ? /*#__PURE__*/jsx(Box, {
180
+ css: {
181
+ background: '$white',
182
+ padding: '$spacing-05',
183
+ position: 'sticky',
184
+ top: 0
185
+ },
186
+ children: /*#__PURE__*/jsxs(MobileContainer, {
187
+ direction: "row",
188
+ justify: "between",
189
+ align: "center",
190
+ css: css,
191
+ onClick: toggleCollapse,
192
+ children: [/*#__PURE__*/jsx(Content, {
193
+ activeId: activeId,
194
+ isCollapse: mobileCollapse,
195
+ isDialog: isDialog,
196
+ content: content,
197
+ onNavClick: onNavClick
198
+ }), /*#__PURE__*/jsx(Box, {
199
+ css: {
200
+ position: 'absolute',
201
+ top: 8,
202
+ right: 8
203
+ },
204
+ children: mobileCollapse ? /*#__PURE__*/jsx(ChevronUpOutline, {
205
+ style: {
206
+ cursor: 'pointer'
207
+ }
208
+ }) : /*#__PURE__*/jsx(ChevronDownOutline, {
209
+ style: {
210
+ cursor: 'pointer'
211
+ }
212
+ })
213
+ })]
214
+ })
215
+ }) : /*#__PURE__*/jsx(DesktopContainer, {
216
+ direction: "row",
217
+ css: css,
218
+ children: /*#__PURE__*/jsx(StyledCard, {
219
+ showBottomLine: false,
220
+ children: /*#__PURE__*/jsx(Content, {
221
+ isCollapse: true,
222
+ isDialog: isDialog,
223
+ content: content,
224
+ onNavClick: onNavClick
225
+ })
226
+ })
227
+ });
228
+ }
229
+ const StyledPage = styled(Box, {
230
+ maxWidth: 982
231
+ });
232
+ const Page = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/jsx(StyledPage, {
233
+ ref: ref,
234
+ children: /*#__PURE__*/jsx(ScrollSpy, {
235
+ ...props
236
+ })
237
+ }));
238
+ Page.displayName = 'TableOfContent.Page';
239
+ TableOfContent.Page = Page;
240
+ TableOfContent.defaultProps = {
241
+ isMobile: false,
242
+ isDialog: false
243
+ };
244
+ TableOfContent.propTypes = {
245
+ /**
246
+ List of contents containing the title and id of a content.
247
+ */
248
+ content: PropTypes.array,
249
+ /**
250
+ Components devoted to mobile viewing only.
251
+ */
252
+ isMobile: PropTypes.bool,
253
+ /**
254
+ Condition when table of content is inside a component dialog.
255
+ */
256
+ isDialog: PropTypes.bool,
257
+ /**
258
+ The active ID to reference the active content on the mobile view obtained from onUpdateCallback.
259
+ */
260
+ activeId: PropTypes.string,
261
+ /**
262
+ Event Callback on navigation click.
263
+ */
264
+ onNavClick: PropTypes.func
265
+ };
266
+
267
+ export { TableOfContent as default };
@@ -0,0 +1,18 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import TableOfContent from './TableOfContent.esm.js';
3
+
4
+ const TableOfContentPage = props => {
5
+ return jsx(TableOfContent.Page, Object.assign({}, props, {
6
+ children: props.children
7
+ }));
8
+ };
9
+ TableOfContentPage.defaultProps = {
10
+ scrollThrottle: 300,
11
+ offsetTop: 0,
12
+ offsetBottom: 0,
13
+ useDataAttribute: 'to-scrollspy-id',
14
+ activeClass: 'active-scroll-spy',
15
+ useBoxMethod: true
16
+ };
17
+
18
+ export { TableOfContent, TableOfContentPage };
@@ -0,0 +1,38 @@
1
+ import { useState, useRef, useEffect } from 'react';
2
+ import Box from '../../layout/box/Box.esm.js';
3
+ import Flex from '../../layout/flex/Flex.esm.js';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ function Collapse({
7
+ children,
8
+ isOpen
9
+ }) {
10
+ const [height, setHeight] = useState(0);
11
+ const contentRef = useRef(null);
12
+ useEffect(() => {
13
+ const resizeObserver = new ResizeObserver(el => {
14
+ setHeight(el[0].contentRect.height);
15
+ });
16
+ resizeObserver.observe(contentRef.current);
17
+ return () => {
18
+ resizeObserver.disconnect();
19
+ };
20
+ }, []);
21
+ return /*#__PURE__*/jsx(Box, {
22
+ css: {
23
+ maxHeight: isOpen ? height : 25,
24
+ overflow: 'hidden',
25
+ transition: '0.4s max-height'
26
+ },
27
+ children: /*#__PURE__*/jsx(Flex, {
28
+ direction: "row",
29
+ ref: contentRef,
30
+ children: children
31
+ })
32
+ });
33
+ }
34
+ Collapse.defaultProps = {
35
+ isOpen: false
36
+ };
37
+
38
+ export { Collapse as default };
@@ -0,0 +1,282 @@
1
+ import React__default, { useState, useRef, useLayoutEffect } from 'react';
2
+ import * as TabsPrimitive from '@radix-ui/react-tabs';
3
+ import { colors, styled } from '../../config/stitches.config.esm.js';
4
+ import { addPropsToChildren } from '../../utils/element.esm.js';
5
+ import Box from '../../layout/box/Box.esm.js';
6
+ import Flex from '../../layout/flex/Flex.esm.js';
7
+ import { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
8
+ import { ChevronLgLeftOutline, ChevronLgRightOutline } from '@majoo-ui/icons';
9
+ import { Button } from '../button/Button.esm.js';
10
+ import PropTypes from 'prop-types';
11
+ import { jsx, jsxs } from 'react/jsx-runtime';
12
+ import Tooltip from '../tooltip/Tooltip.esm.js';
13
+
14
+ const StyledTabs = styled(TabsPrimitive.Root, {
15
+ display: 'flex',
16
+ flexDirection: 'column',
17
+ variants: {
18
+ gapped: {
19
+ true: {
20
+ gap: '$spacing-03',
21
+ boxShadow: 'none'
22
+ },
23
+ false: {
24
+ gap: 0,
25
+ boxShadow: '$medium'
26
+ }
27
+ }
28
+ },
29
+ defaultVariants: {
30
+ gapped: 'false'
31
+ }
32
+ });
33
+ const StyledList = styled(TabsPrimitive.List, {
34
+ flexShrink: 0,
35
+ display: 'flex',
36
+ borderBottom: '$medium',
37
+ boxShadow: '$medium',
38
+ overflowX: 'auto',
39
+ overflowY: 'hidden',
40
+ scrollBehavior: 'smooth',
41
+ '-ms-overflow-style': 'none',
42
+ scrollbarWidth: 'none',
43
+ '&::-webkit-scrollbar': {
44
+ display: 'none'
45
+ }
46
+ });
47
+ const StyledTrigger = styled(TabsPrimitive.Trigger, {
48
+ all: 'unset',
49
+ fontFamily: 'inherit',
50
+ backgroundColor: '$bgWhite ',
51
+ padding: '0 20px',
52
+ height: 60,
53
+ flex: 1,
54
+ display: 'flex',
55
+ alignItems: 'center',
56
+ justifyContent: 'center',
57
+ fontSize: '$header-tabs',
58
+ lineHeight: '$short-content-bold',
59
+ letterSpacing: '$header-tabs',
60
+ fontWeight: 500,
61
+ color: '$textSecondary',
62
+ userSelect: 'none',
63
+ cursor: 'pointer',
64
+ position: 'relative',
65
+ '&:hover': {
66
+ backgroundColor: '$btnHoverSecondary'
67
+ },
68
+ '&[data-state="active"]': {
69
+ color: '$textBrand',
70
+ '&::after': {
71
+ content: '',
72
+ position: 'absolute',
73
+ bottom: 0,
74
+ left: 0,
75
+ right: 0,
76
+ background: '$bgBrand',
77
+ height: '4px',
78
+ borderRadius: '1px'
79
+ }
80
+ },
81
+ '&:first-child': {
82
+ borderTopLeftRadius: '$lg',
83
+ borderBottomLeftRadius: '$lg',
84
+ '&::after': {
85
+ borderRadius: '1px 1px 1px 8px'
86
+ }
87
+ },
88
+ '&:last-child': {
89
+ borderTopRightRadius: '$lg',
90
+ borderBottomRightRadius: '$lg',
91
+ '&::after': {
92
+ borderRadius: '1px 1px 8px 1px'
93
+ }
94
+ },
95
+ variants: {
96
+ size: {
97
+ sm: {
98
+ height: '44px'
99
+ },
100
+ lg: {
101
+ height: '60px'
102
+ }
103
+ }
104
+ },
105
+ defaultVariants: {
106
+ size: 'lg'
107
+ }
108
+ });
109
+ const StyledContent = styled(TabsPrimitive.Content, {
110
+ flexGrow: 1,
111
+ borderRadius: '$lg',
112
+ backgroundColor: '$bgWhite ',
113
+ outline: 'none',
114
+ boxShadow: '$medium'
115
+ });
116
+ const ScrollButton = styled(Button, {
117
+ width: '28px',
118
+ '&:hover': {
119
+ boxShadow: '0px 1px 1px rgba(0, 0, 0, 0.07), 0px 2px 4px rgba(0, 0, 0, 0.05), 0px 4px 10px rgba(0, 0, 0, 0.05)'
120
+ },
121
+ variants: {
122
+ position: {
123
+ left: {
124
+ '& svg': {
125
+ marginTop: '-1px',
126
+ marginLeft: '-2px'
127
+ }
128
+ },
129
+ right: {
130
+ '& svg': {
131
+ marginTop: 0,
132
+ marginLeft: 0
133
+ }
134
+ }
135
+ }
136
+ }
137
+ });
138
+ const ScrollButtonContainer = styled(Box, {
139
+ size: '28px',
140
+ position: 'absolute',
141
+ zIndex: '$sticky',
142
+ borderRadius: '$md',
143
+ top: '8px',
144
+ variants: {
145
+ position: {
146
+ left: {
147
+ left: '8px',
148
+ boxShadow: '10px 0 8px 2px rgba(255,255,255,1), -6px 0 8px 2px rgba(255,255,255,1)'
149
+ },
150
+ right: {
151
+ right: '8px',
152
+ boxShadow: '6px 0 8px 2px rgba(255,255,255,1), -10px 0 8px 2px rgba(255,255,255,1)'
153
+ }
154
+ }
155
+ }
156
+ });
157
+ const Tabs = ({
158
+ children,
159
+ ...props
160
+ }) => {
161
+ const [activeTabs, setActiveTabs] = useState(props.defaultValue || '');
162
+ return /*#__PURE__*/jsx(StyledTabs, {
163
+ ...props,
164
+ onValueChange: value => {
165
+ setActiveTabs(value);
166
+ if (props.onValueChange) props.onValueChange(value);
167
+ },
168
+ children: addPropsToChildren(children, {
169
+ activeTabs
170
+ })
171
+ });
172
+ };
173
+ Tabs.propTypes = {
174
+ asChild: PropTypes.bool,
175
+ defaultValue: PropTypes.string,
176
+ value: PropTypes.string,
177
+ orientation: PropTypes.oneOf(['horizontal', 'vertical']),
178
+ dir: PropTypes.oneOf(['ltr', 'rtl']),
179
+ activationMode: PropTypes.oneOf(['automatic', 'manual'])
180
+ };
181
+ const TabsList = ({
182
+ children,
183
+ activeTabs,
184
+ ...props
185
+ }) => {
186
+ const [listContainerScrollPosition, setlistContainerScrollPosition] = useState(0);
187
+ const [scrollAreaWidth, setScrollAreaWidth] = useState(0);
188
+ const listContainerRef = useRef();
189
+ useLayoutEffect(() => {
190
+ if (listContainerRef && listContainerRef.current) {
191
+ setScrollAreaWidth(listContainerRef.current.scrollWidth - listContainerRef.current.clientWidth);
192
+ }
193
+ }, [listContainerRef, activeTabs]);
194
+ return /*#__PURE__*/jsxs(Box, {
195
+ css: {
196
+ position: 'relative'
197
+ },
198
+ children: [/*#__PURE__*/jsx(StyledList, {
199
+ ...props,
200
+ ref: listContainerRef,
201
+ onScroll: e => setlistContainerScrollPosition(e.target.scrollLeft),
202
+ children: addPropsToChildren(children, {
203
+ activeTabs
204
+ })
205
+ }), listContainerScrollPosition > 10 && /*#__PURE__*/jsx(ScrollButtonContainer, {
206
+ position: "left",
207
+ children: /*#__PURE__*/jsx(ScrollButton, {
208
+ position: "left",
209
+ type: "button",
210
+ buttonType: "ghost",
211
+ size: "xs",
212
+ icon: true,
213
+ onClick: () => listContainerRef.current.scrollLeft -= scrollAreaWidth / 2,
214
+ children: /*#__PURE__*/jsx(ChevronLgLeftOutline, {
215
+ color: colors.iconBrand
216
+ })
217
+ })
218
+ }), listContainerScrollPosition < scrollAreaWidth - 10 && /*#__PURE__*/jsx(ScrollButtonContainer, {
219
+ position: "right",
220
+ children: /*#__PURE__*/jsx(ScrollButton, {
221
+ position: "right",
222
+ type: "button",
223
+ buttonType: "ghost",
224
+ size: "xs",
225
+ icon: true,
226
+ onClick: () => listContainerRef.current.scrollLeft += scrollAreaWidth / 2,
227
+ children: /*#__PURE__*/jsx(ChevronLgRightOutline, {
228
+ color: colors.iconBrand
229
+ })
230
+ })
231
+ })]
232
+ });
233
+ };
234
+ const TabsTrigger = ({
235
+ children,
236
+ icon,
237
+ activeTabs,
238
+ value,
239
+ ...props
240
+ }) => {
241
+ const [isIconHovered, setIsIconHovered] = useState(false);
242
+ return /*#__PURE__*/jsx(StyledTrigger, {
243
+ value: value,
244
+ ...props,
245
+ children: /*#__PURE__*/jsx(ConditionalWrapper, {
246
+ condition: icon && activeTabs !== value,
247
+ wrapper: wrappedChildren => /*#__PURE__*/jsx(Tooltip, {
248
+ color: 'dark',
249
+ label: children,
250
+ side: "top",
251
+ onOpenChange: setIsIconHovered,
252
+ children: wrappedChildren
253
+ }),
254
+ children: /*#__PURE__*/jsxs(Flex, {
255
+ align: "center",
256
+ gap: 3,
257
+ css: {
258
+ whiteSpace: 'nowrap'
259
+ },
260
+ children: [icon && /*#__PURE__*/React__default.cloneElement(icon, {
261
+ color: activeTabs === value || isIconHovered ? colors.iconBrand : colors.iconDisable
262
+ }), (!icon || activeTabs === value) && children]
263
+ })
264
+ })
265
+ });
266
+ };
267
+ TabsTrigger.propTypes = {
268
+ value: PropTypes.string,
269
+ icon: PropTypes.func,
270
+ size: PropTypes.oneOf(['sm', 'md', 'lg'])
271
+ };
272
+ const TabsContent = ({
273
+ activeTabs,
274
+ ...props
275
+ }) => /*#__PURE__*/jsx(StyledContent, {
276
+ ...props
277
+ });
278
+ TabsContent.propTypes = {
279
+ value: PropTypes.string
280
+ };
281
+
282
+ export { Tabs, TabsContent, TabsList, TabsTrigger };