@antscorp/antsomi-ui 1.6.8 → 1.7.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.
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { SliderRangeProps, SliderSingleProps } from 'antd/es/slider';
3
- export interface SliderProps extends SliderSingleProps {
3
+ export interface SliderProps {
4
+ defaultSliderTrack?: boolean;
4
5
  }
5
- export declare const SliderV2: React.FC<SliderProps | SliderRangeProps>;
6
+ export declare const SliderV2: React.FC<(SliderSingleProps & SliderProps) | (SliderRangeProps & SliderProps)>;
@@ -4,20 +4,18 @@ import React, { useState } from 'react';
4
4
  import { Slider as AntdSlider } from 'antd';
5
5
  // React.FC<SliderProps>
6
6
  export const SliderV2 = props => {
7
- const [value, setValue] = useState(0);
8
- // console.log('sliderRef:: ', sliderRef);
9
- // const min = props.min || 0;
10
- // const max = props.max || 100;
11
- const { min, max, onChange, styles, range } = props;
12
- if (min && max && min < 0 && max > 0 && !range) {
7
+ const { min, max, onChange, styles, range, value, defaultValue, marks, defaultSliderTrack } = props;
8
+ const [valueInternal, setValueInternal] = useState(defaultValue || min || 0);
9
+ if (min && max && min < 0 && max > 0 && !range && !defaultSliderTrack) {
13
10
  const sliderWidth = max - min;
14
- const leftTrackPosition = `${(Math.abs(value > 0 ? min : min - value) / sliderWidth) * 100}%`;
15
- const sliderTrackWidth = `${(Math.abs(value) / sliderWidth) * 100}%`;
16
- return (React.createElement(AntdSlider, Object.assign({ value: value, onChange: value => {
17
- setValue(value);
11
+ const calcValue = value || valueInternal;
12
+ const leftTrackPosition = `${(Math.abs(calcValue > 0 ? min : min - calcValue) / sliderWidth) * 100}%`;
13
+ const sliderTrackWidth = `${(Math.abs(calcValue) / sliderWidth) * 100}%`;
14
+ return (React.createElement(AntdSlider, Object.assign({ value: value || valueInternal, onChange: value => {
15
+ setValueInternal(value);
18
16
  if (onChange)
19
17
  onChange(value);
20
- }, styles: Object.assign({ track: Object.assign({ left: leftTrackPosition, width: sliderTrackWidth }, styles === null || styles === void 0 ? void 0 : styles.track) }, styles), marks: { 0: ' ' } }, props)));
18
+ }, styles: Object.assign({ track: Object.assign({ left: leftTrackPosition, width: sliderTrackWidth }, styles === null || styles === void 0 ? void 0 : styles.track) }, styles), marks: marks || { 0: ' ' } }, props)));
21
19
  }
22
20
  return React.createElement(AntdSlider, Object.assign({}, props));
23
21
  };
@@ -23,7 +23,6 @@ export { IconSelectionRenderer } from './IconSelection/components/Icon';
23
23
  export { AlignSetting } from './AlignSetting';
24
24
  export { EdgeSetting } from './EdgeSetting';
25
25
  export { ShareAccess, Constants as ShareAccessConstants, Utils as ShareAccessUtils, } from './ShareAccess';
26
- export { Drawer } from './Drawer';
27
26
  export { Collapse } from './Collapse';
28
27
  export { TreeSelect } from './TreeSelect';
29
28
  export { Card } from './Card';
@@ -53,6 +52,7 @@ export { CalendarSelection, CalendarSelectionConstants, CalendarSelectionUtils,
53
52
  export * from './EmptyData';
54
53
  export * from './PreviewModal';
55
54
  export * from './DrawerDetail';
55
+ export * from './Drawer';
56
56
  export * from './ThumbnailCard';
57
57
  export * from './ProcessLoading';
58
58
  export * from './Tree';
@@ -23,7 +23,6 @@ export { IconSelectionRenderer } from './IconSelection/components/Icon';
23
23
  export { AlignSetting } from './AlignSetting';
24
24
  export { EdgeSetting } from './EdgeSetting';
25
25
  export { ShareAccess, Constants as ShareAccessConstants, Utils as ShareAccessUtils, } from './ShareAccess';
26
- export { Drawer } from './Drawer';
27
26
  export { Collapse } from './Collapse';
28
27
  export { TreeSelect } from './TreeSelect';
29
28
  export { Card } from './Card';
@@ -53,6 +52,7 @@ export { CalendarSelection, CalendarSelectionConstants, CalendarSelectionUtils,
53
52
  export * from './EmptyData';
54
53
  export * from './PreviewModal';
55
54
  export * from './DrawerDetail';
55
+ export * from './Drawer';
56
56
  export * from './ThumbnailCard';
57
57
  export * from './ProcessLoading';
58
58
  export * from './Tree';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.6.8",
3
+ "version": "1.7.0",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",