draft-components 2.10.0 → 2.10.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.
@@ -1995,6 +1995,7 @@
1995
1995
  /* Label properties */
1996
1996
  --dc-slider-label-gap: 4px;
1997
1997
  --dc-slider-label-height: 24px;
1998
+ --dc-slider-label-max-width: 80px;
1998
1999
  --dc-slider-label-padding-x: 0.5em;
1999
2000
  --dc-slider-label-radius: 6px;
2000
2001
  --dc-slider-label-border: 1px solid var(--dc-white);
@@ -2038,7 +2039,7 @@
2038
2039
  min-height: var(--dc-slider-thumb-height);
2039
2040
  }
2040
2041
 
2041
- .dc-slider__body_has_label {
2042
+ .dc-slider__body_has_labels {
2042
2043
  margin-top: calc(
2043
2044
  var(--dc-slider-label-height) +
2044
2045
  var(--dc-slider-label-gap)
@@ -2151,7 +2152,7 @@
2151
2152
  box-shadow: var(--dc-slider-thumb-shadow);
2152
2153
  }
2153
2154
 
2154
- .dc-slider__input-label {
2155
+ .dc-slider__label {
2155
2156
  font: var(--dc-text-xs);
2156
2157
  font-variant-numeric: tabular-nums;
2157
2158
  color: var(--dc-slider-label-text-color);
@@ -2169,6 +2170,7 @@
2169
2170
  box-sizing: border-box;
2170
2171
  height: var(--dc-slider-label-height);
2171
2172
  min-width: var(--dc-slider-label-height);
2173
+ max-width: var(--dc-slider-label-max-width);
2172
2174
  padding: 0 var(--dc-slider-label-padding-x);
2173
2175
  transform: translateX(-50%);
2174
2176
  border: var(--dc-slider-label-border);
@@ -2176,8 +2178,14 @@
2176
2178
  background: var(--dc-slider-label-bg);
2177
2179
  }
2178
2180
 
2181
+ .dc-slider__label-text {
2182
+ overflow: hidden;
2183
+ white-space: nowrap;
2184
+ text-overflow: ellipsis;
2185
+ }
2186
+
2179
2187
  .dc-slider__input_active,
2180
- .dc-slider__input-label_active {
2188
+ .dc-slider__label_active {
2181
2189
  z-index: 1;
2182
2190
  }
2183
2191
 
@@ -1,7 +1,7 @@
1
- import { formatNumber, formatPercent } from '../../lib/index.js';
1
+ import { formatNumber } from '../../lib/index.js';
2
2
  export function getOffsetRelativeToThumb(position) {
3
3
  return 'calc(' +
4
- `${formatPercent(position)} - ` +
4
+ `${Math.floor(position * 100)}% - ` +
5
5
  `var(--dc-slider-thumb-width) * ${formatNumber(position / 2)} + ` +
6
6
  `var(--dc-slider-thumb-width) * ${formatNumber((1 - position) / 2)}` +
7
7
  ')';
@@ -11,7 +11,7 @@ export type RangeSliderProps = {
11
11
  className?: string;
12
12
  disabled?: boolean;
13
13
  fullWidth?: boolean;
14
- showLabel?: boolean;
14
+ showLabels?: boolean;
15
15
  iconLeft?: ReactNode;
16
16
  iconRight?: ReactNode;
17
17
  tickMarks?: SliderTickMark[];
@@ -27,4 +27,4 @@ export type RangeSliderProps = {
27
27
  onChange: (value: RangeSliderValue) => void;
28
28
  formatValue?: (value: number) => ReactNode;
29
29
  };
30
- export declare function RangeSlider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabel, iconLeft, iconRight, tickMarks, step, min, minThumbName, minThumbAriaLabel, max, maxThumbName, maxThumbAriaLabel, name, value: range, onChange, formatValue, }: RangeSliderProps): import("react/jsx-runtime").JSX.Element;
30
+ export declare function RangeSlider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabels, iconLeft, iconRight, tickMarks, step, min, minThumbName, minThumbAriaLabel, max, maxThumbName, maxThumbAriaLabel, name, value: range, onChange, formatValue, }: RangeSliderProps): import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,7 @@ import { SliderThumb } from './slider-thumb.js';
5
5
  import { classNames } from '../../lib/index.js';
6
6
  import { SliderTickMarks } from './slider-tick-marks.js';
7
7
  const numberFormatter = new Intl.NumberFormat();
8
- export function RangeSlider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabel = true, iconLeft, iconRight, tickMarks, step = 1, min = 0, minThumbName, minThumbAriaLabel, max = 100, maxThumbName, maxThumbAriaLabel, name, value: range, onChange, formatValue = numberFormatter.format, }) {
8
+ export function RangeSlider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabels, iconLeft, iconRight, tickMarks, step = 1, min = 0, minThumbName, minThumbAriaLabel, max = 100, maxThumbName, maxThumbAriaLabel, name, value: range, onChange, formatValue = numberFormatter.format, }) {
9
9
  const defaultId = useId();
10
10
  const [focusedThumb, setFocusedThumb] = useState('min');
11
11
  const positionMin = range.min / (max - min);
@@ -41,7 +41,7 @@ export function RangeSlider({ 'aria-label': ariaLabel, id, style, className, dis
41
41
  'dc-slider_full-width': fullWidth,
42
42
  }), name: name, disabled: disabled, "aria-label": ariaLabel, children: _jsxs("div", { className: classNames({
43
43
  'dc-slider__body': true,
44
- 'dc-slider__body_has_label': showLabel,
44
+ 'dc-slider__body_has_labels': showLabels,
45
45
  'dc-slider__body_has_tick-marks': tickMarksElement,
46
- }), children: [iconLeft, _jsxs(SliderTrack, { positionStart: positionMin, positionEnd: positionMax, children: [tickMarksElement, _jsx(SliderThumb, { name: minThumbName || (name && `${name}[min]`), active: focusedThumb === 'min', "aria-label": minThumbAriaLabel, showLabel: showLabel, dataListId: dataListId, position: positionMin, step: step, min: min, max: max, value: range.min, formatValue: formatValue, onChange: handleChangeMin, onFocus: handleFocusMinThumb }), _jsx(SliderThumb, { name: maxThumbName || (name && `${name}[max]`), active: focusedThumb === 'max', "aria-label": maxThumbAriaLabel, showLabel: showLabel, dataListId: dataListId, position: positionMax, step: step, min: min, max: max, value: range.max, formatValue: formatValue, onChange: handleChangeMax, onFocus: handleFocusMaxThumb })] }), iconRight] }) }));
46
+ }), children: [iconLeft, _jsxs(SliderTrack, { positionStart: positionMin, positionEnd: positionMax, children: [tickMarksElement, _jsx(SliderThumb, { name: minThumbName || (name && `${name}[min]`), active: focusedThumb === 'min', "aria-label": minThumbAriaLabel, showLabel: showLabels, dataListId: dataListId, position: positionMin, step: step, min: min, max: max, value: range.min, formatValue: formatValue, onChange: handleChangeMin, onFocus: handleFocusMinThumb }), _jsx(SliderThumb, { name: maxThumbName || (name && `${name}[max]`), active: focusedThumb === 'max', "aria-label": maxThumbAriaLabel, showLabel: showLabels, dataListId: dataListId, position: positionMax, step: step, min: min, max: max, value: range.max, formatValue: formatValue, onChange: handleChangeMax, onFocus: handleFocusMaxThumb })] }), iconRight] }) }));
47
47
  }
@@ -9,7 +9,7 @@ export function SliderThumb({ 'aria-label': ariaLabel, id, name, active, disable
9
9
  'dc-slider__input': true,
10
10
  'dc-slider__input_active': active,
11
11
  }), type: "range", name: name, "aria-label": ariaLabel, list: dataListId, step: step, min: min, max: max, disabled: disabled, value: value, onChange: handleChange, onFocus: onFocus, onBlur: onBlur }), showLabel && (_jsx("output", { style: { left: getOffsetRelativeToThumb(position) }, className: classNames({
12
- 'dc-slider__input-label': true,
13
- 'dc-slider__input-label_active': active,
14
- }), htmlFor: id, children: formatValue(value) }))] }));
12
+ 'dc-slider__label': true,
13
+ 'dc-slider__label_active': active,
14
+ }), htmlFor: id, children: _jsx("span", { className: "dc-slider__label-text", children: formatValue(value) }) }))] }));
15
15
  }
@@ -1,8 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { formatPercent } from '../../lib/index.js';
3
2
  export function SliderTrack({ positionStart, positionEnd, children, }) {
4
- const start = formatPercent(positionStart);
5
- const end = formatPercent(positionEnd);
3
+ const start = `${Math.floor(positionStart * 100)}%`;
4
+ const end = `${Math.floor(positionEnd * 100)}%`;
6
5
  const background = 'linear-gradient(' +
7
6
  'to right, ' +
8
7
  `var(--dc-slider-track-bg) ${start}, ` +
@@ -5,7 +5,7 @@ import { SliderThumb } from './slider-thumb.js';
5
5
  import { classNames } from '../../lib/index.js';
6
6
  import { SliderTickMarks } from './slider-tick-marks.js';
7
7
  const numberFormatter = new Intl.NumberFormat();
8
- export function Slider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabel = true, iconLeft, iconRight, tickMarks, step = 1, min = 0, max = 100, name, value, onChange, formatValue = numberFormatter.format, }) {
8
+ export function Slider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabel, iconLeft, iconRight, tickMarks, step = 1, min = 0, max = 100, name, value, onChange, formatValue = numberFormatter.format, }) {
9
9
  const defaultId = useId();
10
10
  const thumbId = id || `${defaultId}slider-thumb`;
11
11
  const position = value / (max - min);
@@ -21,7 +21,7 @@ export function Slider({ 'aria-label': ariaLabel, id, style, className, disabled
21
21
  'dc-slider_full-width': fullWidth,
22
22
  }), children: _jsxs("div", { className: classNames({
23
23
  'dc-slider__body': true,
24
- 'dc-slider__body_has_label': showLabel,
24
+ 'dc-slider__body_has_labels': showLabel,
25
25
  'dc-slider__body_has_tick-marks': tickMarksElement,
26
26
  }), children: [iconLeft, _jsxs(SliderTrack, { positionStart: 0, positionEnd: position, children: [tickMarksElement, _jsx(SliderThumb, { id: thumbId, name: name, "aria-label": ariaLabel, disabled: disabled, showLabel: showLabel, dataListId: dataListId, position: position, step: step, min: min, max: max, value: value, onChange: onChange, formatValue: formatValue })] }), iconRight] }) }));
27
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "draft-components",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
4
4
  "description": "The React based UI components library.",
5
5
  "type": "module",
6
6
  "exports": {