@zag-js/slider 0.0.0-dev-20220617070002 → 0.0.0-dev-20220617101836

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/dist/index.js CHANGED
@@ -423,6 +423,8 @@ function getHorizontalThumbOffset(ctx) {
423
423
  }
424
424
  function getThumbOffset(ctx) {
425
425
  const percent = valueToPercent(ctx.value, ctx);
426
+ if (ctx.thumbAlignment === "center")
427
+ return `${percent}%`;
426
428
  const offset = ctx.isVertical ? getVerticalThumbOffset(ctx) : getHorizontalThumbOffset(ctx);
427
429
  return `calc(${percent}% - ${offset}px)`;
428
430
  }
@@ -829,6 +831,7 @@ function machine(ctx = {}) {
829
831
  initial: "unknown",
830
832
  context: __spreadValues({
831
833
  thumbSize: null,
834
+ thumbAlignment: "contain",
832
835
  uid: "",
833
836
  disabled: false,
834
837
  threshold: 5,
@@ -1001,6 +1004,8 @@ function machine(ctx = {}) {
1001
1004
  dom.dispatchChangeEvent(ctx2);
1002
1005
  },
1003
1006
  setThumbSize(ctx2) {
1007
+ if (ctx2.thumbAlignment !== "contain")
1008
+ return;
1004
1009
  raf(() => {
1005
1010
  const el = dom.getThumbEl(ctx2);
1006
1011
  if (!el)
package/dist/index.mjs CHANGED
@@ -399,6 +399,8 @@ function getHorizontalThumbOffset(ctx) {
399
399
  }
400
400
  function getThumbOffset(ctx) {
401
401
  const percent = valueToPercent(ctx.value, ctx);
402
+ if (ctx.thumbAlignment === "center")
403
+ return `${percent}%`;
402
404
  const offset = ctx.isVertical ? getVerticalThumbOffset(ctx) : getHorizontalThumbOffset(ctx);
403
405
  return `calc(${percent}% - ${offset}px)`;
404
406
  }
@@ -805,6 +807,7 @@ function machine(ctx = {}) {
805
807
  initial: "unknown",
806
808
  context: __spreadValues({
807
809
  thumbSize: null,
810
+ thumbAlignment: "contain",
808
811
  uid: "",
809
812
  disabled: false,
810
813
  threshold: 5,
@@ -977,6 +980,8 @@ function machine(ctx = {}) {
977
980
  dom.dispatchChangeEvent(ctx2);
978
981
  },
979
982
  setThumbSize(ctx2) {
983
+ if (ctx2.thumbAlignment !== "contain")
984
+ return;
980
985
  raf(() => {
981
986
  const el = dom.getThumbEl(ctx2);
982
987
  if (!el)
@@ -89,6 +89,12 @@ declare type PublicContext = DirectionProperty & {
89
89
  onChangeStart?(details: {
90
90
  value: number;
91
91
  }): void;
92
+ /**
93
+ * The alignment of the slider thumb relative to the track
94
+ * - `center`: the thumb will extend beyond the bounds of the slider track.
95
+ * - `contain`: the thumb will be contained within the bounds of the track.
96
+ */
97
+ thumbAlignment?: "contain" | "center";
92
98
  };
93
99
  export declare type UserDefinedContext = Partial<PublicContext>;
94
100
  declare type ComputedContext = Readonly<{
@@ -156,6 +162,7 @@ export declare type SharedContext = {
156
162
  width: number;
157
163
  height: number;
158
164
  } | null;
165
+ thumbAlignment?: "contain" | "center";
159
166
  orientation?: "horizontal" | "vertical";
160
167
  readonly hasMeasuredThumbSize: boolean;
161
168
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/slider",
3
- "version": "0.0.0-dev-20220617070002",
3
+ "version": "0.0.0-dev-20220617101836",
4
4
  "description": "Core logic for the slider widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -30,10 +30,10 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@zag-js/core": "0.1.6",
33
- "@zag-js/dom-utils": "0.0.0-dev-20220617070002",
33
+ "@zag-js/dom-utils": "0.0.0-dev-20220617101836",
34
34
  "@zag-js/number-utils": "0.1.2",
35
35
  "@zag-js/rect-utils": "0.1.2",
36
- "@zag-js/types": "0.0.0-dev-20220617070002",
36
+ "@zag-js/types": "0.0.0-dev-20220617101836",
37
37
  "@zag-js/utils": "0.1.2"
38
38
  },
39
39
  "scripts": {