@peerbots/core 1.0.0 → 1.0.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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.0",
6
+ "version": "1.0.1",
7
7
  "main": "dist/index.js",
8
8
  "style": "./dist/index.css",
9
9
  "types": "dist/index.d.ts",
@@ -13,6 +13,7 @@ export interface SliderProps extends React.AriaAttributes {
13
13
  className?: string;
14
14
  name?: string;
15
15
  icon?: React.ReactNode;
16
+ id?: string;
16
17
  }
17
18
 
18
19
  export const Slider = React.forwardRef<HTMLDivElement, SliderProps>(
@@ -28,6 +29,7 @@ export const Slider = React.forwardRef<HTMLDivElement, SliderProps>(
28
29
  onChange,
29
30
  name,
30
31
  icon,
32
+ id,
31
33
  "aria-label": ariaLabel,
32
34
  ...props
33
35
  },
@@ -46,20 +48,21 @@ export const Slider = React.forwardRef<HTMLDivElement, SliderProps>(
46
48
  <div className="pb:flex-grow pb:flex pb:items-center pb:h-8 pb:min-w-[120px]">
47
49
  <BaseSlider.Root
48
50
  ref={ref}
51
+ id={id}
49
52
  min={min}
50
53
  max={max}
51
54
  step={step}
52
55
  value={
53
56
  value !== undefined
54
57
  ? Array.isArray(value)
55
- ? value
58
+ ? (value as number[])
56
59
  : [value]
57
60
  : undefined
58
61
  }
59
62
  defaultValue={
60
63
  defaultValue !== undefined
61
64
  ? Array.isArray(defaultValue)
62
- ? defaultValue
65
+ ? (defaultValue as number[])
63
66
  : [defaultValue]
64
67
  : undefined
65
68
  }
@@ -14,6 +14,7 @@ export interface SliderWithNumberFieldProps extends React.AriaAttributes {
14
14
  className?: string;
15
15
  inputWidth?: string;
16
16
  showButtons?: boolean;
17
+ id?: string;
17
18
  }
18
19
 
19
20
  export const SliderWithNumberField = React.forwardRef<
@@ -32,11 +33,17 @@ export const SliderWithNumberField = React.forwardRef<
32
33
  onChange,
33
34
  inputWidth,
34
35
  showButtons = false,
36
+ id,
35
37
  "aria-label": ariaLabel,
36
38
  ...props
37
39
  },
38
40
  ref,
39
41
  ) => {
42
+ const reactId = React.useId();
43
+ const uniqueId = id || reactId;
44
+ const sliderId = `${uniqueId}-slider`;
45
+ const numberId = `${uniqueId}-number`;
46
+
40
47
  const handleChange = (val: number | number[], event: Event) => {
41
48
  if (onChange) {
42
49
  const newValue = Array.isArray(val) ? val[0] : val;
@@ -62,6 +69,7 @@ export const SliderWithNumberField = React.forwardRef<
62
69
  >
63
70
  <div className="pb:flex-1 pb:min-w-0">
64
71
  <Slider
72
+ id={sliderId}
65
73
  min={min}
66
74
  max={max}
67
75
  step={step}
@@ -75,6 +83,7 @@ export const SliderWithNumberField = React.forwardRef<
75
83
  </div>
76
84
  <div className={cn(widthClass, "pb:shrink-0")}>
77
85
  <NumberField
86
+ id={numberId}
78
87
  value={value}
79
88
  defaultValue={defaultValue}
80
89
  min={min}