@zag-js/radio-group 0.52.0 → 0.54.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.
@@ -53,32 +53,37 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize
53
53
  clearValue() {
54
54
  send({ type: "SET_VALUE", value: null, isTrusted: false })
55
55
  },
56
- getItemState,
57
56
 
58
- rootProps: normalize.element({
59
- ...parts.root.attrs,
60
- role: "radiogroup",
61
- id: dom.getRootId(state.context),
62
- "aria-labelledby": dom.getLabelId(state.context),
63
- "data-orientation": state.context.orientation,
64
- "data-disabled": dataAttr(groupDisabled),
65
- "aria-orientation": state.context.orientation,
66
- dir: state.context.dir,
67
- style: {
68
- position: "relative",
69
- },
70
- }),
71
-
72
- labelProps: normalize.element({
73
- ...parts.label.attrs,
74
- dir: state.context.dir,
75
- "data-orientation": state.context.orientation,
76
- "data-disabled": dataAttr(groupDisabled),
77
- id: dom.getLabelId(state.context),
78
- onClick: focus,
79
- }),
57
+ getRootProps() {
58
+ return normalize.element({
59
+ ...parts.root.attrs,
60
+ role: "radiogroup",
61
+ id: dom.getRootId(state.context),
62
+ "aria-labelledby": dom.getLabelId(state.context),
63
+ "data-orientation": state.context.orientation,
64
+ "data-disabled": dataAttr(groupDisabled),
65
+ "aria-orientation": state.context.orientation,
66
+ dir: state.context.dir,
67
+ style: {
68
+ position: "relative",
69
+ },
70
+ })
71
+ },
80
72
 
81
- getItemProps(props: ItemProps) {
73
+ getLabelProps() {
74
+ return normalize.element({
75
+ ...parts.label.attrs,
76
+ dir: state.context.dir,
77
+ "data-orientation": state.context.orientation,
78
+ "data-disabled": dataAttr(groupDisabled),
79
+ id: dom.getLabelId(state.context),
80
+ onClick: focus,
81
+ })
82
+ },
83
+
84
+ getItemState,
85
+
86
+ getItemProps(props) {
82
87
  const itemState = getItemState(props)
83
88
 
84
89
  return normalize.label({
@@ -112,7 +117,7 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize
112
117
  })
113
118
  },
114
119
 
115
- getItemTextProps(props: ItemProps) {
120
+ getItemTextProps(props) {
116
121
  return normalize.element({
117
122
  ...parts.itemText.attrs,
118
123
  dir: state.context.dir,
@@ -121,7 +126,7 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize
121
126
  })
122
127
  },
123
128
 
124
- getItemControlProps(props: ItemProps) {
129
+ getItemControlProps(props) {
125
130
  const controlState = getItemState(props)
126
131
 
127
132
  return normalize.element({
@@ -134,7 +139,7 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize
134
139
  })
135
140
  },
136
141
 
137
- getItemHiddenInputProps(props: ItemProps) {
142
+ getItemHiddenInputProps(props) {
138
143
  const inputState = getItemState(props)
139
144
 
140
145
  return normalize.input({
@@ -178,27 +183,29 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize
178
183
  })
179
184
  },
180
185
 
181
- indicatorProps: normalize.element({
182
- id: dom.getIndicatorId(state.context),
183
- ...parts.indicator.attrs,
184
- dir: state.context.dir,
185
- hidden: state.context.value == null,
186
- "data-disabled": dataAttr(groupDisabled),
187
- "data-orientation": state.context.orientation,
188
- style: {
189
- "--transition-property": "left, top, width, height",
190
- "--left": state.context.indicatorRect?.left,
191
- "--top": state.context.indicatorRect?.top,
192
- "--width": state.context.indicatorRect?.width,
193
- "--height": state.context.indicatorRect?.height,
194
- position: "absolute",
195
- willChange: "var(--transition-property)",
196
- transitionProperty: "var(--transition-property)",
197
- transitionDuration: state.context.canIndicatorTransition ? "var(--transition-duration, 150ms)" : "0ms",
198
- transitionTimingFunction: "var(--transition-timing-function)",
199
- [state.context.orientation === "horizontal" ? "left" : "top"]:
200
- state.context.orientation === "horizontal" ? "var(--left)" : "var(--top)",
201
- },
202
- }),
186
+ getIndicatorProps() {
187
+ return normalize.element({
188
+ id: dom.getIndicatorId(state.context),
189
+ ...parts.indicator.attrs,
190
+ dir: state.context.dir,
191
+ hidden: state.context.value == null,
192
+ "data-disabled": dataAttr(groupDisabled),
193
+ "data-orientation": state.context.orientation,
194
+ style: {
195
+ "--transition-property": "left, top, width, height",
196
+ "--left": state.context.indicatorRect?.left,
197
+ "--top": state.context.indicatorRect?.top,
198
+ "--width": state.context.indicatorRect?.width,
199
+ "--height": state.context.indicatorRect?.height,
200
+ position: "absolute",
201
+ willChange: "var(--transition-property)",
202
+ transitionProperty: "var(--transition-property)",
203
+ transitionDuration: state.context.canIndicatorTransition ? "var(--transition-duration, 150ms)" : "0ms",
204
+ transitionTimingFunction: "var(--transition-timing-function)",
205
+ [state.context.orientation === "horizontal" ? "left" : "top"]:
206
+ state.context.orientation === "horizontal" ? "var(--left)" : "var(--top)",
207
+ },
208
+ })
209
+ },
203
210
  }
204
211
  }
@@ -177,11 +177,11 @@ export interface MachineApi<T extends PropTypes = PropTypes> {
177
177
  */
178
178
  getItemState(props: ItemProps): ItemState
179
179
 
180
- rootProps: T["element"]
181
- labelProps: T["element"]
180
+ getRootProps(): T["element"]
181
+ getLabelProps(): T["element"]
182
182
  getItemProps(props: ItemProps): T["label"]
183
183
  getItemTextProps(props: ItemProps): T["element"]
184
184
  getItemControlProps(props: ItemProps): T["element"]
185
185
  getItemHiddenInputProps(props: ItemProps): T["input"]
186
- indicatorProps: T["element"]
186
+ getIndicatorProps(): T["element"]
187
187
  }