@hanzogui/toggle-group 2.0.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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/Toggle.cjs +145 -0
  3. package/dist/cjs/Toggle.native.js +154 -0
  4. package/dist/cjs/Toggle.native.js.map +1 -0
  5. package/dist/cjs/ToggleGroup.cjs +229 -0
  6. package/dist/cjs/ToggleGroup.native.js +252 -0
  7. package/dist/cjs/ToggleGroup.native.js.map +1 -0
  8. package/dist/cjs/context.cjs +32 -0
  9. package/dist/cjs/context.native.js +37 -0
  10. package/dist/cjs/context.native.js.map +1 -0
  11. package/dist/cjs/index.cjs +28 -0
  12. package/dist/cjs/index.native.js +31 -0
  13. package/dist/cjs/index.native.js.map +1 -0
  14. package/dist/cjs/types.cjs +16 -0
  15. package/dist/cjs/types.native.js +19 -0
  16. package/dist/cjs/types.native.js.map +1 -0
  17. package/dist/esm/Toggle.mjs +110 -0
  18. package/dist/esm/Toggle.mjs.map +1 -0
  19. package/dist/esm/Toggle.native.js +116 -0
  20. package/dist/esm/Toggle.native.js.map +1 -0
  21. package/dist/esm/ToggleGroup.mjs +195 -0
  22. package/dist/esm/ToggleGroup.mjs.map +1 -0
  23. package/dist/esm/ToggleGroup.native.js +215 -0
  24. package/dist/esm/ToggleGroup.native.js.map +1 -0
  25. package/dist/esm/context.mjs +8 -0
  26. package/dist/esm/context.mjs.map +1 -0
  27. package/dist/esm/context.native.js +10 -0
  28. package/dist/esm/context.native.js.map +1 -0
  29. package/dist/esm/index.js +4 -0
  30. package/dist/esm/index.js.map +1 -0
  31. package/dist/esm/index.mjs +4 -0
  32. package/dist/esm/index.mjs.map +1 -0
  33. package/dist/esm/index.native.js +4 -0
  34. package/dist/esm/index.native.js.map +1 -0
  35. package/dist/esm/types.mjs +2 -0
  36. package/dist/esm/types.mjs.map +1 -0
  37. package/dist/esm/types.native.js +2 -0
  38. package/dist/esm/types.native.js.map +1 -0
  39. package/dist/jsx/Toggle.mjs +110 -0
  40. package/dist/jsx/Toggle.mjs.map +1 -0
  41. package/dist/jsx/Toggle.native.js +154 -0
  42. package/dist/jsx/Toggle.native.js.map +1 -0
  43. package/dist/jsx/ToggleGroup.mjs +195 -0
  44. package/dist/jsx/ToggleGroup.mjs.map +1 -0
  45. package/dist/jsx/ToggleGroup.native.js +252 -0
  46. package/dist/jsx/ToggleGroup.native.js.map +1 -0
  47. package/dist/jsx/context.mjs +8 -0
  48. package/dist/jsx/context.mjs.map +1 -0
  49. package/dist/jsx/context.native.js +37 -0
  50. package/dist/jsx/context.native.js.map +1 -0
  51. package/dist/jsx/index.js +4 -0
  52. package/dist/jsx/index.js.map +1 -0
  53. package/dist/jsx/index.mjs +4 -0
  54. package/dist/jsx/index.mjs.map +1 -0
  55. package/dist/jsx/index.native.js +31 -0
  56. package/dist/jsx/index.native.js.map +1 -0
  57. package/dist/jsx/types.mjs +2 -0
  58. package/dist/jsx/types.mjs.map +1 -0
  59. package/dist/jsx/types.native.js +19 -0
  60. package/dist/jsx/types.native.js.map +1 -0
  61. package/package.json +60 -0
  62. package/src/Toggle.tsx +150 -0
  63. package/src/ToggleGroup.tsx +355 -0
  64. package/src/context.tsx +10 -0
  65. package/src/index.ts +2 -0
  66. package/src/types.tsx +3 -0
  67. package/types/Toggle.d.ts +74 -0
  68. package/types/ToggleGroup.d.ts +189 -0
  69. package/types/context.d.ts +9 -0
  70. package/types/index.d.ts +3 -0
  71. package/types/types.d.ts +5 -0
@@ -0,0 +1,355 @@
1
+ import { isWeb } from '@hanzogui/constants'
2
+ import { registerFocusable } from '@hanzogui/focusable'
3
+ import { withStaticProperties } from '@hanzogui/helpers'
4
+ import { RovingFocusGroup } from '@hanzogui/roving-focus'
5
+ import { useControllableState } from '@hanzogui/use-controllable-state'
6
+ import { useDirection } from '@hanzogui/use-direction'
7
+ import type { GetProps, GuiElement } from '@hanzogui/web'
8
+ import { createStyledContext, styled, View } from '@hanzogui/web'
9
+ import React from 'react'
10
+
11
+ import type { ToggleProps } from './Toggle'
12
+ import { Toggle, ToggleFrame } from './Toggle'
13
+ import { context as ToggleContext } from './context'
14
+
15
+ const TOGGLE_GROUP_NAME = 'ToggleGroup'
16
+ const TOGGLE_GROUP_ITEM_NAME = 'ToggleGroupItem'
17
+ const TOGGLE_GROUP_CONTEXT = 'ToggleGroup'
18
+
19
+ /* -------------------------------------------------------------------------------------------------
20
+ * ToggleGroupItem
21
+ * -----------------------------------------------------------------------------------------------*/
22
+
23
+ type ToggleGroupItemContextValue = { disabled?: boolean }
24
+
25
+ const { Provider: ToggleGroupItemProvider } =
26
+ createStyledContext<ToggleGroupItemContextValue>()
27
+
28
+ const { Provider: ToggleGroupContext, useStyledContext: useToggleGroupContext } =
29
+ createStyledContext<ToggleGroupContextValue>({})
30
+
31
+ type ToggleGroupItemProps = GetProps<typeof ToggleFrame> & {
32
+ value: string
33
+ id?: string
34
+ disabled?: boolean
35
+ }
36
+
37
+ const ToggleGroupItem = ToggleFrame.styleable<ScopedProps<ToggleGroupItemProps>>(
38
+ (props, forwardedRef) => {
39
+ const valueContext = useToggleGroupValueContext(props.__scopeToggleGroup)
40
+ const context = useToggleGroupContext(props.__scopeToggleGroup)
41
+ const toggleContext = ToggleContext.useStyledContext(props.__scopeToggleGroup)
42
+ const active = valueContext?.value.includes(props.value)
43
+ const color = (props as any).color || toggleContext.color
44
+ const disabled = context.disabled || props.disabled || false
45
+
46
+ const inner = (
47
+ <ToggleGroupItemImpl
48
+ ref={forwardedRef}
49
+ tabIndex={disabled ? -1 : 0}
50
+ {...(props as any)}
51
+ active={active}
52
+ disabled={disabled}
53
+ />
54
+ )
55
+
56
+ return (
57
+ <ToggleGroupItemProvider scope={props.__scopeToggleGroup}>
58
+ <ToggleContext.Provider color={color} active={active}>
59
+ {context.rovingFocus ? (
60
+ <RovingFocusGroup.Item
61
+ asChild="except-style"
62
+ __scopeRovingFocusGroup={props.__scopeToggleGroup || TOGGLE_GROUP_CONTEXT}
63
+ focusable={!disabled}
64
+ active={active}
65
+ >
66
+ {inner}
67
+ </RovingFocusGroup.Item>
68
+ ) : (
69
+ inner
70
+ )}
71
+ </ToggleContext.Provider>
72
+ </ToggleGroupItemProvider>
73
+ )
74
+ }
75
+ )
76
+ ToggleGroupItem.displayName = TOGGLE_GROUP_ITEM_NAME
77
+
78
+ /* -----------------------------------------------------------------------------------------------*/
79
+
80
+ type ToggleGroupItemImplProps = Omit<ToggleProps, 'defaultActive' | 'onActiveChange'> & {
81
+ value: string
82
+ }
83
+
84
+ const ToggleGroupItemImpl = React.forwardRef<
85
+ GuiElement,
86
+ ScopedProps<ToggleGroupItemImplProps>
87
+ >((props, forwardedRef) => {
88
+ const { __scopeToggleGroup, value, ...itemProps } = props
89
+ const valueContext = useToggleGroupValueContext(__scopeToggleGroup)
90
+ const singleProps = { 'aria-pressed': undefined }
91
+ const typeProps = valueContext.type === 'single' ? singleProps : undefined
92
+
93
+ return (
94
+ <Toggle
95
+ {...typeProps}
96
+ {...itemProps}
97
+ ref={forwardedRef}
98
+ onActiveChange={(pressed) => {
99
+ if (pressed) {
100
+ valueContext.onItemActivate(value)
101
+ } else {
102
+ valueContext.onItemDeactivate(value)
103
+ }
104
+ }}
105
+ />
106
+ )
107
+ })
108
+
109
+ /* -------------------------------------------------------------------------------------------------
110
+ * ToggleGroup
111
+ * -----------------------------------------------------------------------------------------------*/
112
+
113
+ type ScopedProps<P> = P & { __scopeToggleGroup?: string }
114
+
115
+ interface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {
116
+ type: 'single'
117
+ }
118
+
119
+ interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {
120
+ type: 'multiple'
121
+ }
122
+
123
+ type ToggleGroupProps = ToggleGroupSingleProps | ToggleGroupMultipleProps
124
+
125
+ const ToggleGroup = withStaticProperties(
126
+ React.forwardRef<GuiElement, ScopedProps<ToggleGroupProps>>(
127
+ (props, forwardedRef) => {
128
+ const { type, ...toggleGroupProps } = props
129
+
130
+ if (!isWeb) {
131
+ React.useEffect(() => {
132
+ if (!props.id) return
133
+ return registerFocusable(props.id, {
134
+ focus: () => {},
135
+ })
136
+ }, [props.id])
137
+ }
138
+
139
+ if (type === 'single') {
140
+ const singleProps = toggleGroupProps as ToggleGroupImplSingleProps
141
+ return <ToggleGroupImplSingle {...singleProps} ref={forwardedRef} />
142
+ }
143
+
144
+ if (type === 'multiple') {
145
+ const multipleProps = toggleGroupProps as ToggleGroupImplMultipleProps
146
+ return <ToggleGroupImplMultiple {...multipleProps} ref={forwardedRef} />
147
+ }
148
+
149
+ throw new Error(`Missing prop \`type\` expected on \`${TOGGLE_GROUP_NAME}\``)
150
+ }
151
+ ),
152
+ {
153
+ Item: ToggleGroupItem,
154
+ }
155
+ )
156
+
157
+ ToggleGroup.displayName = TOGGLE_GROUP_NAME
158
+
159
+ /* -----------------------------------------------------------------------------------------------*/
160
+
161
+ type ToggleGroupValueContextValue = {
162
+ type: 'single' | 'multiple'
163
+ defaultValue?: string | string[]
164
+ value: string[]
165
+ onItemActivate(value: string): void
166
+ onItemDeactivate(value: string): void
167
+ }
168
+
169
+ const {
170
+ Provider: ToggleGroupValueProvider,
171
+ useStyledContext: useToggleGroupValueContext,
172
+ } = createStyledContext<ToggleGroupValueContextValue>()
173
+
174
+ interface ToggleGroupImplSingleProps extends ToggleGroupImplProps {
175
+ /** The controlled stateful value of the item that is pressed. */
176
+ value?: string
177
+ /** The value of the item that is pressed when initially rendered. */
178
+ defaultValue?: string
179
+ /** The callback that fires when the value of the toggle group changes. */
180
+ onValueChange?(value: string): void
181
+ /** Won't let the user turn the active item off. */
182
+ disableDeactivation?: boolean
183
+ }
184
+
185
+ const ToggleGroupImplSingle = React.forwardRef<
186
+ GuiElement,
187
+ ScopedProps<ToggleGroupImplSingleProps>
188
+ >((props: ScopedProps<ToggleGroupImplSingleProps>, forwardedRef) => {
189
+ const {
190
+ value: valueProp,
191
+ defaultValue,
192
+ onValueChange = () => {},
193
+ disableDeactivation = false,
194
+ children,
195
+ ...toggleGroupSingleProps
196
+ } = props
197
+
198
+ const [value, setValue] = useControllableState({
199
+ prop: valueProp,
200
+ defaultProp: defaultValue!,
201
+ onChange: onValueChange,
202
+ })
203
+
204
+ return (
205
+ <ToggleGroupValueProvider
206
+ scope={props.__scopeToggleGroup}
207
+ type="single"
208
+ value={value ? [value] : []}
209
+ defaultValue={value}
210
+ onItemActivate={setValue}
211
+ onItemDeactivate={React.useCallback(
212
+ () => (disableDeactivation ? null : setValue('')),
213
+ [setValue, disableDeactivation]
214
+ )}
215
+ >
216
+ <ToggleGroupImpl {...toggleGroupSingleProps} ref={forwardedRef}>
217
+ {children}
218
+ </ToggleGroupImpl>
219
+ </ToggleGroupValueProvider>
220
+ )
221
+ })
222
+
223
+ interface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {
224
+ /** The controlled stateful value of the items that are pressed. */
225
+ value?: string[]
226
+ /** The value of the items that are pressed when initially rendered. */
227
+ defaultValue?: string[]
228
+ /** The callback that fires when the state of the toggle group changes. */
229
+ onValueChange?(value: string[]): void
230
+ disableDeactivation?: never
231
+ }
232
+
233
+ const ToggleGroupImplMultiple = React.forwardRef<
234
+ GuiElement,
235
+ ToggleGroupImplMultipleProps
236
+ >((props: ScopedProps<ToggleGroupImplMultipleProps>, forwardedRef) => {
237
+ const {
238
+ value: valueProp,
239
+ defaultValue,
240
+ onValueChange = () => {},
241
+ disableDeactivation,
242
+ children,
243
+ ...toggleGroupMultipleProps
244
+ } = props
245
+
246
+ const [value = [], setValue] = useControllableState({
247
+ prop: valueProp,
248
+ defaultProp: defaultValue!,
249
+ onChange: onValueChange,
250
+ })
251
+
252
+ const handleButtonActivate = React.useCallback(
253
+ (itemValue: string) => setValue((prevValue = []) => [...prevValue, itemValue]),
254
+ [setValue]
255
+ )
256
+
257
+ const handleButtonDeactivate = React.useCallback(
258
+ (itemValue: string) =>
259
+ setValue((prevValue = []) => prevValue.filter((value) => value !== itemValue)),
260
+ [setValue]
261
+ )
262
+
263
+ return (
264
+ <ToggleGroupValueProvider
265
+ scope={props.__scopeToggleGroup}
266
+ type="multiple"
267
+ value={value}
268
+ defaultValue={value}
269
+ onItemActivate={handleButtonActivate}
270
+ onItemDeactivate={handleButtonDeactivate}
271
+ >
272
+ <ToggleGroupImpl {...toggleGroupMultipleProps} ref={forwardedRef}>
273
+ {children}
274
+ </ToggleGroupImpl>
275
+ </ToggleGroupValueProvider>
276
+ )
277
+ })
278
+
279
+ /* -----------------------------------------------------------------------------------------------*/
280
+
281
+ type ToggleGroupContextValue = {
282
+ rovingFocus?: boolean
283
+ disabled?: boolean
284
+ }
285
+
286
+ type RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>
287
+
288
+ const ToggleGroupFrame = styled(View, {
289
+ name: TOGGLE_GROUP_NAME,
290
+ })
291
+
292
+ type ToggleGroupImplProps = GetProps<typeof ToggleGroupFrame> & {
293
+ orientation?: 'horizontal' | 'vertical'
294
+ rovingFocus?: boolean
295
+ dir?: RovingFocusGroupProps['dir']
296
+ loop?: RovingFocusGroupProps['loop']
297
+ color?: string
298
+ }
299
+
300
+ const ToggleGroupImpl = ToggleGroupFrame.styleable<GuiElement, ToggleGroupImplProps>(
301
+ (props: ScopedProps<ToggleGroupImplProps>, forwardedRef) => {
302
+ const {
303
+ __scopeToggleGroup,
304
+ disabled = false,
305
+ orientation = 'horizontal',
306
+ dir,
307
+ rovingFocus = true,
308
+ loop = true,
309
+ color,
310
+ ...toggleGroupProps
311
+ } = props
312
+ const direction = useDirection(dir)
313
+
314
+ const content = (
315
+ <ToggleGroupFrame
316
+ role="group"
317
+ ref={forwardedRef}
318
+ data-disabled={disabled ? '' : undefined}
319
+ {...toggleGroupProps}
320
+ />
321
+ )
322
+
323
+ return (
324
+ <ToggleGroupContext
325
+ scope={__scopeToggleGroup}
326
+ rovingFocus={rovingFocus}
327
+ disabled={disabled}
328
+ >
329
+ <ToggleContext.Provider color={color}>
330
+ {rovingFocus ? (
331
+ <RovingFocusGroup
332
+ asChild="except-style"
333
+ __scopeRovingFocusGroup={__scopeToggleGroup || TOGGLE_GROUP_CONTEXT}
334
+ orientation={orientation}
335
+ dir={direction}
336
+ loop={loop}
337
+ >
338
+ {content}
339
+ </RovingFocusGroup>
340
+ ) : (
341
+ content
342
+ )}
343
+ </ToggleContext.Provider>
344
+ </ToggleGroupContext>
345
+ )
346
+ }
347
+ )
348
+
349
+ export { ToggleGroup }
350
+ export type {
351
+ ToggleGroupItemProps,
352
+ ToggleGroupMultipleProps,
353
+ ToggleGroupProps,
354
+ ToggleGroupSingleProps,
355
+ }
@@ -0,0 +1,10 @@
1
+ import { createStyledContext } from '@hanzogui/web'
2
+
3
+ export const context = createStyledContext({
4
+ color: '',
5
+ active: false,
6
+ })
7
+
8
+ export const useToggleGroupItem = () => {
9
+ return context.useStyledContext()
10
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './ToggleGroup'
2
+ export { useToggleGroupItem } from './context'
package/src/types.tsx ADDED
@@ -0,0 +1,3 @@
1
+ import type { ViewStyle } from '@hanzogui/web'
2
+
3
+ export type ToggleStylesBase = ViewStyle & { color?: string }
@@ -0,0 +1,74 @@
1
+ import type { GetProps, GuiElement, ViewStyle } from '@gui/web';
2
+ import * as React from 'react';
3
+ export declare const ToggleFrame: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase & {
4
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
5
+ accept: {
6
+ readonly activeStyle: "style";
7
+ };
8
+ }>> | undefined;
9
+ }, {
10
+ unstyled?: boolean | undefined;
11
+ size?: number | import("@gui/web").SizeTokens | undefined;
12
+ defaultActiveStyle?: boolean | undefined;
13
+ }, {
14
+ accept: {
15
+ readonly activeStyle: "style";
16
+ };
17
+ }>;
18
+ type ToggleFrameProps = GetProps<typeof ToggleFrame>;
19
+ type ToggleItemExtraProps = {
20
+ orientation?: 'horizontal' | 'vertical';
21
+ defaultValue?: string;
22
+ disabled?: boolean;
23
+ active?: boolean;
24
+ defaultActive?: boolean;
25
+ onActiveChange?(active: boolean): void;
26
+ activeStyle?: ViewStyle | null;
27
+ activeTheme?: string | null;
28
+ };
29
+ export type ToggleProps = ToggleFrameProps & ToggleItemExtraProps;
30
+ export declare const Toggle: React.ForwardRefExoticComponent<Omit<import("@gui/web").StackNonStyleProps, "unstyled" | keyof import("@gui/web").StackStyleBase | "size" | "activeStyle" | "defaultActiveStyle"> & import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
31
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
32
+ accept: {
33
+ readonly activeStyle: "style";
34
+ };
35
+ }>> | undefined;
36
+ }> & {
37
+ unstyled?: boolean | undefined;
38
+ size?: number | import("@gui/web").SizeTokens | undefined;
39
+ defaultActiveStyle?: boolean | undefined;
40
+ } & import("@gui/web").WithShorthands<import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
41
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
42
+ accept: {
43
+ readonly activeStyle: "style";
44
+ };
45
+ }>> | undefined;
46
+ }>> & import("@gui/web").WithPseudoProps<import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
47
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
48
+ accept: {
49
+ readonly activeStyle: "style";
50
+ };
51
+ }>> | undefined;
52
+ }> & {
53
+ unstyled?: boolean | undefined;
54
+ size?: number | import("@gui/web").SizeTokens | undefined;
55
+ defaultActiveStyle?: boolean | undefined;
56
+ } & import("@gui/web").WithShorthands<import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
57
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
58
+ accept: {
59
+ readonly activeStyle: "style";
60
+ };
61
+ }>> | undefined;
62
+ }>>> & import("@gui/web").WithMediaProps<import("@gui/web").WithThemeShorthandsAndPseudos<import("@gui/web").StackStyleBase & {
63
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
64
+ accept: {
65
+ readonly activeStyle: "style";
66
+ };
67
+ }>> | undefined;
68
+ }, {
69
+ unstyled?: boolean | undefined;
70
+ size?: number | import("@gui/web").SizeTokens | undefined;
71
+ defaultActiveStyle?: boolean | undefined;
72
+ }>> & ToggleItemExtraProps & React.RefAttributes<GuiElement>>;
73
+ export {};
74
+ //# sourceMappingURL=Toggle.d.ts.map
@@ -0,0 +1,189 @@
1
+ import { RovingFocusGroup } from '@gui/roving-focus';
2
+ import type { GetProps, GuiElement } from '@gui/web';
3
+ import React from 'react';
4
+ import { ToggleFrame } from './Toggle';
5
+ type ToggleGroupItemProps = GetProps<typeof ToggleFrame> & {
6
+ value: string;
7
+ id?: string;
8
+ disabled?: boolean;
9
+ };
10
+ type ScopedProps<P> = P & {
11
+ __scopeToggleGroup?: string;
12
+ };
13
+ interface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {
14
+ type: 'single';
15
+ }
16
+ interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {
17
+ type: 'multiple';
18
+ }
19
+ type ToggleGroupProps = ToggleGroupSingleProps | ToggleGroupMultipleProps;
20
+ declare const ToggleGroup: React.ForwardRefExoticComponent<ScopedProps<ToggleGroupProps> & React.RefAttributes<GuiElement>> & {
21
+ Item: import("@gui/web").GuiComponent<Omit<import("@gui/web").GetFinalProps<import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase & {
22
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
23
+ accept: {
24
+ readonly activeStyle: "style";
25
+ };
26
+ }>> | undefined;
27
+ }, {
28
+ unstyled?: boolean | undefined;
29
+ size?: number | import("@gui/web").SizeTokens | undefined;
30
+ defaultActiveStyle?: boolean | undefined;
31
+ }>, "theme" | "debug" | "style" | `$${string}` | `$${number}` | import("@gui/web").GroupMediaKeys | `$theme-${string}` | `$theme-${number}` | "render" | "hitSlop" | "children" | "target" | "htmlFor" | "asChild" | "dangerouslySetInnerHTML" | "disabled" | "className" | "themeShallow" | "unstyled" | "id" | "group" | "untilMeasured" | "componentName" | "tabIndex" | "role" | "disableOptimization" | "forceStyle" | "disableClassName" | "animatedBy" | "onFocus" | "onBlur" | "onPointerCancel" | "onPointerDown" | "onPointerMove" | "onPointerUp" | "needsOffscreenAlphaCompositing" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "collapsableChildren" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMoveCapture" | "onPointerCancelCapture" | "onPointerDownCapture" | "onPointerUpCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "aria-label" | "accessibilityRole" | "accessibilityState" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-selected" | "accessibilityHint" | "accessibilityValue" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onAccessibilityAction" | "importantForAccessibility" | "aria-hidden" | "aria-modal" | "accessibilityLabelledBy" | "aria-labelledby" | "accessibilityLiveRegion" | "aria-live" | "screenReaderFocusable" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "accessibilityLanguage" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityRespondsToUserInteraction" | keyof import("@gui/web").StackStyleBase | "onPress" | "onLongPress" | "onPressIn" | "onPressOut" | "onMouseEnter" | "onMouseLeave" | "onMouseDown" | "onMouseUp" | "onMouseMove" | "onMouseOver" | "onMouseOut" | "onClick" | "onDoubleClick" | "onContextMenu" | "onWheel" | "onKeyDown" | "onKeyUp" | "onChange" | "onInput" | "onBeforeInput" | "onScroll" | "onCopy" | "onCut" | "onPaste" | "onDrag" | "onDragStart" | "onDragEnd" | "onDragEnter" | "onDragLeave" | "onDragOver" | "onDrop" | "size" | "activeStyle" | "value" | "defaultActiveStyle" | keyof import("@gui/web").WithPseudoProps<import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
32
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
33
+ accept: {
34
+ readonly activeStyle: "style";
35
+ };
36
+ }>> | undefined;
37
+ }> & {
38
+ unstyled?: boolean | undefined;
39
+ size?: number | import("@gui/web").SizeTokens | undefined;
40
+ defaultActiveStyle?: boolean | undefined;
41
+ } & import("@gui/web").WithShorthands<import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
42
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
43
+ accept: {
44
+ readonly activeStyle: "style";
45
+ };
46
+ }>> | undefined;
47
+ }>>> | "__scopeToggleGroup"> & Omit<import("@gui/web").StackNonStyleProps, "unstyled" | keyof import("@gui/web").StackStyleBase | "size" | "activeStyle" | "defaultActiveStyle"> & import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
48
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
49
+ accept: {
50
+ readonly activeStyle: "style";
51
+ };
52
+ }>> | undefined;
53
+ }> & {
54
+ unstyled?: boolean | undefined;
55
+ size?: number | import("@gui/web").SizeTokens | undefined;
56
+ defaultActiveStyle?: boolean | undefined;
57
+ } & import("@gui/web").WithShorthands<import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
58
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
59
+ accept: {
60
+ readonly activeStyle: "style";
61
+ };
62
+ }>> | undefined;
63
+ }>> & import("@gui/web").WithPseudoProps<import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
64
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
65
+ accept: {
66
+ readonly activeStyle: "style";
67
+ };
68
+ }>> | undefined;
69
+ }> & {
70
+ unstyled?: boolean | undefined;
71
+ size?: number | import("@gui/web").SizeTokens | undefined;
72
+ defaultActiveStyle?: boolean | undefined;
73
+ } & import("@gui/web").WithShorthands<import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
74
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
75
+ accept: {
76
+ readonly activeStyle: "style";
77
+ };
78
+ }>> | undefined;
79
+ }>>> & import("@gui/web").WithMediaProps<import("@gui/web").WithThemeShorthandsAndPseudos<import("@gui/web").StackStyleBase & {
80
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
81
+ accept: {
82
+ readonly activeStyle: "style";
83
+ };
84
+ }>> | undefined;
85
+ }, {
86
+ unstyled?: boolean | undefined;
87
+ size?: number | import("@gui/web").SizeTokens | undefined;
88
+ defaultActiveStyle?: boolean | undefined;
89
+ }>> & {
90
+ value: string;
91
+ id?: string;
92
+ disabled?: boolean;
93
+ } & {
94
+ __scopeToggleGroup?: string;
95
+ }, GuiElement, import("@gui/web").StackNonStyleProps & Omit<import("@gui/web").StackNonStyleProps, "unstyled" | keyof import("@gui/web").StackStyleBase | "size" | "activeStyle" | "defaultActiveStyle"> & import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
96
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
97
+ accept: {
98
+ readonly activeStyle: "style";
99
+ };
100
+ }>> | undefined;
101
+ }> & {
102
+ unstyled?: boolean | undefined;
103
+ size?: number | import("@gui/web").SizeTokens | undefined;
104
+ defaultActiveStyle?: boolean | undefined;
105
+ } & import("@gui/web").WithShorthands<import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
106
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
107
+ accept: {
108
+ readonly activeStyle: "style";
109
+ };
110
+ }>> | undefined;
111
+ }>> & import("@gui/web").WithPseudoProps<import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
112
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
113
+ accept: {
114
+ readonly activeStyle: "style";
115
+ };
116
+ }>> | undefined;
117
+ }> & {
118
+ unstyled?: boolean | undefined;
119
+ size?: number | import("@gui/web").SizeTokens | undefined;
120
+ defaultActiveStyle?: boolean | undefined;
121
+ } & import("@gui/web").WithShorthands<import("@gui/web").WithThemeValues<import("@gui/web").StackStyleBase & {
122
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
123
+ accept: {
124
+ readonly activeStyle: "style";
125
+ };
126
+ }>> | undefined;
127
+ }>>> & import("@gui/web").WithMediaProps<import("@gui/web").WithThemeShorthandsAndPseudos<import("@gui/web").StackStyleBase & {
128
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
129
+ accept: {
130
+ readonly activeStyle: "style";
131
+ };
132
+ }>> | undefined;
133
+ }, {
134
+ unstyled?: boolean | undefined;
135
+ size?: number | import("@gui/web").SizeTokens | undefined;
136
+ defaultActiveStyle?: boolean | undefined;
137
+ }>> & {
138
+ value: string;
139
+ id?: string;
140
+ disabled?: boolean;
141
+ } & {
142
+ __scopeToggleGroup?: string;
143
+ }, import("@gui/web").StackStyleBase & {
144
+ readonly activeStyle?: Partial<import("@gui/web").InferStyleProps<import("@gui/web").GuiComponent<import("@gui/web").ViewProps, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, {}>, {
145
+ accept: {
146
+ readonly activeStyle: "style";
147
+ };
148
+ }>> | undefined;
149
+ }, {
150
+ unstyled?: boolean | undefined;
151
+ size?: number | import("@gui/web").SizeTokens | undefined;
152
+ defaultActiveStyle?: boolean | undefined;
153
+ }, {
154
+ accept: {
155
+ readonly activeStyle: "style";
156
+ };
157
+ }>;
158
+ };
159
+ interface ToggleGroupImplSingleProps extends ToggleGroupImplProps {
160
+ /** The controlled stateful value of the item that is pressed. */
161
+ value?: string;
162
+ /** The value of the item that is pressed when initially rendered. */
163
+ defaultValue?: string;
164
+ /** The callback that fires when the value of the toggle group changes. */
165
+ onValueChange?(value: string): void;
166
+ /** Won't let the user turn the active item off. */
167
+ disableDeactivation?: boolean;
168
+ }
169
+ interface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {
170
+ /** The controlled stateful value of the items that are pressed. */
171
+ value?: string[];
172
+ /** The value of the items that are pressed when initially rendered. */
173
+ defaultValue?: string[];
174
+ /** The callback that fires when the state of the toggle group changes. */
175
+ onValueChange?(value: string[]): void;
176
+ disableDeactivation?: never;
177
+ }
178
+ type RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>;
179
+ declare const ToggleGroupFrame: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, GuiElement, import("@gui/web").StackNonStyleProps, import("@gui/web").StackStyleBase, {}, import("@gui/web").StaticConfigPublic>;
180
+ type ToggleGroupImplProps = GetProps<typeof ToggleGroupFrame> & {
181
+ orientation?: 'horizontal' | 'vertical';
182
+ rovingFocus?: boolean;
183
+ dir?: RovingFocusGroupProps['dir'];
184
+ loop?: RovingFocusGroupProps['loop'];
185
+ color?: string;
186
+ };
187
+ export { ToggleGroup };
188
+ export type { ToggleGroupItemProps, ToggleGroupMultipleProps, ToggleGroupProps, ToggleGroupSingleProps, };
189
+ //# sourceMappingURL=ToggleGroup.d.ts.map
@@ -0,0 +1,9 @@
1
+ export declare const context: import("@gui/web").StyledContext<{
2
+ color: string;
3
+ active: boolean;
4
+ }>;
5
+ export declare const useToggleGroupItem: () => {
6
+ color: string;
7
+ active: boolean;
8
+ };
9
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './ToggleGroup';
2
+ export { useToggleGroupItem } from './context';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import type { ViewStyle } from '@gui/web';
2
+ export type ToggleStylesBase = ViewStyle & {
3
+ color?: string;
4
+ };
5
+ //# sourceMappingURL=types.d.ts.map