@quen-ui/components 1.0.1 → 1.2.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 (114) hide show
  1. package/dist/Banner/Banner.cjs.js +96 -0
  2. package/dist/Banner/Banner.d.ts +4 -0
  3. package/dist/Banner/Banner.es.js +96 -0
  4. package/dist/Banner/index.d.ts +2 -0
  5. package/dist/Banner/styles.cjs.js +113 -0
  6. package/dist/Banner/styles.d.ts +12 -0
  7. package/dist/Banner/styles.es.js +113 -0
  8. package/dist/Banner/types.d.ts +40 -0
  9. package/dist/Button/styles.cjs.js +6 -10
  10. package/dist/Button/styles.es.js +6 -10
  11. package/dist/Calendar/Calendar.cjs.js +5 -3
  12. package/dist/Calendar/Calendar.es.js +5 -3
  13. package/dist/Calendar/styles.cjs.js +0 -1
  14. package/dist/Calendar/styles.es.js +0 -1
  15. package/dist/Card/Card.cjs.js +8 -4
  16. package/dist/Card/Card.d.ts +1 -1
  17. package/dist/Card/Card.es.js +8 -4
  18. package/dist/Card/styles.cjs.js +9 -3
  19. package/dist/Card/styles.d.ts +3 -1
  20. package/dist/Card/styles.es.js +9 -3
  21. package/dist/Card/types.d.ts +2 -0
  22. package/dist/Dropdown/Dropdown.cjs.js +47 -43
  23. package/dist/Dropdown/Dropdown.d.ts +1 -1
  24. package/dist/Dropdown/Dropdown.es.js +48 -44
  25. package/dist/Dropdown/DropdownItem.cjs.js +10 -13
  26. package/dist/Dropdown/DropdownItem.es.js +10 -13
  27. package/dist/Dropdown/DropdownList.cjs.js +0 -2
  28. package/dist/Dropdown/DropdownList.es.js +0 -2
  29. package/dist/Form/Form.cjs.js +1 -1
  30. package/dist/Form/Form.es.js +1 -1
  31. package/dist/Image/styles.cjs.js +3 -1
  32. package/dist/Image/styles.es.js +3 -1
  33. package/dist/InputBase/InputBase.cjs.js +55 -12
  34. package/dist/InputBase/InputBase.d.ts +1 -1
  35. package/dist/InputBase/InputBase.es.js +57 -14
  36. package/dist/InputBase/styles.cjs.js +44 -4
  37. package/dist/InputBase/styles.d.ts +7 -1
  38. package/dist/InputBase/styles.es.js +45 -5
  39. package/dist/InputBase/types.d.ts +5 -1
  40. package/dist/InputDate/styles.d.ts +1 -1
  41. package/dist/InputNumber/styles.d.ts +1 -1
  42. package/dist/Layout/Footer.cjs.js +9 -0
  43. package/dist/Layout/Footer.d.ts +1 -2
  44. package/dist/Layout/Footer.es.js +9 -0
  45. package/dist/Layout/Header.cjs.js +12 -4
  46. package/dist/Layout/Header.es.js +12 -4
  47. package/dist/Layout/Layout.cjs.js +8 -3
  48. package/dist/Layout/Layout.d.ts +1 -1
  49. package/dist/Layout/Layout.es.js +8 -3
  50. package/dist/Layout/Sidebar.cjs.js +2 -1
  51. package/dist/Layout/Sidebar.es.js +2 -1
  52. package/dist/Layout/styles.cjs.js +6 -4
  53. package/dist/Layout/styles.d.ts +2 -0
  54. package/dist/Layout/styles.es.js +6 -4
  55. package/dist/Layout/types.d.ts +6 -0
  56. package/dist/Menu/MenuItem.cjs.js +9 -1
  57. package/dist/Menu/MenuItem.es.js +9 -1
  58. package/dist/Menu/styles.cjs.js +3 -1
  59. package/dist/Menu/styles.es.js +3 -1
  60. package/dist/Menu/types.d.ts +4 -1
  61. package/dist/Modal/Modal.cjs.js +2 -2
  62. package/dist/Modal/Modal.es.js +2 -2
  63. package/dist/Modal/styles.cjs.js +3 -1
  64. package/dist/Modal/styles.es.js +3 -1
  65. package/dist/Select/Select.cjs.js +2 -5
  66. package/dist/Select/Select.es.js +2 -5
  67. package/dist/Select/helpers.d.ts +8 -0
  68. package/dist/Select/styles.d.ts +1 -1
  69. package/dist/Select/useSelect.d.ts +8 -0
  70. package/dist/Slider/Slider.cjs.js +122 -224
  71. package/dist/Slider/Slider.d.ts +1 -1
  72. package/dist/Slider/Slider.es.js +125 -227
  73. package/dist/Slider/styles.cjs.js +49 -32
  74. package/dist/Slider/styles.d.ts +1 -1
  75. package/dist/Slider/styles.es.js +49 -32
  76. package/dist/Slider/useSlider.cjs.js +194 -0
  77. package/dist/Slider/useSlider.d.ts +11 -0
  78. package/dist/Slider/useSlider.es.js +194 -0
  79. package/dist/Stepper/Step.cjs.js +114 -0
  80. package/dist/Stepper/Step.d.ts +2 -0
  81. package/dist/Stepper/Step.es.js +114 -0
  82. package/dist/Stepper/StepContent.cjs.js +10 -0
  83. package/dist/Stepper/StepContent.d.ts +4 -0
  84. package/dist/Stepper/StepContent.es.js +10 -0
  85. package/dist/Stepper/StepLabel.cjs.js +28 -0
  86. package/dist/Stepper/StepLabel.d.ts +2 -0
  87. package/dist/Stepper/StepLabel.es.js +28 -0
  88. package/dist/Stepper/Stepper.cjs.js +54 -0
  89. package/dist/Stepper/Stepper.d.ts +2 -0
  90. package/dist/Stepper/Stepper.es.js +54 -0
  91. package/dist/Stepper/StepperContext.cjs.js +13 -0
  92. package/dist/Stepper/StepperContext.d.ts +3 -0
  93. package/dist/Stepper/StepperContext.es.js +13 -0
  94. package/dist/Stepper/index.cjs.js +10 -0
  95. package/dist/Stepper/index.d.ts +12 -0
  96. package/dist/Stepper/index.es.js +11 -0
  97. package/dist/Stepper/styles.cjs.js +149 -0
  98. package/dist/Stepper/styles.d.ts +44 -0
  99. package/dist/Stepper/styles.es.js +149 -0
  100. package/dist/Stepper/types.d.ts +70 -0
  101. package/dist/TextField/TextField.cjs.js +4 -0
  102. package/dist/TextField/TextField.d.ts +1 -1
  103. package/dist/TextField/TextField.es.js +4 -0
  104. package/dist/TextField/styles.d.ts +1 -1
  105. package/dist/Textarea/styles.d.ts +1 -1
  106. package/dist/Tooltip/Tooltip.cjs.js +3 -1
  107. package/dist/Tooltip/Tooltip.es.js +4 -2
  108. package/dist/index.cjs.js +4 -0
  109. package/dist/index.d.ts +2 -0
  110. package/dist/index.es.js +4 -0
  111. package/dist/typography/Text/Text.cjs.js +2 -2
  112. package/dist/typography/Text/Text.es.js +2 -2
  113. package/dist/typography/Text/types.d.ts +1 -1
  114. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import Flex from "../Flex/Flex.es.js";
3
3
  const MenuItemStyled = styled.button.withConfig({
4
- shouldForwardProp: (prop) => !["disabled", "active", "hover"].includes(prop)
4
+ shouldForwardProp: (prop) => !["disabled", "active", "hover", "leftContent", "label"].includes(prop)
5
5
  }).attrs((props) => ({
6
6
  className: props.active ? "quen-ui__menu-item--active" : "quen-ui__menu-item"
7
7
  }))`
@@ -16,6 +16,7 @@ const MenuItemStyled = styled.button.withConfig({
16
16
  transition: background 0.2s ease;
17
17
  background: transparent;
18
18
  justify-content: flex-start;
19
+ text-decoration: none;
19
20
 
20
21
  color: ${({ theme, disabled }) => disabled ? theme.components.Menu.disabledColor : theme.components.Menu.color};
21
22
 
@@ -42,6 +43,7 @@ const MenuItemStyled = styled.button.withConfig({
42
43
 
43
44
  .quen-ui--menu__item_label {
44
45
  width: 100%;
46
+ text-align: left;
45
47
  }
46
48
 
47
49
  &:hover {
@@ -1,4 +1,4 @@
1
- import { default as React } from 'react';
1
+ import { default as React, JSX } from 'react';
2
2
  import { TQuenSize } from '../types/size';
3
3
  export interface IMenuDefaultItem {
4
4
  /** Unique item identifier */
@@ -15,6 +15,9 @@ export interface IMenuDefaultItem {
15
15
  disabled?: boolean;
16
16
  /** Custom CSS classes */
17
17
  className?: string;
18
+ /** Renders as custom element (e.g., "a" for links) */
19
+ as?: keyof JSX.IntrinsicElements | React.ElementType;
20
+ [key: string]: any;
18
21
  }
19
22
  export type TMenuPropGetItemKey<Item> = (item: Item) => string;
20
23
  export type TMenuPropGetItemIcon<Item> = (item: Item) => React.ReactNode;
@@ -25,7 +25,6 @@ const Modal = ({
25
25
  width,
26
26
  ...props
27
27
  }) => {
28
- console.log(open);
29
28
  const [state, toggle] = reactTransitionState.useTransitionState({
30
29
  timeout: 500,
31
30
  unmountOnExit: true,
@@ -51,11 +50,12 @@ const Modal = ({
51
50
  };
52
51
  }, []);
53
52
  React.useEffect(() => {
53
+ const overflow = document.body.style.overflow;
54
54
  if (state.isEnter) {
55
55
  document.body.style.overflow = "hidden";
56
56
  }
57
57
  return () => {
58
- document.body.style.overflow = "unset";
58
+ document.body.style.overflow = overflow;
59
59
  };
60
60
  }, [state]);
61
61
  if (state.isEnter && container) {
@@ -24,7 +24,6 @@ const Modal = ({
24
24
  width,
25
25
  ...props
26
26
  }) => {
27
- console.log(open);
28
27
  const [state, toggle] = useTransitionState({
29
28
  timeout: 500,
30
29
  unmountOnExit: true,
@@ -50,11 +49,12 @@ const Modal = ({
50
49
  };
51
50
  }, []);
52
51
  useEffect(() => {
52
+ const overflow = document.body.style.overflow;
53
53
  if (state.isEnter) {
54
54
  document.body.style.overflow = "hidden";
55
55
  }
56
56
  return () => {
57
- document.body.style.overflow = "unset";
57
+ document.body.style.overflow = overflow;
58
58
  };
59
59
  }, [state]);
60
60
  if (state.isEnter && container) {
@@ -58,7 +58,9 @@ const ModalStyled = styled.div.withConfig({
58
58
  }
59
59
  `};
60
60
  `;
61
- const ModalContentStyled = styled.div`
61
+ const ModalContentStyled = styled.div.withConfig({
62
+ shouldForwardProp: (prop) => !["scrollable"].includes(prop)
63
+ })`
62
64
  ${({ scrollable }) => scrollable && styled.css`
63
65
  overflow-y: auto;
64
66
  max-height: 60vh;
@@ -56,7 +56,9 @@ const ModalStyled = styled.div.withConfig({
56
56
  }
57
57
  `};
58
58
  `;
59
- const ModalContentStyled = styled.div`
59
+ const ModalContentStyled = styled.div.withConfig({
60
+ shouldForwardProp: (prop) => !["scrollable"].includes(prop)
61
+ })`
60
62
  ${({ scrollable }) => scrollable && css`
61
63
  overflow-y: auto;
62
64
  max-height: 60vh;
@@ -8,7 +8,6 @@ const useSelect = require("./useSelect.cjs.js");
8
8
  const helpers = require("./helpers.cjs.js");
9
9
  const Tag = require("../Tag/Tag.cjs.js");
10
10
  const iconArrowBottom = require("../assets/icon-arrow-bottom.svg.cjs.js");
11
- const Flex = require("../Flex/Flex.cjs.js");
12
11
  const iconClose = require("../assets/icon-close.svg.cjs.js");
13
12
  const SelectComponent = (props) => {
14
13
  const {
@@ -62,6 +61,7 @@ const SelectComponent = (props) => {
62
61
  error,
63
62
  size,
64
63
  required,
64
+ rightContent,
65
65
  ...otherProps,
66
66
  children: [
67
67
  /* @__PURE__ */ jsxRuntime.jsx(styles.SelectDropDownStyles, { zIndex }),
@@ -80,10 +80,7 @@ const SelectComponent = (props) => {
80
80
  menuItemSelectedIcon: null,
81
81
  loading,
82
82
  prefix: leftContent,
83
- suffixIcon: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { gap: 4, align: "center", children: [
84
- rightContent,
85
- /* @__PURE__ */ jsxRuntime.jsx(iconArrowBottom, { className: "icon-arrow" })
86
- ] }),
83
+ suffixIcon: /* @__PURE__ */ jsxRuntime.jsx(iconArrowBottom, { className: "icon-arrow" }),
87
84
  labelRender: (props2) => /* @__PURE__ */ jsxRuntime.jsx(Text, { size, children: props2.label }),
88
85
  open,
89
86
  disabled,
@@ -7,7 +7,6 @@ import { useSelect } from "./useSelect.es.js";
7
7
  import { withDefaultGetters } from "./helpers.es.js";
8
8
  import Tag from "../Tag/Tag.es.js";
9
9
  import SvgIconArrowBottom from "../assets/icon-arrow-bottom.svg.es.js";
10
- import Flex from "../Flex/Flex.es.js";
11
10
  import SvgIconClose from "../assets/icon-close.svg.es.js";
12
11
  const SelectComponent = (props) => {
13
12
  const {
@@ -61,6 +60,7 @@ const SelectComponent = (props) => {
61
60
  error,
62
61
  size,
63
62
  required,
63
+ rightContent,
64
64
  ...otherProps,
65
65
  children: [
66
66
  /* @__PURE__ */ jsx(SelectDropDownStyles, { zIndex }),
@@ -79,10 +79,7 @@ const SelectComponent = (props) => {
79
79
  menuItemSelectedIcon: null,
80
80
  loading,
81
81
  prefix: leftContent,
82
- suffixIcon: /* @__PURE__ */ jsxs(Flex, { gap: 4, align: "center", children: [
83
- rightContent,
84
- /* @__PURE__ */ jsx(SvgIconArrowBottom, { className: "icon-arrow" })
85
- ] }),
82
+ suffixIcon: /* @__PURE__ */ jsx(SvgIconArrowBottom, { className: "icon-arrow" }),
86
83
  labelRender: (props2) => /* @__PURE__ */ jsx(Text, { size, children: props2.label }),
87
84
  open,
88
85
  disabled,
@@ -14,7 +14,9 @@ export declare function withDefaultGetters<ITEM>(props: TSelectProps<ITEM>): {
14
14
  required?: boolean;
15
15
  error?: string | boolean;
16
16
  leftContent?: import('react').ReactNode;
17
+ leftContentVariant?: "icon" | "text" | "addon";
17
18
  rightContent?: import('react').ReactNode;
19
+ rightContentVariant?: "icon" | "text" | "addon";
18
20
  id?: string;
19
21
  className?: string;
20
22
  style?: import('react').CSSProperties;
@@ -48,7 +50,9 @@ export declare function withDefaultGetters<ITEM>(props: TSelectProps<ITEM>): {
48
50
  required?: boolean;
49
51
  error?: string | boolean;
50
52
  leftContent?: import('react').ReactNode;
53
+ leftContentVariant?: "icon" | "text" | "addon";
51
54
  rightContent?: import('react').ReactNode;
55
+ rightContentVariant?: "icon" | "text" | "addon";
52
56
  id?: string;
53
57
  className?: string;
54
58
  style?: import('react').CSSProperties;
@@ -82,7 +86,9 @@ export declare function withDefaultGetters<ITEM>(props: TSelectProps<ITEM>): {
82
86
  required?: boolean;
83
87
  error?: string | boolean;
84
88
  leftContent?: import('react').ReactNode;
89
+ leftContentVariant?: "icon" | "text" | "addon";
85
90
  rightContent?: import('react').ReactNode;
91
+ rightContentVariant?: "icon" | "text" | "addon";
86
92
  id?: string;
87
93
  className?: string;
88
94
  style?: import('react').CSSProperties;
@@ -116,7 +122,9 @@ export declare function withDefaultGetters<ITEM>(props: TSelectProps<ITEM>): {
116
122
  required?: boolean;
117
123
  error?: string | boolean;
118
124
  leftContent?: import('react').ReactNode;
125
+ leftContentVariant?: "icon" | "text" | "addon";
119
126
  rightContent?: import('react').ReactNode;
127
+ rightContentVariant?: "icon" | "text" | "addon";
120
128
  id?: string;
121
129
  className?: string;
122
130
  style?: import('react').CSSProperties;
@@ -2,7 +2,7 @@ export declare const SelectWrapper: import('styled-components/dist/types').IStyl
2
2
  children?: import('react').ReactNode | undefined;
3
3
  }, {
4
4
  zIndex?: number;
5
- }>> & string & Omit<({ label, className, size, id, required, style, error, disabled, children, leftContent, rightContent, ...props }: import('react').PropsWithChildren<import('../InputBase').IInputBaseProps>) => import("react/jsx-runtime").JSX.Element, keyof import('react').Component<any, {}, any>>;
5
+ }>> & string & Omit<({ label, className, size, id, required, style, error, disabled, children, leftContent, rightContent, leftContentVariant, rightContentVariant, ...props }: import('react').PropsWithChildren<import('../InputBase').IInputBaseProps>) => import("react/jsx-runtime").JSX.Element, keyof import('react').Component<any, {}, any>>;
6
6
  export declare const SelectDropDownStyles: import('react').NamedExoticComponent<import('styled-components').ExecutionProps & {
7
7
  zIndex?: number;
8
8
  }>;
@@ -14,7 +14,9 @@ export declare function useSelect<ITEM>(props: TSelectProps<ITEM> & Required<Pic
14
14
  required?: boolean;
15
15
  error?: string | boolean;
16
16
  leftContent?: import('react').ReactNode;
17
+ leftContentVariant?: "icon" | "text" | "addon";
17
18
  rightContent?: import('react').ReactNode;
19
+ rightContentVariant?: "icon" | "text" | "addon";
18
20
  id?: string;
19
21
  className?: string;
20
22
  style?: import('react').CSSProperties;
@@ -51,7 +53,9 @@ export declare function useSelect<ITEM>(props: TSelectProps<ITEM> & Required<Pic
51
53
  required?: boolean;
52
54
  error?: string | boolean;
53
55
  leftContent?: import('react').ReactNode;
56
+ leftContentVariant?: "icon" | "text" | "addon";
54
57
  rightContent?: import('react').ReactNode;
58
+ rightContentVariant?: "icon" | "text" | "addon";
55
59
  id?: string;
56
60
  className?: string;
57
61
  style?: import('react').CSSProperties;
@@ -88,7 +92,9 @@ export declare function useSelect<ITEM>(props: TSelectProps<ITEM> & Required<Pic
88
92
  required?: boolean;
89
93
  error?: string | boolean;
90
94
  leftContent?: import('react').ReactNode;
95
+ leftContentVariant?: "icon" | "text" | "addon";
91
96
  rightContent?: import('react').ReactNode;
97
+ rightContentVariant?: "icon" | "text" | "addon";
92
98
  id?: string;
93
99
  className?: string;
94
100
  style?: import('react').CSSProperties;
@@ -125,7 +131,9 @@ export declare function useSelect<ITEM>(props: TSelectProps<ITEM> & Required<Pic
125
131
  required?: boolean;
126
132
  error?: string | boolean;
127
133
  leftContent?: import('react').ReactNode;
134
+ leftContentVariant?: "icon" | "text" | "addon";
128
135
  rightContent?: import('react').ReactNode;
136
+ rightContentVariant?: "icon" | "text" | "addon";
129
137
  id?: string;
130
138
  className?: string;
131
139
  style?: import('react').CSSProperties;
@@ -3,271 +3,169 @@ const jsxRuntime = require("react/jsx-runtime");
3
3
  const React = require("react");
4
4
  const styles = require("./styles.cjs.js");
5
5
  const helpers = require("@quen-ui/helpers");
6
+ const useSlider = require("./useSlider.cjs.js");
6
7
  const Slider = ({
7
- value = 0,
8
8
  min = 0,
9
9
  max = 100,
10
10
  step = 1,
11
- onChange,
12
- showTooltip = true,
13
- range,
11
+ range = false,
14
12
  orientation = "horizontal",
15
13
  marks = [],
16
- draggableTrack,
14
+ disabled = false,
15
+ showTooltip = true,
16
+ draggableTrack = false,
17
+ color = "violet",
17
18
  tooltip,
18
19
  style,
19
20
  className,
20
- disabled,
21
- color = "violet"
21
+ value,
22
+ onChange
22
23
  }) => {
23
- const trackRef = React.useRef(null);
24
- const draggableRef = React.useRef(false);
25
- const initialValue = (_value) => {
26
- if (!range) {
27
- return Array.isArray(_value) ? _value : [_value ?? min, _value ?? min];
28
- }
29
- return Array.isArray(_value) ? _value : [min, max];
30
- };
31
- const [startEndValues, setStartEndValues] = React.useState(
32
- initialValue(value)
33
- );
34
- const [currentHandle, setCurrentHandle] = React.useState(
35
- null
36
- );
37
- const [isMouseDown, setIsMouseDown] = React.useState(false);
38
- React.useEffect(() => {
39
- setStartEndValues(initialValue(value));
40
- }, [value]);
41
- const clamp = (val) => Math.min(max, Math.max(min, val));
42
- const snap = (raw) => {
43
- return clamp(Math.round(raw / step) * step);
44
- };
45
- const percentOf = (v) => (v - min) / (max - min) * 100;
46
- const updateValue = React.useCallback(
47
- (newVal) => {
48
- if (newVal[0] !== startEndValues[0] || newVal[1] !== startEndValues[1] || newVal[0] == 0 && newVal[1] == 0) {
49
- setStartEndValues(newVal);
50
- onChange?.(range ? newVal : newVal[1]);
51
- }
24
+ const {
25
+ values,
26
+ trackRef,
27
+ percentStart,
28
+ percentEnd,
29
+ onPointerDownThumb,
30
+ onPointerDownTrack,
31
+ onKeyDown,
32
+ isDragging
33
+ } = useSlider.useSlider({
34
+ value,
35
+ min,
36
+ max,
37
+ step,
38
+ onChange,
39
+ range,
40
+ disabled,
41
+ orientation,
42
+ draggableTrack
43
+ });
44
+ const [isActive, setIsActive] = React.useState(false);
45
+ const renderThumb = React.useCallback(
46
+ (target, currentValue, percent) => {
47
+ const valText = `${target === "start" ? "From" : "To"} ${currentValue}`;
48
+ const isVert = orientation === "vertical";
49
+ return /* @__PURE__ */ jsxRuntime.jsxs(
50
+ "div",
51
+ {
52
+ style: {
53
+ position: "absolute",
54
+ zIndex: 2,
55
+ overflow: "visible",
56
+ [isVert ? "top" : "left"]: isVert ? `${100 - percent}%` : `${percent}%`,
57
+ [isVert ? "left" : "top"]: "50%",
58
+ transform: "translate(-50%, -50%)"
59
+ },
60
+ children: [
61
+ /* @__PURE__ */ jsxRuntime.jsx(
62
+ styles.SliderTooltipStyled,
63
+ {
64
+ isVertical: isVert,
65
+ open: isActive,
66
+ show: showTooltip,
67
+ text: currentValue,
68
+ position: isVert ? "right" : "top",
69
+ value: percent,
70
+ ...tooltip,
71
+ classNameContent: helpers.cnMerge(
72
+ "quen-ui__slider__tooltip__content",
73
+ tooltip?.classNameContent
74
+ ),
75
+ children: null
76
+ }
77
+ ),
78
+ /* @__PURE__ */ jsxRuntime.jsx(
79
+ styles.SliderThumbStyled,
80
+ {
81
+ role: "slider",
82
+ tabIndex: disabled ? -1 : 0,
83
+ "aria-disabled": disabled,
84
+ "aria-orientation": orientation,
85
+ "aria-valuemin": min,
86
+ "aria-valuemax": max,
87
+ "aria-valuenow": currentValue,
88
+ "aria-valuetext": valText,
89
+ "aria-label": range ? valText : "Slider value",
90
+ disabled,
91
+ color,
92
+ isVertical: isVert,
93
+ onPointerDown: (e) => {
94
+ setIsActive(true);
95
+ onPointerDownThumb(target, e);
96
+ },
97
+ onPointerUp: () => setIsActive(false),
98
+ onMouseEnter: () => setIsActive(true),
99
+ onMouseLeave: () => !isDragging && setIsActive(false),
100
+ onFocus: () => setIsActive(true),
101
+ onBlur: () => !isDragging && setIsActive(false),
102
+ onKeyDown: (e) => onKeyDown(target, e)
103
+ }
104
+ )
105
+ ]
106
+ },
107
+ target
108
+ );
52
109
  },
53
- [range, onChange]
110
+ [
111
+ orientation,
112
+ showTooltip,
113
+ tooltip,
114
+ disabled,
115
+ min,
116
+ max,
117
+ color,
118
+ range,
119
+ isDragging,
120
+ isActive,
121
+ onPointerDownThumb,
122
+ onKeyDown
123
+ ]
54
124
  );
55
- const setByValue = (raw, target) => {
56
- const snapped = snap(raw);
57
- let next = [0, 0];
58
- if (target === "end") {
59
- next = [startEndValues[0], snapped];
60
- } else if (target === "start") {
61
- next = [snapped, startEndValues[1]];
62
- } else if (!range) {
63
- next = [snapped, snapped];
64
- } else if (range) {
65
- const distanceToStart = Math.abs(snapped - startEndValues[0]);
66
- const distanceToEnd = Math.abs(snapped - startEndValues[1]);
67
- next = distanceToStart <= distanceToEnd ? [snapped, startEndValues[1]] : [startEndValues[0], snapped];
68
- }
69
- if (next[0] > next[1]) {
70
- next = [next[1], next[0]];
71
- }
72
- updateValue(next);
73
- };
74
- const handleTrackClick = (e) => {
75
- if (!trackRef.current || draggableRef.current) return;
76
- const rect = trackRef.current.getBoundingClientRect();
77
- const startClient = "touches" in e ? e.touches[0] : e;
78
- const ratio = orientation === "vertical" ? 1 - (startClient.clientY - rect.top) / rect.height : (startClient.clientX - rect.left) / rect.width;
79
- const raw = min + ratio * (max - min);
80
- setByValue(raw);
81
- };
82
- const handleMove = (e, target) => {
83
- if (!trackRef.current) return;
84
- const rect = trackRef.current.getBoundingClientRect();
85
- const client = "touches" in e ? e.touches[0] : e;
86
- let ratio = orientation === "vertical" ? 1 - (client.clientY - rect.top) / rect.height : (client.clientX - rect.left) / rect.width;
87
- ratio = Math.min(1, Math.max(0, ratio));
88
- const rawValue = min + ratio * (max - min);
89
- setByValue(rawValue, target);
90
- };
91
- const bindEvents = (target) => ({
92
- onMouseDown: (e) => {
93
- e.preventDefault();
94
- setCurrentHandle(target);
95
- setIsMouseDown(true);
96
- const move = (ev) => handleMove(ev, target);
97
- const up = () => {
98
- setCurrentHandle(null);
99
- setIsMouseDown(false);
100
- document.removeEventListener("mousemove", move);
101
- document.removeEventListener("mouseup", up, { capture: true });
102
- };
103
- document.addEventListener("mousemove", move);
104
- document.addEventListener("mouseup", up, { capture: true });
105
- },
106
- onTouchStart: () => {
107
- setCurrentHandle(target);
108
- setIsMouseDown(true);
109
- const move = (ev) => handleMove(ev, target);
110
- const up = () => {
111
- setCurrentHandle(null);
112
- setIsMouseDown(false);
113
- document.removeEventListener("touchmove", move);
114
- document.removeEventListener("touchend", up);
115
- };
116
- document.addEventListener("touchmove", move);
117
- document.addEventListener("touchend", up);
118
- },
119
- onMouseMove: () => {
120
- setCurrentHandle(target);
121
- },
122
- onMouseLeave: () => {
123
- if (!isMouseDown) {
124
- setCurrentHandle(null);
125
- }
126
- }
127
- });
128
- const startDragWholeRange = (e) => {
129
- if (!draggableTrack || !range || !trackRef.current) {
130
- handleTrackClick(e);
131
- } else {
132
- const rect = trackRef.current.getBoundingClientRect();
133
- const startClient = "touches" in e ? e.touches[0] : e;
134
- const startRatio = orientation === "vertical" ? 1 - (startClient.clientY - rect.top) / rect.height : (startClient.clientX - rect.left) / rect.width;
135
- const startValue = min + startRatio * (max - min);
136
- const rangeSize = startEndValues[1] - startEndValues[0];
137
- const offsetInsideRange = startValue - startEndValues[0];
138
- const move = (ev) => {
139
- const client = "touches" in ev ? ev.touches[0] : ev;
140
- let ratio = orientation === "vertical" ? 1 - (client.clientY - rect.top) / rect.height : (client.clientX - rect.left) / rect.width;
141
- ratio = Math.min(1, Math.max(0, ratio));
142
- const rawValue = min + ratio * (max - min);
143
- let newStart = rawValue - offsetInsideRange;
144
- let newEnd = newStart + rangeSize;
145
- if (newStart < min) {
146
- newStart = min;
147
- newEnd = min + rangeSize;
148
- }
149
- if (newEnd > max) {
150
- newStart = max - rangeSize;
151
- }
152
- const snappedStart = snap(newStart);
153
- const snappedEnd = snap(snappedStart + rangeSize);
154
- const next = [snappedStart, snappedEnd];
155
- updateValue(next);
156
- };
157
- const stop = () => {
158
- document.removeEventListener("mousemove", move);
159
- document.removeEventListener("mouseup", stop);
160
- document.removeEventListener("touchmove", move);
161
- document.removeEventListener("touchend", stop);
162
- setTimeout(() => {
163
- draggableRef.current = false;
164
- }, 500);
165
- };
166
- document.addEventListener("mousemove", move);
167
- document.addEventListener("mouseup", stop);
168
- document.addEventListener("touchmove", move);
169
- document.addEventListener("touchend", stop);
170
- }
171
- };
172
125
  return /* @__PURE__ */ jsxRuntime.jsxs(
173
126
  styles.SliderContainer,
174
127
  {
175
128
  disabled,
176
129
  style,
177
130
  className,
178
- role: "slider",
179
- "aria-label": "slider",
180
- "aria-orientation": orientation,
181
- "aria-disabled": disabled,
182
- "aria-valuemax": max,
183
- "aria-valuemin": min,
184
- "aria-valuenow": startEndValues[0],
131
+ role: "group",
132
+ "aria-label": "Slider",
185
133
  children: [
186
134
  /* @__PURE__ */ jsxRuntime.jsx(
187
135
  styles.SliderTrackStyled,
188
136
  {
189
- "data-testid": "slider-track",
190
- disabled,
191
137
  ref: trackRef,
138
+ disabled,
192
139
  isVertical: orientation === "vertical",
193
- onClick: handleTrackClick
140
+ onPointerDown: onPointerDownTrack
194
141
  }
195
142
  ),
196
143
  /* @__PURE__ */ jsxRuntime.jsx(
197
144
  styles.SliderProgressStyled,
198
145
  {
199
146
  isRange: range,
200
- range: [percentOf(startEndValues[0]), percentOf(startEndValues[1])],
201
- "data-testid": "slider-progress",
147
+ range: [percentStart, percentEnd],
202
148
  disabled,
203
149
  color,
204
- onMouseDown: startDragWholeRange,
205
- onTouchStart: startDragWholeRange,
206
150
  isVertical: orientation === "vertical"
207
151
  }
208
152
  ),
209
- range && /* @__PURE__ */ jsxRuntime.jsx(
210
- styles.SliderTooltipStyled,
211
- {
212
- isVertical: orientation === "vertical",
213
- open: currentHandle === "start",
214
- show: showTooltip,
215
- text: startEndValues[0],
216
- position: orientation === "vertical" ? "right" : "top",
217
- value: percentOf(startEndValues[0]),
218
- ...tooltip,
219
- classNameContent: helpers.cnMerge(
220
- "quen-ui__slider__tooltip__content",
221
- tooltip?.classNameContent
222
- ),
223
- children: /* @__PURE__ */ jsxRuntime.jsx(
224
- styles.SliderThumbStyled,
225
- {
226
- disabled,
227
- color,
228
- isVertical: orientation === "vertical",
229
- ...bindEvents("start")
230
- }
231
- )
232
- }
233
- ),
234
- /* @__PURE__ */ jsxRuntime.jsx(
235
- styles.SliderTooltipStyled,
236
- {
237
- isVertical: orientation === "vertical",
238
- open: currentHandle === "end",
239
- show: showTooltip,
240
- text: startEndValues[1],
241
- position: orientation === "vertical" ? "right" : "top",
242
- value: percentOf(startEndValues[1]),
243
- ...tooltip,
244
- classNameContent: helpers.cnMerge(
245
- "quen-ui__slider__tooltip__content",
246
- tooltip?.classNameContent
247
- ),
248
- children: /* @__PURE__ */ jsxRuntime.jsx(
249
- styles.SliderThumbStyled,
250
- {
251
- disabled,
252
- color,
253
- isVertical: orientation === "vertical",
254
- ...bindEvents("end")
255
- }
256
- )
257
- }
258
- ),
153
+ range ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
154
+ renderThumb("start", values[0], percentStart),
155
+ renderThumb("end", values[1], percentEnd)
156
+ ] }) : renderThumb("end", values[1], percentEnd),
259
157
  /* @__PURE__ */ jsxRuntime.jsx(styles.SliderMarksWrapperStyled, { isVertical: orientation === "vertical", children: marks.map((m) => /* @__PURE__ */ jsxRuntime.jsxs(
260
158
  styles.SliderMarkStyled,
261
159
  {
262
160
  className: m.className,
263
- onClick: (e) => {
264
- console.log(e);
161
+ style: m.style,
162
+ isVertical: orientation === "vertical",
163
+ value: (m.value - min) / (max - min) * 100,
164
+ onPointerDown: (e) => {
165
+ if (disabled) return;
265
166
  e.stopPropagation();
266
- setByValue(m.value);
167
+ onPointerDownTrack(e);
267
168
  },
268
- isVertical: orientation === "vertical",
269
- value: percentOf(m.value),
270
- style: m.style,
271
169
  children: [
272
170
  /* @__PURE__ */ jsxRuntime.jsx(styles.SliderDotStyled, {}),
273
171
  m.label && /* @__PURE__ */ jsxRuntime.jsx(styles.SliderLabelStyled, { isVertical: orientation === "vertical", children: m.label })
@@ -1,3 +1,3 @@
1
1
  import { ISliderProps } from './types';
2
- declare const Slider: ({ value, min, max, step, onChange, showTooltip, range, orientation, marks, draggableTrack, tooltip, style, className, disabled, color }: ISliderProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const Slider: ({ min, max, step, range, orientation, marks, disabled, showTooltip, draggableTrack, color, tooltip, style, className, value, onChange }: ISliderProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default Slider;