@mezzanine-ui/react 0.6.2 → 0.7.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.
Files changed (146) hide show
  1. package/Accordion/Accordion.js +3 -2
  2. package/Accordion/AccordionDetails.js +3 -2
  3. package/Accordion/AccordionSummary.js +3 -2
  4. package/Alert/Alert.js +3 -2
  5. package/AppBar/AppBar.js +3 -2
  6. package/AppBar/AppBarBrand.js +3 -2
  7. package/AppBar/AppBarMain.js +3 -2
  8. package/AppBar/AppBarSupport.js +3 -2
  9. package/Badge/Badge.js +3 -2
  10. package/Badge/BadgeContainer.js +3 -2
  11. package/Button/Button.d.ts +1 -1
  12. package/Button/Button.js +3 -2
  13. package/Button/ButtonGroup.js +3 -2
  14. package/Button/IconButton.js +3 -2
  15. package/Button/index.js +2 -2
  16. package/Calendar/Calendar.js +3 -2
  17. package/Calendar/CalendarCell.js +1 -1
  18. package/Calendar/CalendarContext.js +1 -2
  19. package/Calendar/CalendarControls.js +1 -1
  20. package/Calendar/CalendarDayOfWeek.js +1 -1
  21. package/Calendar/CalendarDays.js +1 -1
  22. package/Calendar/CalendarMonths.js +1 -1
  23. package/Calendar/CalendarWeeks.js +1 -1
  24. package/Calendar/CalendarYears.js +1 -1
  25. package/Card/Card.js +3 -2
  26. package/Card/CardActions.js +3 -2
  27. package/Checkbox/CheckAll.js +3 -2
  28. package/Checkbox/Checkbox.js +3 -2
  29. package/Checkbox/CheckboxGroup.js +3 -2
  30. package/ConfirmActions/ConfirmActions.js +3 -2
  31. package/DatePicker/DatePicker.js +3 -2
  32. package/DatePicker/DatePickerCalendar.js +3 -2
  33. package/DateRangePicker/DateRangePicker.js +3 -2
  34. package/DateRangePicker/DateRangePickerCalendar.js +3 -2
  35. package/DateRangePicker/useDateRangePickerValue.d.ts +2 -2
  36. package/DateTimePicker/DateTimePicker.js +3 -2
  37. package/DateTimePicker/DateTimePickerPanel.js +3 -2
  38. package/Drawer/Drawer.js +3 -2
  39. package/Dropdown/Dropdown.js +3 -2
  40. package/Empty/Empty.js +3 -2
  41. package/Form/FormField.js +3 -2
  42. package/Form/FormLabel.js +3 -2
  43. package/Form/FormMessage.js +3 -2
  44. package/Form/useSelectValueControl.js +8 -2
  45. package/Icon/Icon.js +3 -2
  46. package/Input/Input.js +3 -2
  47. package/Loading/Loading.js +3 -2
  48. package/Menu/Menu.js +3 -2
  49. package/Menu/MenuDivider.js +3 -2
  50. package/Menu/MenuItem.js +3 -2
  51. package/Menu/MenuItemGroup.js +3 -2
  52. package/Message/Message.d.ts +8 -5
  53. package/Message/Message.js +29 -13
  54. package/Message/index.d.ts +1 -1
  55. package/Modal/Modal.js +3 -2
  56. package/Modal/ModalActions.js +3 -2
  57. package/Modal/ModalBody.js +3 -2
  58. package/Modal/ModalFooter.js +3 -2
  59. package/Modal/ModalHeader.js +3 -2
  60. package/Navigation/Navigation.js +3 -2
  61. package/Navigation/NavigationItem.js +3 -2
  62. package/Navigation/NavigationSubMenu.js +3 -2
  63. package/Notification/Notification.js +3 -2
  64. package/Notifier/NotifierManager.js +1 -1
  65. package/Overlay/Overlay.js +3 -2
  66. package/PageFooter/PageFooter.js +3 -2
  67. package/Pagination/Pagination.js +3 -2
  68. package/Pagination/PaginationItem.js +3 -2
  69. package/Pagination/PaginationJumper.js +3 -2
  70. package/Picker/PickerTrigger.js +3 -2
  71. package/Picker/RangePickerTrigger.js +3 -2
  72. package/Picker/usePickerInputValue.js +1 -2
  73. package/Picker/usePickerValue.d.ts +1 -1
  74. package/Picker/useRangePickerValue.d.ts +2 -2
  75. package/Popconfirm/Popconfirm.js +3 -2
  76. package/Popover/Popover.js +3 -2
  77. package/Popper/Popper.js +3 -2
  78. package/Portal/Portal.js +3 -2
  79. package/Progress/Progress.js +3 -2
  80. package/Radio/Radio.js +3 -2
  81. package/Radio/RadioGroup.js +3 -2
  82. package/Select/AutoComplete.d.ts +1 -1
  83. package/Select/AutoComplete.js +3 -2
  84. package/Select/Option.js +3 -2
  85. package/Select/Select.d.ts +1 -1
  86. package/Select/Select.js +3 -2
  87. package/Select/SelectTrigger.js +3 -2
  88. package/Select/TreeSelect.d.ts +1 -1
  89. package/Select/TreeSelect.js +3 -2
  90. package/Skeleton/Skeleton.js +3 -2
  91. package/Slider/Slider.js +20 -3
  92. package/Slider/useSlider.js +8 -6
  93. package/Stepper/Step.js +3 -2
  94. package/Stepper/Stepper.js +3 -2
  95. package/Switch/Switch.js +3 -2
  96. package/Table/Table.d.ts +51 -44
  97. package/Table/Table.js +42 -23
  98. package/Table/TableBody.js +10 -4
  99. package/Table/TableBodyRow.js +3 -2
  100. package/Table/TableCell.js +3 -2
  101. package/Table/TableHeader.js +3 -2
  102. package/Table/editable/TableEditRenderWrapper.js +1 -1
  103. package/Table/expandable/TableExpandable.js +3 -2
  104. package/Table/pagination/TablePagination.js +13 -14
  105. package/Table/pagination/useTablePagination.d.ts +5 -13
  106. package/Table/pagination/useTablePagination.js +3 -23
  107. package/Table/refresh/TableRefresh.js +3 -2
  108. package/Table/rowSelection/TableRowSelection.js +3 -2
  109. package/Table/sorting/TableSortingIcon.js +3 -2
  110. package/Table/useTableScroll.d.ts +4 -4
  111. package/Table/useTableScroll.js +1 -1
  112. package/Tabs/Tab.js +3 -2
  113. package/Tabs/TabPane.js +3 -2
  114. package/Tabs/Tabs.js +3 -2
  115. package/Tabs/useTabsOverflow.js +1 -1
  116. package/Tag/Tag.js +3 -2
  117. package/TextField/TextField.js +3 -2
  118. package/Textarea/Textarea.js +3 -2
  119. package/TimePanel/TimePanel.js +3 -2
  120. package/TimePanel/TimePanelAction.js +3 -2
  121. package/TimePanel/TimePanelColumn.js +3 -2
  122. package/TimePicker/TimePicker.js +3 -2
  123. package/TimePicker/TimePickerPanel.js +3 -2
  124. package/Tooltip/Tooltip.js +3 -2
  125. package/Transition/Collapse.js +3 -2
  126. package/Transition/Fade.js +3 -2
  127. package/Transition/Grow.js +3 -2
  128. package/Transition/SlideFade.js +3 -2
  129. package/Transition/Transition.d.ts +1 -1
  130. package/Transition/Transition.js +2 -2
  131. package/Transition/Zoom.js +3 -2
  132. package/Tree/Tree.js +3 -2
  133. package/Tree/TreeNode.js +3 -2
  134. package/Tree/TreeNodeList.js +3 -2
  135. package/Typography/Typography.d.ts +1 -1
  136. package/Typography/Typography.js +3 -2
  137. package/Upload/UploadButton.js +3 -2
  138. package/Upload/UploadInput.js +3 -2
  139. package/Upload/UploadResult.js +3 -2
  140. package/_internal/InputCheck/InputCheck.js +3 -2
  141. package/_internal/InputCheck/InputCheckGroup.js +3 -2
  142. package/_internal/InputTriggerPopper/InputTriggerPopper.js +3 -2
  143. package/index.d.ts +4 -2
  144. package/index.js +51 -49
  145. package/package.json +5 -5
  146. package/utils/{rename-types.d.ts → general.d.ts} +3 -0
package/Slider/Slider.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { forwardRef, useState, useEffect } from 'react';
3
- import { isRangeSlider, sortSliderValue, sliderClasses, roundToStep } from '@mezzanine-ui/core/slider';
3
+ import { isRangeSlider, fixRangeSliderValue, fixSingleSliderValue, sortSliderValue, sliderClasses, roundToStep } from '@mezzanine-ui/core/slider';
4
4
  import { useSlider } from './useSlider.js';
5
5
  import Input from '../Input/Input.js';
6
6
  import Tooltip from '../Tooltip/Tooltip.js';
@@ -36,6 +36,22 @@ function SliderComponent(props) {
36
36
  }
37
37
  return `${value[1]}`;
38
38
  });
39
+ useEffect(() => {
40
+ if (max > min) {
41
+ if (isRangeSlider(value)) {
42
+ if ((value[0] > max && value[1] > max) ||
43
+ (value[0] < min && value[1] < min) ||
44
+ value[0] < min ||
45
+ value[1] > max) {
46
+ onChange(fixRangeSliderValue(value, min, max));
47
+ }
48
+ return;
49
+ }
50
+ if (value < min || value > max) {
51
+ onChange(fixSingleSliderValue(value, min, max));
52
+ }
53
+ }
54
+ }, [min, max, onChange, value]);
39
55
  useEffect(() => {
40
56
  if (withInput) {
41
57
  if (isRangeSlider(value)) {
@@ -167,6 +183,7 @@ const Slider = forwardRef((props, ref) => {
167
183
  return (jsx(SliderComponent, Object.assign({}, props, { innerRef: ref }), void 0));
168
184
  }
169
185
  return (jsx(SliderComponent, Object.assign({}, props, { innerRef: ref }), void 0));
170
- });
186
+ });
187
+ var Slider$1 = Slider;
171
188
 
172
- export default Slider;
189
+ export { Slider$1 as default };
@@ -1,4 +1,4 @@
1
- import { toSliderCssVars, getPercentage, isRangeSlider, sortSliderValue, findClosetValueIndex, getSliderRect, getValueFromClientX, roundToStep } from '@mezzanine-ui/core/slider';
1
+ import { isRangeSlider, fixRangeSliderValue, fixSingleSliderValue, toSliderCssVars, getPercentage, findClosetValueIndex, sortSliderValue, getSliderRect, getValueFromClientX, roundToStep } from '@mezzanine-ui/core/slider';
2
2
  import { useRef, useState } from 'react';
3
3
  import { useDocumentEvents } from '../hooks/useDocumentEvents.js';
4
4
 
@@ -13,12 +13,14 @@ function useSlider(props) {
13
13
  }
14
14
  return isRangeSlider(value) ? Math.abs(1 - value.indexOf(anchorValue)) : undefined;
15
15
  }
16
+ const fixedValue = isRangeSlider(value) ? fixRangeSliderValue(value, min, max)
17
+ : fixSingleSliderValue(value, min, max);
16
18
  const cssVars = toSliderCssVars({
17
- trackWidth: getPercentage(isRangeSlider(value) ? Math.abs(value[0] - value[1]) : value, min, max),
18
- trackPosition: getPercentage(isRangeSlider(value) ? Math.abs(Math.min(...value) - min) : 0, min, max),
19
- handlerPosition: getPercentage(isRangeSlider(value) ? 0 : value, min, max),
20
- handlerStartPosition: getPercentage(isRangeSlider(value) ? Math.abs(Math.min(...value) - min) : value, min, max),
21
- handlerEndPosition: getPercentage(isRangeSlider(value) ? Math.abs(Math.max(...value) - min) : value, min, max),
19
+ trackWidth: getPercentage(isRangeSlider(fixedValue) ? Math.abs(fixedValue[0] - fixedValue[1]) : fixedValue - min, min, max),
20
+ trackPosition: getPercentage(isRangeSlider(fixedValue) ? Math.abs(Math.min(...fixedValue) - min) : 0, min, max),
21
+ handlerPosition: getPercentage(isRangeSlider(fixedValue) ? 0 : fixedValue - min, min, max),
22
+ handlerStartPosition: getPercentage(isRangeSlider(fixedValue) ? Math.abs(Math.min(...fixedValue) - min) : fixedValue, min, max),
23
+ handlerEndPosition: getPercentage(isRangeSlider(fixedValue) ? Math.abs(Math.max(...fixedValue) - min) : fixedValue, min, max),
22
24
  });
23
25
  const getRoundedNewValue = (e, railElement) => {
24
26
  const clientX = e.type === 'touchmove' ? e.changedTouches[0].clientX : e.clientX;
package/Stepper/Step.js CHANGED
@@ -14,6 +14,7 @@ const Step = forwardRef(function Step(props, ref) {
14
14
  /** icon and step number */
15
15
  const iconRender = (jsx(Typography, Object.assign({ className: stepClasses.iconBackground, variant: "button3" }, { children: completed ? (jsx(Icon, Object.assign({ className: stepClasses.completedIcon, icon: CheckIcon }, completedIconProps), void 0)) : index + 1 }), void 0));
16
16
  return (jsxs("div", Object.assign({ className: cx(stepClasses.host, disabled && stepClasses.disabled, className), ref: ref }, rest, { children: [iconRender, /** title (optional) */ title && (jsx(Typography, Object.assign({ className: stepClasses.title, variant: "button2" }, titleProps, { children: title }), void 0)), children] }), void 0));
17
- });
17
+ });
18
+ var Step$1 = Step;
18
19
 
19
- export default Step;
20
+ export { Step$1 as default };
@@ -28,6 +28,7 @@ const Stepper = forwardRef(function Stepper(props, ref) {
28
28
  });
29
29
  });
30
30
  return (jsx("div", Object.assign({ className: cx(stepperClasses.host, className), ref: ref }, rest, { children: stepsWithState }), void 0));
31
- });
31
+ });
32
+ var Stepper$1 = Stepper;
32
33
 
33
- export default Stepper;
34
+ export { Stepper$1 as default };
package/Switch/Switch.js CHANGED
@@ -24,6 +24,7 @@ const Switch = forwardRef(function Switch(props, ref) {
24
24
  [switchClasses.large]: size === 'large',
25
25
  }, className) }, { children: [jsx("span", Object.assign({ className: switchClasses.control }, { children: loading && jsx(Icon, { icon: SwitchSpinnerIcon, spin: true }, void 0) }), void 0),
26
26
  jsx("input", Object.assign({}, inputProps, { "aria-checked": checked, "aria-disabled": disabled, checked: checked, className: switchClasses.input, disabled: disabled, onChange: onChange, type: "checkbox" }), void 0)] }), void 0));
27
- });
27
+ });
28
+ var Switch$1 = Switch;
28
29
 
29
- export default Switch;
30
+ export { Switch$1 as default };
package/Table/Table.d.ts CHANGED
@@ -2,78 +2,85 @@
2
2
  import { TableColumn, TableComponents, TableDataSource, TableRowSelection, TableExpandable, TableFetchMore, TablePagination as TablePaginationType, TableRefresh as TableRefreshType } from '@mezzanine-ui/core/table';
3
3
  import { EmptyProps } from '../Empty';
4
4
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
5
- export interface TableProps<T> extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'role'> {
5
+ export interface TableBaseProps<T> extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'role'> {
6
6
  /**
7
7
  * customized body className
8
8
  */
9
9
  bodyClassName?: string;
10
10
  /**
11
- * customized body row className
12
- */
11
+ * customized body row className
12
+ */
13
13
  bodyRowClassName?: string;
14
14
  /**
15
- * Columns of table <br />
16
- * `column.render` allowed customizing the column body cell rendering. <br />
17
- * `column.renderTitle` allowed customizing the column header cell rendering. <br />
18
- * `column.sorter` is the sorting method that you want to apply to your column. <br />
19
- * `column.onSorted` is the callback triggered whenever sort icon clicked.
20
- */
15
+ * Columns of table <br />
16
+ * `column.render` allowed customizing the column body cell rendering. <br />
17
+ * `column.renderTitle` allowed customizing the column header cell rendering. <br />
18
+ * `column.sorter` is the sorting method that you want to apply to your column. <br />
19
+ * `column.onSorted` is the callback triggered whenever sort icon clicked.
20
+ */
21
21
  columns: TableColumn<T>[];
22
22
  /**
23
- * Custom table components <br />
24
- */
23
+ * Custom table components <br />
24
+ */
25
25
  components?: TableComponents;
26
26
  /**
27
- * Data record array to be displayed. <br />
28
- * Notice that each source should contain `key` or `id` prop as data primary key.
29
- */
27
+ * Data record array to be displayed. <br />
28
+ * Notice that each source should contain `key` or `id` prop as data primary key.
29
+ */
30
30
  dataSource: TableDataSource[];
31
31
  /**
32
- * props exported from `<Empty />` component.
33
- */
32
+ * props exported from `<Empty />` component.
33
+ */
34
34
  emptyProps?: EmptyProps;
35
35
  /**
36
- * When `expandable.rowExpandable` is given, it will control whether row data is expandable or not
37
- * `expandable.expandedRowRender` is a callback to helps you decides what data should be rendered.
38
- */
36
+ * When `expandable.rowExpandable` is given, it will control whether row data is expandable or not
37
+ * `expandable.expandedRowRender` is a callback to helps you decides what data should be rendered.
38
+ */
39
39
  expandable?: TableExpandable<T>;
40
- /**
41
- * If `fetchMore.callback` is given, table will automatically trigger it when scrolling position reach end. <br />
42
- * If `fetchMore.isReachEnd` is true, table will stop triggering callback. <br />
43
- * If `fetchMore.isFetching` is true, a loading spinner will display at the end of table and stop triggering callback.
44
- * <br />
45
- * Notice that when `fetchMore.isFetching` is `undefined`, table will take control of it when source length changed.
46
- */
47
- fetchMore?: TableFetchMore;
48
40
  /**
49
41
  * customized header className
50
42
  */
51
43
  headerClassName?: string;
52
44
  /**
53
- * Whether table is loading or not
54
- */
45
+ * Whether table is loading or not
46
+ */
55
47
  loading?: boolean;
56
- /**
57
- * `pagination.show` controls pagination display. <br />
58
- * `pagination.current` is the current page number. <br />
59
- * `pagination.onChange` is the callback when page number changed. <br />
60
- * `pagination.total` is the total amount of your data. <br />
61
- * `pagination.options` is the <Pagination /> component props. <br />
62
- * Notice that if `pagination` object is given, table will disable fetchMore and use pagination instead.
63
- */
64
- pagination?: TablePaginationType;
65
48
  /**
66
49
  * `refresh.show` is true, refresh button will display at the top-start of table. <br />
67
50
  * `refresh.onClick` is the callback of the refresh button.
68
51
  */
69
52
  refresh?: TableRefreshType;
70
53
  /**
71
- * Enable row selection feature <br />
72
- * `rowSelection.selectedRowKey` is the dataSource keys that are currently selected. <br />
73
- * `rowSelection.onChange` is the callback when selection changed. <br />
74
- * `rowSelection.actions` are the actions that you want to do for selected data.
75
- */
54
+ * Enable row selection feature <br />
55
+ * `rowSelection.selectedRowKey` is the dataSource keys that are currently selected. <br />
56
+ * `rowSelection.onChange` is the callback when selection changed. <br />
57
+ * `rowSelection.actions` are the actions that you want to do for selected data.
58
+ */
76
59
  rowSelection?: TableRowSelection;
77
60
  }
78
- declare const Table: import("react").ForwardRefExoticComponent<TableProps<Record<string, unknown>> & import("react").RefAttributes<HTMLDivElement>>;
61
+ export interface TableWithFetchMore<T> extends TableBaseProps<T> {
62
+ /**
63
+ * If `fetchMore.callback` is given, table will automatically trigger it when scrolling position reach end. <br />
64
+ * If `fetchMore.isReachEnd` is true, table will stop triggering callback. <br />
65
+ * If `fetchMore.isFetching` is true, a loading spinner will display at the end of table and stop triggering callback.
66
+ * <br />
67
+ * Notice that when `fetchMore.isFetching` is `undefined`, table will take control of it when source length changed.
68
+ */
69
+ fetchMore?: TableFetchMore;
70
+ pagination?: undefined;
71
+ }
72
+ export interface TableWithPagination<T> extends TableBaseProps<T> {
73
+ /**
74
+ * `pagination.current` is the current page number. (required) <br />
75
+ * `pagination.onChange` is the callback when page number changed. (required) <br />
76
+ * `pagination.disableAutoSlicing` set this to true if you don't want auto data slicing. <br />
77
+ * `pagination.total` is the total amount of your data. (default will be dataSource length) <br />
78
+ * `pagination.options` is the <Pagination /> component props. <br />
79
+ * Notice that if `pagination` object is given, table will disable fetchMore and use pagination instead.
80
+ */
81
+ pagination?: TablePaginationType;
82
+ fetchMore?: undefined;
83
+ }
84
+ export declare type TableProps<T> = TableWithFetchMore<T> | TableWithPagination<T>;
85
+ declare const Table: import("react").ForwardRefExoticComponent<(TableWithFetchMore<Record<string, unknown>> & import("react").RefAttributes<HTMLDivElement>) | (TableWithPagination<Record<string, unknown>> & import("react").RefAttributes<HTMLDivElement>)>;
79
86
  export default Table;
package/Table/Table.js CHANGED
@@ -61,26 +61,44 @@ const Table = forwardRef(function Table(props, ref) {
61
61
  refreshProp.show) !== null && _a !== void 0 ? _a : false);
62
62
  }, [refreshProp === null || refreshProp === void 0 ? void 0 : refreshProp.show]);
63
63
  /** context */
64
- const tableContextValue = useMemo(() => ({
65
- scrollBarSize: 4,
66
- emptyProps,
67
- rowSelection,
68
- sorting: {
69
- onSort,
70
- onResetAll,
71
- sortedOn,
72
- sortedType,
73
- },
74
- loading,
75
- setLoading,
76
- expanding: expandableProp,
77
- fetchMore: onFetchMore ? {
78
- onFetchMore,
79
- isFetching,
80
- isReachEnd,
81
- } : undefined,
82
- pagination: paginationProp,
83
- }), [
64
+ const tableContextValue = useMemo(() => {
65
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
66
+ return ({
67
+ scrollBarSize: 4,
68
+ emptyProps,
69
+ rowSelection,
70
+ sorting: {
71
+ onSort,
72
+ onResetAll,
73
+ sortedOn,
74
+ sortedType,
75
+ },
76
+ loading,
77
+ setLoading,
78
+ expanding: expandableProp,
79
+ fetchMore: onFetchMore ? {
80
+ onFetchMore,
81
+ isFetching,
82
+ isReachEnd,
83
+ } : undefined,
84
+ pagination: paginationProp ? {
85
+ current: paginationProp.current,
86
+ disableAutoSlicing: (_a = paginationProp.disableAutoSlicing) !== null && _a !== void 0 ? _a : false,
87
+ onChange: paginationProp.onChange,
88
+ total: (_b = paginationProp.total) !== null && _b !== void 0 ? _b : dataSource.length,
89
+ options: {
90
+ boundaryCount: (_d = (_c = paginationProp.options) === null || _c === void 0 ? void 0 : _c.boundaryCount) !== null && _d !== void 0 ? _d : 1,
91
+ className: (_e = paginationProp.options) === null || _e === void 0 ? void 0 : _e.className,
92
+ disabled: (_g = (_f = paginationProp.options) === null || _f === void 0 ? void 0 : _f.disabled) !== null && _g !== void 0 ? _g : false,
93
+ hideNextButton: (_j = (_h = paginationProp.options) === null || _h === void 0 ? void 0 : _h.hideNextButton) !== null && _j !== void 0 ? _j : false,
94
+ hidePreviousButton: (_l = (_k = paginationProp.options) === null || _k === void 0 ? void 0 : _k.hidePreviousButton) !== null && _l !== void 0 ? _l : false,
95
+ pageSize: (_o = (_m = paginationProp.options) === null || _m === void 0 ? void 0 : _m.pageSize) !== null && _o !== void 0 ? _o : 10,
96
+ siblingCount: (_q = (_p = paginationProp.options) === null || _p === void 0 ? void 0 : _p.siblingCount) !== null && _q !== void 0 ? _q : 1,
97
+ },
98
+ } : undefined,
99
+ });
100
+ }, [
101
+ dataSource,
84
102
  emptyProps,
85
103
  expandableProp,
86
104
  rowSelection,
@@ -105,7 +123,8 @@ const Table = forwardRef(function Table(props, ref) {
105
123
  return (jsx(Loading, Object.assign({ loading: loading, stretch: true, tip: "\u8CC7\u6599\u8F09\u5165\u4E2D..." }, { children: jsx("div", Object.assign({ ref: ref }, rest, { className: cx(tableClasses.host, className), role: "grid" }, { children: jsx(TableContext.Provider, Object.assign({ value: tableContextValue }, { children: jsx(TableDataContext.Provider, Object.assign({ value: tableDataContextValue }, { children: jsxs(TableComponentContext.Provider, Object.assign({ value: tableComponentContextValue }, { children: [isRefreshShow ? (jsx(TableRefresh, { onClick: refreshProp.onClick }, void 0)) : null,
106
124
  jsx(TableHeader, { className: headerClassName }, void 0),
107
125
  jsx(TableBody, { ref: bodyRef, className: bodyClassName, rowClassName: bodyRowClassName }, void 0),
108
- (paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.show) ? (jsx(TablePagination, { bodyRef: bodyRef }, void 0)) : null] }), void 0) }), void 0) }), void 0) }), void 0) }), void 0));
109
- });
126
+ paginationProp ? (jsx(TablePagination, { bodyRef: bodyRef }, void 0)) : null] }), void 0) }), void 0) }), void 0) }), void 0) }), void 0));
127
+ });
128
+ var Table$1 = Table;
110
129
 
111
- export default Table;
130
+ export { Table$1 as default };
@@ -12,12 +12,17 @@ import cx from 'clsx';
12
12
  const TableBody = forwardRef(function TableBody(props, ref) {
13
13
  const { className, rowClassName, ...rest } = props;
14
14
  const { dataSource = [], } = useContext(TableDataContext) || {};
15
- const { emptyProps, scrollBarSize, fetchMore, } = useContext(TableContext) || {};
15
+ const { emptyProps, fetchMore, scrollBarSize, pagination, } = useContext(TableContext) || {};
16
16
  const [tableBody, scrollElement] = useTableScroll();
17
17
  const composedRefs = useComposeRefs([ref, tableBody.ref]);
18
18
  /** customizing empty */
19
19
  const { className: emptyComponentClassName = '', children: emptyComponentChildren = '查無資料', fullHeight: emptyComponentFullHeight = true, ...restEmptyProps } = emptyProps || {};
20
- return (jsxs("div", Object.assign({}, rest, { ref: composedRefs, className: cx(tableClasses.body, className), onScroll: tableBody.onScroll, role: "rowgroup" }, { children: [dataSource.length ? dataSource.map((rowData) => (jsx(TableBodyRow, { className: rowClassName, rowData: rowData }, (rowData.key || rowData.id)))) : (jsx(Empty, Object.assign({}, restEmptyProps, { className: cx(tableClasses.bodyEmpty, emptyComponentClassName), fullHeight: emptyComponentFullHeight }, { children: emptyComponentChildren }), void 0)),
20
+ /** pagination feature */
21
+ const { current: currentPage, disableAutoSlicing, total, options: paginationOptions, } = pagination || {};
22
+ const currentStartCount = (paginationOptions === null || paginationOptions === void 0 ? void 0 : paginationOptions.pageSize) && currentPage ? ((paginationOptions.pageSize) * (currentPage - 1)) : 0;
23
+ const currentEndCount = (paginationOptions === null || paginationOptions === void 0 ? void 0 : paginationOptions.pageSize) && currentPage && total ? (Math.min(((paginationOptions.pageSize) * currentPage), total)) : 0;
24
+ const currentDataSource = pagination && !disableAutoSlicing ? (dataSource.slice(currentStartCount, currentEndCount)) : dataSource;
25
+ return (jsxs("div", Object.assign({}, rest, { ref: composedRefs, className: cx(tableClasses.body, className), onScroll: tableBody.onScroll, role: "rowgroup" }, { children: [currentDataSource.length ? currentDataSource.map((rowData) => (jsx(TableBodyRow, { className: rowClassName, rowData: rowData }, (rowData.key || rowData.id)))) : (jsx(Empty, Object.assign({}, restEmptyProps, { className: cx(tableClasses.bodyEmpty, emptyComponentClassName), fullHeight: emptyComponentFullHeight }, { children: emptyComponentChildren }), void 0)),
21
26
  (fetchMore === null || fetchMore === void 0 ? void 0 : fetchMore.isFetching) ? (jsx("div", Object.assign({ className: tableClasses.bodyFetchMore }, { children: jsx(Loading, { loading: true }, void 0) }), void 0)) : null,
22
27
  jsx("div", Object.assign({ ref: scrollElement.ref, onMouseDown: scrollElement.onMouseDown, onMouseUp: scrollElement.onMouseUp, onMouseEnter: scrollElement.onMouseEnter, onMouseLeave: scrollElement.onMouseLeave, role: "button", style: scrollElement.style, tabIndex: -1 }, { children: jsx("div", { style: {
23
28
  width: `${scrollBarSize}px`,
@@ -26,6 +31,7 @@ const TableBody = forwardRef(function TableBody(props, ref) {
26
31
  backgroundColor: '#7d7d7d',
27
32
  transition: '0.1s',
28
33
  } }, void 0) }), void 0)] }), void 0));
29
- });
34
+ });
35
+ var TableBody$1 = TableBody;
30
36
 
31
- export default TableBody;
37
+ export { TableBody$1 as default };
@@ -58,6 +58,7 @@ const TableBodyRow = forwardRef(function TableBodyRow(props, ref) {
58
58
  return (jsx("div", Object.assign({ className: cx(tableClasses.bodyRowCellWrapper, column.bodyClassName), style: getColumnStyle(column) }, { children: jsx(TableEditRenderWrapper, Object.assign({}, column, { rowData: rowData }, { children: jsx(TableCell, Object.assign({ ellipsis: ellipsis, forceShownTooltipWhenHovered: column.forceShownTooltipWhenHovered, style: getCellStyle(column), tooltipTitle: tooltipTitle }, { children: ((_d = column.render) === null || _d === void 0 ? void 0 : _d.call(column, column, rowData, index)) || rowData[column.dataIndex] }), void 0) }), void 0) }), `${column.dataIndex}-${column.title}`));
59
59
  })] }), void 0),
60
60
  renderedExpandedContent ? (jsx(AccordionDetails, Object.assign({ className: expanding.className, expanded: expanded }, { children: renderedExpandedContent }), void 0)) : null] }, void 0));
61
- });
61
+ });
62
+ var TableBodyRow$1 = TableBodyRow;
62
63
 
63
- export default TableBodyRow;
64
+ export { TableBodyRow$1 as default };
@@ -18,6 +18,7 @@ const TableCell = forwardRef(function TableCell(props, ref) {
18
18
  onMouseEnter(e);
19
19
  }
20
20
  }, onMouseLeave: onMouseLeave }, { children: children }), void 0)) }), void 0)) : children }), void 0));
21
- });
21
+ });
22
+ var TableCell$1 = TableCell;
22
23
 
23
- export default TableCell;
24
+ export { TableCell$1 as default };
@@ -42,6 +42,7 @@ const TableHeader = forwardRef(function TableHeader(props, ref) {
42
42
  return (jsx("div", Object.assign({ className: cx(tableClasses.headerCellWrapper, column.headerClassName), style: getColumnStyle(column) }, { children: jsxs(TableCell, Object.assign({ ellipsis: false, role: "columnheader", style: getCellStyle(column) }, { children: [((_a = column.renderTitle) === null || _a === void 0 ? void 0 : _a.call(column, tableClasses)) || column.title,
43
43
  typeof column.sorter === 'function' ? (jsx(TableSortingIcon, { column: column }, void 0)) : null] }), void 0) }), `${column.dataIndex}-${column.title}`));
44
44
  })] }), void 0));
45
- });
45
+ });
46
+ var TableHeader$1 = TableHeader;
46
47
 
47
- export default TableHeader;
48
+ export { TableHeader$1 as default };
@@ -12,4 +12,4 @@ function TableEditRenderWrapper({ children, dataIndex, editable, rowData, setCel
12
12
  return (jsx(Fragment, { children: children }, void 0));
13
13
  }
14
14
 
15
- export default TableEditRenderWrapper;
15
+ export { TableEditRenderWrapper as default };
@@ -10,6 +10,7 @@ const TableExpandable = forwardRef(function TableExpandable(props, ref) {
10
10
  return (jsx("div", Object.assign({}, rest, { ref: ref, className: cx(tableClasses.collapseAction, className) }, { children: jsx("div", Object.assign({ className: tableClasses.icon }, { children: showIcon ? (jsx(Icon, { className: cx(tableClasses.icon, {
11
11
  [tableClasses.iconClickable]: expandable,
12
12
  }), color: expandable ? 'primary' : 'disabled', icon: ChevronDownIcon, onClick: () => expandable && (setExpanded === null || setExpanded === void 0 ? void 0 : setExpanded(!expanded)), style: { transform: `rotate(${expanded ? '180deg' : '0'})` } }, void 0)) : null }), void 0) }), void 0));
13
- });
13
+ });
14
+ var TableExpandable$1 = TableExpandable;
14
15
 
15
- export default TableExpandable;
16
+ export { TableExpandable$1 as default };
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { forwardRef, useContext } from 'react';
3
3
  import { tableClasses } from '@mezzanine-ui/core/table';
4
- import { TableContext, TableDataContext } from '../TableContext.js';
4
+ import { TableContext } from '../TableContext.js';
5
5
  import { useTablePagination } from './useTablePagination.js';
6
6
  import Pagination from '../../Pagination/Pagination.js';
7
7
  import cx from 'clsx';
@@ -9,19 +9,18 @@ import cx from 'clsx';
9
9
  const TablePagination = forwardRef(function TablePagination(props, ref) {
10
10
  const { className, bodyRef, ...rest } = props;
11
11
  const { pagination, } = useContext(TableContext) || {};
12
- const { dataSource = [], } = useContext(TableDataContext) || {};
13
- const [currentPage, setCurrentPage, options] = useTablePagination({
12
+ const { current: currentPageProp, onChange: onChangePageProp, total, options: paginationOptions = {}, } = pagination || {};
13
+ const [currentPage, setCurrentPage] = useTablePagination({
14
14
  bodyRef,
15
- current: pagination === null || pagination === void 0 ? void 0 : pagination.current,
16
- dataSource,
17
- onChange: pagination === null || pagination === void 0 ? void 0 : pagination.onChange,
18
- options: pagination === null || pagination === void 0 ? void 0 : pagination.options,
19
- total: pagination === null || pagination === void 0 ? void 0 : pagination.total,
15
+ current: currentPageProp,
16
+ onChange: onChangePageProp,
20
17
  });
21
- const currentStartCount = (options.pageSize * (currentPage - 1)) + 1;
22
- const currentEndCount = Math.min(options.pageSize * currentPage, options.total);
23
- return (jsxs("div", Object.assign({}, rest, { ref: ref, className: cx(tableClasses.pagination, className) }, { children: [jsx("span", Object.assign({ className: tableClasses.paginationIndicator }, { children: `目前顯示 ${currentStartCount} - ${currentEndCount} 筆,共 ${options.total} 筆資料` }), void 0),
24
- jsx("div", Object.assign({ className: tableClasses.paginationActions }, { children: jsx(Pagination, { boundaryCount: options.boundaryCount, className: options.className, current: currentPage, disabled: options.disabled, hideNextButton: options.hideNextButton, hidePreviousButton: options.hidePreviousButton, onChange: setCurrentPage, pageSize: options.pageSize, siblingCount: options.siblingCount, total: options.total }, void 0) }), void 0)] }), void 0));
25
- });
18
+ const { boundaryCount, className: paginationClassName, disabled, hideNextButton, hidePreviousButton, pageSize: pageSizeProp, siblingCount, } = paginationOptions;
19
+ const currentStartCount = (pageSizeProp * (currentPage - 1)) + 1;
20
+ const currentEndCount = Math.min(pageSizeProp * currentPage, total);
21
+ return (jsxs("div", Object.assign({}, rest, { ref: ref, className: cx(tableClasses.pagination, className) }, { children: [jsx("span", Object.assign({ className: tableClasses.paginationIndicator }, { children: `目前顯示 ${currentStartCount} - ${currentEndCount} 筆,共 ${total} 筆資料` }), void 0),
22
+ jsx("div", Object.assign({ className: tableClasses.paginationActions }, { children: jsx(Pagination, { boundaryCount: boundaryCount, className: paginationClassName, current: currentPage, disabled: disabled, hideNextButton: hideNextButton, hidePreviousButton: hidePreviousButton, onChange: setCurrentPage, pageSize: pageSizeProp, siblingCount: siblingCount, total: total }, void 0) }), void 0)] }), void 0));
23
+ });
24
+ var TablePagination$1 = TablePagination;
26
25
 
27
- export default TablePagination;
26
+ export { TablePagination$1 as default };
@@ -1,16 +1,8 @@
1
1
  import { RefObject } from 'react';
2
- import { TablePagination, TableDataSource } from '@mezzanine-ui/core/table';
3
- export interface UseTablePagination extends Omit<TablePagination, 'show'> {
2
+ import { TablePagination } from '@mezzanine-ui/core/table';
3
+ export interface UseTablePagination {
4
4
  bodyRef: RefObject<HTMLDivElement>;
5
- dataSource: TableDataSource[];
5
+ current?: TablePagination['current'];
6
+ onChange?: TablePagination['onChange'];
6
7
  }
7
- export declare function useTablePagination(props: UseTablePagination): readonly [number, (c: number) => void, {
8
- boundaryCount: number;
9
- className: string | undefined;
10
- disabled: boolean;
11
- hideNextButton: boolean;
12
- hidePreviousButton: boolean;
13
- pageSize: number;
14
- siblingCount: number;
15
- total: number;
16
- }];
8
+ export declare function useTablePagination(props: UseTablePagination): readonly [number, (c: number) => void];
@@ -1,12 +1,11 @@
1
- import { useContext, useMemo } from 'react';
1
+ import { useContext } from 'react';
2
2
  import { useControlValueState } from '../../Form/useControlValueState.js';
3
3
  import { useLastCallback } from '../../hooks/useLastCallback.js';
4
4
  import { TableContext } from '../TableContext.js';
5
5
 
6
6
  const equalityFn = (a, b) => a === b;
7
7
  function useTablePagination(props) {
8
- const { bodyRef, current: currentProp, dataSource, onChange: onChangeProp, options: optionsProp, total: totalProp, } = props;
9
- const { boundaryCount = 1, className, disabled = false, hideNextButton = false, hidePreviousButton = false, pageSize: pageSizeProp, siblingCount = 1, } = optionsProp || {};
8
+ const { bodyRef, current: currentProp, onChange: onChangeProp, } = props;
10
9
  const { sorting, } = useContext(TableContext) || {};
11
10
  const [current, setCurrent] = useControlValueState({
12
11
  defaultValue: 1,
@@ -24,26 +23,7 @@ function useTablePagination(props) {
24
23
  }
25
24
  onChangeProp === null || onChangeProp === void 0 ? void 0 : onChangeProp(newCurrent);
26
25
  });
27
- const pageSize = useMemo(() => (pageSizeProp !== null && pageSizeProp !== void 0 ? pageSizeProp : dataSource.length), [pageSizeProp, dataSource.length]);
28
- const total = useMemo(() => (totalProp !== null && totalProp !== void 0 ? totalProp : (dataSource.length / pageSize)), [totalProp, dataSource.length, pageSize]);
29
- const defaultOptions = useMemo(() => ({
30
- boundaryCount,
31
- className,
32
- disabled,
33
- hideNextButton,
34
- hidePreviousButton,
35
- pageSize,
36
- siblingCount,
37
- total,
38
- }), [
39
- boundaryCount,
40
- className,
41
- disabled,
42
- hideNextButton,
43
- hidePreviousButton,
44
- siblingCount,
45
- ]);
46
- return [current, onChange, defaultOptions];
26
+ return [current, onChange];
47
27
  }
48
28
 
49
29
  export { useTablePagination };
@@ -18,6 +18,7 @@ const TableRefresh = forwardRef(function TableRefresh(props, ref) {
18
18
  setLoading,
19
19
  ]);
20
20
  return (jsx("div", Object.assign({ ref: ref, className: tableClasses.refresh }, rest, { children: jsx(Button, Object.assign({ onClick: onRefreshClicked, prefix: jsx(Icon, { icon: ResetIcon }, void 0) }, { children: children || '重新整理' }), void 0) }), void 0));
21
- });
21
+ });
22
+ var TableRefresh$1 = TableRefresh;
22
23
 
23
- export default TableRefresh;
24
+ export { TableRefresh$1 as default };
@@ -81,6 +81,7 @@ const TableRowSelection = forwardRef(function TableRowSelection(props, ref) {
81
81
  } }, { children: (dropdownRef) => (jsx(Icon, { ref: dropdownRef, className: cx(tableClasses.icon, {
82
82
  [tableClasses.iconClickable]: isMenuAllowOpen,
83
83
  }), color: isMenuAllowOpen ? 'primary' : 'disabled', icon: MoreVerticalIcon, onClick: onIconClicked }, void 0)) }), void 0)) : null }), void 0)] }), void 0));
84
- });
84
+ });
85
+ var TableRowSelection$1 = TableRowSelection;
85
86
 
86
- export default TableRowSelection;
87
+ export { TableRowSelection$1 as default };
@@ -23,6 +23,7 @@ const TableSortingIcon = forwardRef(function TableSortingIcon(props, ref) {
23
23
  evt.stopPropagation();
24
24
  (_a = sorting === null || sorting === void 0 ? void 0 : sorting.onSort) === null || _a === void 0 ? void 0 : _a.call(sorting, column);
25
25
  }, style: currentIconStyle.style }), void 0));
26
- });
26
+ });
27
+ var TableSortingIcon$1 = TableSortingIcon;
27
28
 
28
- export default TableSortingIcon;
29
+ export { TableSortingIcon$1 as default };
@@ -120,10 +120,10 @@ export default function useTableScroll(): readonly [{
120
120
  onCompositionStartCapture?: ((event: import("react").CompositionEvent<HTMLDivElement>) => void) | undefined;
121
121
  onCompositionUpdate?: ((event: import("react").CompositionEvent<HTMLDivElement>) => void) | undefined;
122
122
  onCompositionUpdateCapture?: ((event: import("react").CompositionEvent<HTMLDivElement>) => void) | undefined;
123
- onFocus?: ((event: import("react").FocusEvent<HTMLDivElement>) => void) | undefined;
124
- onFocusCapture?: ((event: import("react").FocusEvent<HTMLDivElement>) => void) | undefined;
125
- onBlur?: ((event: import("react").FocusEvent<HTMLDivElement>) => void) | undefined;
126
- onBlurCapture?: ((event: import("react").FocusEvent<HTMLDivElement>) => void) | undefined;
123
+ onFocus?: ((event: import("react").FocusEvent<HTMLDivElement, Element>) => void) | undefined;
124
+ onFocusCapture?: ((event: import("react").FocusEvent<HTMLDivElement, Element>) => void) | undefined;
125
+ onBlur?: ((event: import("react").FocusEvent<HTMLDivElement, Element>) => void) | undefined;
126
+ onBlurCapture?: ((event: import("react").FocusEvent<HTMLDivElement, Element>) => void) | undefined;
127
127
  onChange?: ((event: import("react").FormEvent<HTMLDivElement>) => void) | undefined;
128
128
  onChangeCapture?: ((event: import("react").FormEvent<HTMLDivElement>) => void) | undefined;
129
129
  onBeforeInput?: ((event: import("react").FormEvent<HTMLDivElement>) => void) | undefined;
@@ -167,4 +167,4 @@ function useTableScroll() {
167
167
  return [tableBody, scrollElement];
168
168
  }
169
169
 
170
- export default useTableScroll;
170
+ export { useTableScroll as default };
package/Tabs/Tab.js CHANGED
@@ -11,6 +11,7 @@ const Tab = forwardRef(function Tab(props, ref) {
11
11
  return (jsx("button", Object.assign({}, rest, { ref: ref, type: "button", "aria-disabled": disabled, className: cx(tabsClasses.tab, {
12
12
  [tabsClasses.tabActive]: active,
13
13
  }, className), disabled: disabled }, { children: children }), void 0));
14
- });
14
+ });
15
+ var Tab$1 = Tab;
15
16
 
16
- export default Tab;
17
+ export { Tab$1 as default };
package/Tabs/TabPane.js CHANGED
@@ -13,6 +13,7 @@ const TabPane = forwardRef(function TabPane(props, ref) {
13
13
  */
14
14
  tab, ...rest } = props;
15
15
  return (jsx("div", Object.assign({}, rest, { ref: ref, className: cx(tabsClasses.pane, className) }, { children: children }), void 0));
16
- });
16
+ });
17
+ var TabPane$1 = TabPane;
17
18
 
18
- export default TabPane;
19
+ export { TabPane$1 as default };
package/Tabs/Tabs.js CHANGED
@@ -44,6 +44,7 @@ const Tabs = forwardRef(function Tabs(props, ref) {
44
44
  return (jsxs("div", Object.assign({}, rest, { ref: ref, className: cx(tabsClasses.host, className) }, { children: [jsxs("div", Object.assign({ className: cx(tabsClasses.tabBar, tabBarClassName) }, { children: [jsxs("div", Object.assign({ className: tabsClasses.overflow }, { children: [isOverflowing && !isScrollToBegin && (jsx("button", Object.assign({ "aria-label": "scrollToLeft", className: tabsClasses.scrollBtn, onClick: () => scrollToLeft(), type: "button" }, { children: jsx(Icon, { icon: ChevronLeftIcon }, void 0) }), void 0)),
45
45
  jsx("div", Object.assign({ ref: tabsRef, className: tabsClasses.tabs }, { children: tabs }), void 0),
46
46
  isOverflowing && !isScrollToEnd && (jsx("button", Object.assign({ "aria-label": "scrollToRight", className: tabsClasses.scrollBtn, onClick: () => scrollToRight(), type: "button" }, { children: jsx(Icon, { icon: ChevronRightIcon }, void 0) }), void 0))] }), void 0), actions] }), void 0), pane] }), void 0));
47
- });
47
+ });
48
+ var Tabs$1 = Tabs;
48
49
 
49
- export default Tabs;
50
+ export { Tabs$1 as default };
@@ -55,4 +55,4 @@ function useTabsOverflow(tabsRef) {
55
55
  };
56
56
  }
57
57
 
58
- export default useTabsOverflow;
58
+ export { useTabsOverflow as default };
package/Tag/Tag.js CHANGED
@@ -18,6 +18,7 @@ const Tag = forwardRef(function Tag(props, ref) {
18
18
  onClose(event);
19
19
  }
20
20
  }, tabIndex: -1 }, void 0))] }), void 0));
21
- });
21
+ });
22
+ var Tag$1 = Tag;
22
23
 
23
- export default Tag;
24
+ export { Tag$1 as default };