@hanzogui/toggle-group 2.0.0-rc.41-hanzoai.3
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/LICENSE +21 -0
- package/dist/cjs/Toggle.cjs +150 -0
- package/dist/cjs/Toggle.native.js +159 -0
- package/dist/cjs/Toggle.native.js.map +1 -0
- package/dist/cjs/ToggleGroup.cjs +245 -0
- package/dist/cjs/ToggleGroup.native.js +262 -0
- package/dist/cjs/ToggleGroup.native.js.map +1 -0
- package/dist/cjs/context.cjs +36 -0
- package/dist/cjs/context.native.js +39 -0
- package/dist/cjs/context.native.js.map +1 -0
- package/dist/cjs/index.cjs +30 -0
- package/dist/cjs/index.native.js +33 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/types.cjs +18 -0
- package/dist/cjs/types.native.js +21 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/esm/Toggle.mjs +113 -0
- package/dist/esm/Toggle.mjs.map +1 -0
- package/dist/esm/Toggle.native.js +119 -0
- package/dist/esm/Toggle.native.js.map +1 -0
- package/dist/esm/ToggleGroup.mjs +209 -0
- package/dist/esm/ToggleGroup.mjs.map +1 -0
- package/dist/esm/ToggleGroup.native.js +223 -0
- package/dist/esm/ToggleGroup.native.js.map +1 -0
- package/dist/esm/context.mjs +10 -0
- package/dist/esm/context.mjs.map +1 -0
- package/dist/esm/context.native.js +10 -0
- package/dist/esm/context.native.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +4 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -0
- package/dist/esm/types.native.js.map +1 -0
- package/dist/jsx/Toggle.mjs +113 -0
- package/dist/jsx/Toggle.mjs.map +1 -0
- package/dist/jsx/Toggle.native.js +159 -0
- package/dist/jsx/Toggle.native.js.map +1 -0
- package/dist/jsx/ToggleGroup.mjs +209 -0
- package/dist/jsx/ToggleGroup.mjs.map +1 -0
- package/dist/jsx/ToggleGroup.native.js +262 -0
- package/dist/jsx/ToggleGroup.native.js.map +1 -0
- package/dist/jsx/context.mjs +10 -0
- package/dist/jsx/context.mjs.map +1 -0
- package/dist/jsx/context.native.js +39 -0
- package/dist/jsx/context.native.js.map +1 -0
- package/dist/jsx/index.js +4 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/index.mjs +4 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/index.native.js +33 -0
- package/dist/jsx/index.native.js.map +1 -0
- package/dist/jsx/types.mjs +2 -0
- package/dist/jsx/types.mjs.map +1 -0
- package/dist/jsx/types.native.js +21 -0
- package/dist/jsx/types.native.js.map +1 -0
- package/package.json +61 -0
- package/src/Toggle.tsx +150 -0
- package/src/ToggleGroup.tsx +355 -0
- package/src/context.tsx +10 -0
- package/src/index.ts +2 -0
- package/src/types.tsx +3 -0
- package/types/Toggle.d.ts +74 -0
- package/types/Toggle.d.ts.map +1 -0
- package/types/ToggleGroup.d.ts +189 -0
- package/types/ToggleGroup.d.ts.map +1 -0
- package/types/context.d.ts +9 -0
- package/types/context.d.ts.map +1 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -0
- package/types/types.d.ts +5 -0
- package/types/types.d.ts.map +1 -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, HanzoguiElement } 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
|
+
HanzoguiElement,
|
|
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<HanzoguiElement, 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
|
+
HanzoguiElement,
|
|
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
|
+
HanzoguiElement,
|
|
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<HanzoguiElement, 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
|
+
}
|
package/src/context.tsx
ADDED
package/src/index.ts
ADDED
package/src/types.tsx
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { GetProps, HanzoguiElement, ViewStyle } from '@hanzogui/web';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export declare const ToggleFrame: import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").TamaDefer, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase & {
|
|
4
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
5
|
+
accept: {
|
|
6
|
+
readonly activeStyle: "style";
|
|
7
|
+
};
|
|
8
|
+
}>> | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
unstyled?: boolean | undefined;
|
|
11
|
+
size?: number | import("@hanzogui/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("@hanzogui/web").StackNonStyleProps, "unstyled" | keyof import("@hanzogui/web").StackStyleBase | "size" | "activeStyle" | "defaultActiveStyle"> & import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
31
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
32
|
+
accept: {
|
|
33
|
+
readonly activeStyle: "style";
|
|
34
|
+
};
|
|
35
|
+
}>> | undefined;
|
|
36
|
+
}> & {
|
|
37
|
+
unstyled?: boolean | undefined;
|
|
38
|
+
size?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
39
|
+
defaultActiveStyle?: boolean | undefined;
|
|
40
|
+
} & import("@hanzogui/web").WithShorthands<import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
41
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
42
|
+
accept: {
|
|
43
|
+
readonly activeStyle: "style";
|
|
44
|
+
};
|
|
45
|
+
}>> | undefined;
|
|
46
|
+
}>> & import("@hanzogui/web").WithPseudoProps<import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
47
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
48
|
+
accept: {
|
|
49
|
+
readonly activeStyle: "style";
|
|
50
|
+
};
|
|
51
|
+
}>> | undefined;
|
|
52
|
+
}> & {
|
|
53
|
+
unstyled?: boolean | undefined;
|
|
54
|
+
size?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
55
|
+
defaultActiveStyle?: boolean | undefined;
|
|
56
|
+
} & import("@hanzogui/web").WithShorthands<import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
57
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
58
|
+
accept: {
|
|
59
|
+
readonly activeStyle: "style";
|
|
60
|
+
};
|
|
61
|
+
}>> | undefined;
|
|
62
|
+
}>>> & import("@hanzogui/web").WithMediaProps<import("@hanzogui/web").WithThemeShorthandsAndPseudos<import("@hanzogui/web").StackStyleBase & {
|
|
63
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
64
|
+
accept: {
|
|
65
|
+
readonly activeStyle: "style";
|
|
66
|
+
};
|
|
67
|
+
}>> | undefined;
|
|
68
|
+
}, {
|
|
69
|
+
unstyled?: boolean | undefined;
|
|
70
|
+
size?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
71
|
+
defaultActiveStyle?: boolean | undefined;
|
|
72
|
+
}>> & ToggleItemExtraProps & React.RefAttributes<HanzoguiElement>>;
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=Toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toggle.d.ts","sourceRoot":"","sources":["../src/Toggle.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,eAAO,MAAM,WAAW;;;;;;;;;;;;;;EAuEvB,CAAA;AAED,KAAK,gBAAgB,GAAG,QAAQ,CAAC,OAAO,WAAW,CAAC,CAAA;AAEpD,KAAK,oBAAoB,GAAG;IAC1B,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IACvC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAA;IACtC,WAAW,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,oBAAoB,CAAA;AAEjE,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kEA8ClB,CAAA"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { RovingFocusGroup } from '@hanzogui/roving-focus';
|
|
2
|
+
import type { GetProps, HanzoguiElement } from '@hanzogui/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<HanzoguiElement>> & {
|
|
21
|
+
Item: import("@hanzogui/web").HanzoguiComponent<Omit<import("@hanzogui/web").GetFinalProps<import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase & {
|
|
22
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
23
|
+
accept: {
|
|
24
|
+
readonly activeStyle: "style";
|
|
25
|
+
};
|
|
26
|
+
}>> | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
unstyled?: boolean | undefined;
|
|
29
|
+
size?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
30
|
+
defaultActiveStyle?: boolean | undefined;
|
|
31
|
+
}>, "theme" | "debug" | "style" | `$${string}` | `$${number}` | import("@hanzogui/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("@hanzogui/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("@hanzogui/web").WithPseudoProps<import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
32
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
33
|
+
accept: {
|
|
34
|
+
readonly activeStyle: "style";
|
|
35
|
+
};
|
|
36
|
+
}>> | undefined;
|
|
37
|
+
}> & {
|
|
38
|
+
unstyled?: boolean | undefined;
|
|
39
|
+
size?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
40
|
+
defaultActiveStyle?: boolean | undefined;
|
|
41
|
+
} & import("@hanzogui/web").WithShorthands<import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
42
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
43
|
+
accept: {
|
|
44
|
+
readonly activeStyle: "style";
|
|
45
|
+
};
|
|
46
|
+
}>> | undefined;
|
|
47
|
+
}>>> | "__scopeToggleGroup"> & Omit<import("@hanzogui/web").StackNonStyleProps, "unstyled" | keyof import("@hanzogui/web").StackStyleBase | "size" | "activeStyle" | "defaultActiveStyle"> & import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
48
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
49
|
+
accept: {
|
|
50
|
+
readonly activeStyle: "style";
|
|
51
|
+
};
|
|
52
|
+
}>> | undefined;
|
|
53
|
+
}> & {
|
|
54
|
+
unstyled?: boolean | undefined;
|
|
55
|
+
size?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
56
|
+
defaultActiveStyle?: boolean | undefined;
|
|
57
|
+
} & import("@hanzogui/web").WithShorthands<import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
58
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
59
|
+
accept: {
|
|
60
|
+
readonly activeStyle: "style";
|
|
61
|
+
};
|
|
62
|
+
}>> | undefined;
|
|
63
|
+
}>> & import("@hanzogui/web").WithPseudoProps<import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
64
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
65
|
+
accept: {
|
|
66
|
+
readonly activeStyle: "style";
|
|
67
|
+
};
|
|
68
|
+
}>> | undefined;
|
|
69
|
+
}> & {
|
|
70
|
+
unstyled?: boolean | undefined;
|
|
71
|
+
size?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
72
|
+
defaultActiveStyle?: boolean | undefined;
|
|
73
|
+
} & import("@hanzogui/web").WithShorthands<import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
74
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
75
|
+
accept: {
|
|
76
|
+
readonly activeStyle: "style";
|
|
77
|
+
};
|
|
78
|
+
}>> | undefined;
|
|
79
|
+
}>>> & import("@hanzogui/web").WithMediaProps<import("@hanzogui/web").WithThemeShorthandsAndPseudos<import("@hanzogui/web").StackStyleBase & {
|
|
80
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
81
|
+
accept: {
|
|
82
|
+
readonly activeStyle: "style";
|
|
83
|
+
};
|
|
84
|
+
}>> | undefined;
|
|
85
|
+
}, {
|
|
86
|
+
unstyled?: boolean | undefined;
|
|
87
|
+
size?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
88
|
+
defaultActiveStyle?: boolean | undefined;
|
|
89
|
+
}>> & {
|
|
90
|
+
value: string;
|
|
91
|
+
id?: string;
|
|
92
|
+
disabled?: boolean;
|
|
93
|
+
} & {
|
|
94
|
+
__scopeToggleGroup?: string;
|
|
95
|
+
}, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps & Omit<import("@hanzogui/web").StackNonStyleProps, "unstyled" | keyof import("@hanzogui/web").StackStyleBase | "size" | "activeStyle" | "defaultActiveStyle"> & import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
96
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
97
|
+
accept: {
|
|
98
|
+
readonly activeStyle: "style";
|
|
99
|
+
};
|
|
100
|
+
}>> | undefined;
|
|
101
|
+
}> & {
|
|
102
|
+
unstyled?: boolean | undefined;
|
|
103
|
+
size?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
104
|
+
defaultActiveStyle?: boolean | undefined;
|
|
105
|
+
} & import("@hanzogui/web").WithShorthands<import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
106
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
107
|
+
accept: {
|
|
108
|
+
readonly activeStyle: "style";
|
|
109
|
+
};
|
|
110
|
+
}>> | undefined;
|
|
111
|
+
}>> & import("@hanzogui/web").WithPseudoProps<import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
112
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
113
|
+
accept: {
|
|
114
|
+
readonly activeStyle: "style";
|
|
115
|
+
};
|
|
116
|
+
}>> | undefined;
|
|
117
|
+
}> & {
|
|
118
|
+
unstyled?: boolean | undefined;
|
|
119
|
+
size?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
120
|
+
defaultActiveStyle?: boolean | undefined;
|
|
121
|
+
} & import("@hanzogui/web").WithShorthands<import("@hanzogui/web").WithThemeValues<import("@hanzogui/web").StackStyleBase & {
|
|
122
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
123
|
+
accept: {
|
|
124
|
+
readonly activeStyle: "style";
|
|
125
|
+
};
|
|
126
|
+
}>> | undefined;
|
|
127
|
+
}>>> & import("@hanzogui/web").WithMediaProps<import("@hanzogui/web").WithThemeShorthandsAndPseudos<import("@hanzogui/web").StackStyleBase & {
|
|
128
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
129
|
+
accept: {
|
|
130
|
+
readonly activeStyle: "style";
|
|
131
|
+
};
|
|
132
|
+
}>> | undefined;
|
|
133
|
+
}, {
|
|
134
|
+
unstyled?: boolean | undefined;
|
|
135
|
+
size?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
136
|
+
defaultActiveStyle?: boolean | undefined;
|
|
137
|
+
}>> & {
|
|
138
|
+
value: string;
|
|
139
|
+
id?: string;
|
|
140
|
+
disabled?: boolean;
|
|
141
|
+
} & {
|
|
142
|
+
__scopeToggleGroup?: string;
|
|
143
|
+
}, import("@hanzogui/web").StackStyleBase & {
|
|
144
|
+
readonly activeStyle?: Partial<import("@hanzogui/web").InferStyleProps<import("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").ViewProps, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, {}>, {
|
|
145
|
+
accept: {
|
|
146
|
+
readonly activeStyle: "style";
|
|
147
|
+
};
|
|
148
|
+
}>> | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
unstyled?: boolean | undefined;
|
|
151
|
+
size?: number | import("@hanzogui/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("@hanzogui/web").HanzoguiComponent<import("@hanzogui/web").TamaDefer, HanzoguiElement, import("@hanzogui/web").StackNonStyleProps, import("@hanzogui/web").StackStyleBase, {}, import("@hanzogui/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 @@
|
|
|
1
|
+
{"version":3,"file":"ToggleGroup.d.ts","sourceRoot":"","sources":["../src/ToggleGroup.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE9D,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAU,WAAW,EAAE,MAAM,UAAU,CAAA;AAmB9C,KAAK,oBAAoB,GAAG,QAAQ,CAAC,OAAO,WAAW,CAAC,GAAG;IACzD,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AA8ED,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEzD,UAAU,sBAAuB,SAAQ,0BAA0B;IACjE,IAAI,EAAE,QAAQ,CAAA;CACf;AAED,UAAU,wBAAyB,SAAQ,4BAA4B;IACrE,IAAI,EAAE,UAAU,CAAA;CACjB;AAED,KAAK,gBAAgB,GAAG,sBAAsB,GAAG,wBAAwB,CAAA;AAEzE,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA7FR,MAAM;aACR,MAAM;mBACA,OAAO;;6BA+E6B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAjF9C,MAAM;aACR,MAAM;mBACA,OAAO;;6BA+E6B,MAAM;;;;;;;;;;;;;;;;CA0CtD,CAAA;AAmBD,UAAU,0BAA2B,SAAQ,oBAAoB;IAC/D,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qEAAqE;IACrE,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,0EAA0E;IAC1E,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACnC,mDAAmD;IACnD,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAwCD,UAAU,4BAA6B,SAAQ,oBAAoB;IACjE,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,0EAA0E;IAC1E,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IACrC,mBAAmB,CAAC,EAAE,KAAK,CAAA;CAC5B;AAuDD,KAAK,qBAAqB,GAAG,KAAK,CAAC,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEpF,QAAA,MAAM,gBAAgB,mOAEpB,CAAA;AAEF,KAAK,oBAAoB,GAAG,QAAQ,CAAC,OAAO,gBAAgB,CAAC,GAAG;IAC9D,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IACvC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,GAAG,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAA;IAClC,IAAI,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAA;IACpC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAmDD,OAAO,EAAE,WAAW,EAAE,CAAA;AACtB,YAAY,EACV,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EAChB,sBAAsB,GACvB,CAAA"}
|