@fluentui/react-toolbar 9.0.0-beta.5 → 9.0.0-beta.7
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/CHANGELOG.json +128 -6
- package/CHANGELOG.md +36 -7
- package/dist/index.d.ts +36 -5
- package/lib/components/Toolbar/Toolbar.types.js.map +1 -1
- package/lib/components/Toolbar/ToolbarContext.js +10 -5
- package/lib/components/Toolbar/ToolbarContext.js.map +1 -1
- package/lib/components/Toolbar/useToolbar.js +39 -6
- package/lib/components/Toolbar/useToolbar.js.map +1 -1
- package/lib/components/Toolbar/useToolbarContextValues.js +4 -2
- package/lib/components/Toolbar/useToolbarContextValues.js.map +1 -1
- package/lib/components/ToolbarToggleButton/ToolbarToggleButton.js +3 -9
- package/lib/components/ToolbarToggleButton/ToolbarToggleButton.js.map +1 -1
- package/lib/components/ToolbarToggleButton/ToolbarToggleButton.types.js.map +1 -1
- package/lib/components/ToolbarToggleButton/useToolbarToggleButton.js +37 -0
- package/lib/components/ToolbarToggleButton/useToolbarToggleButton.js.map +1 -0
- package/lib-commonjs/components/Toolbar/ToolbarContext.js +10 -5
- package/lib-commonjs/components/Toolbar/ToolbarContext.js.map +1 -1
- package/lib-commonjs/components/Toolbar/useToolbar.js +41 -7
- package/lib-commonjs/components/Toolbar/useToolbar.js.map +1 -1
- package/lib-commonjs/components/Toolbar/useToolbarContextValues.js +4 -2
- package/lib-commonjs/components/Toolbar/useToolbarContextValues.js.map +1 -1
- package/lib-commonjs/components/ToolbarToggleButton/ToolbarToggleButton.js +2 -8
- package/lib-commonjs/components/ToolbarToggleButton/ToolbarToggleButton.js.map +1 -1
- package/lib-commonjs/components/ToolbarToggleButton/useToolbarToggleButton.js +48 -0
- package/lib-commonjs/components/ToolbarToggleButton/useToolbarToggleButton.js.map +1 -0
- package/package.json +13 -11
- package/dist/tsdoc-metadata.json +0 -11
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,129 @@
|
|
|
2
2
|
"name": "@fluentui/react-toolbar",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Tue, 20 Sep 2022 20:54:08 GMT",
|
|
6
|
+
"tag": "@fluentui/react-toolbar_v9.0.0-beta.7",
|
|
7
|
+
"version": "9.0.0-beta.7",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "beachball",
|
|
12
|
+
"package": "@fluentui/react-toolbar",
|
|
13
|
+
"comment": "Bump @fluentui/react-button to v9.1.2",
|
|
14
|
+
"commit": "9617a5a46ef4c5e310a066a5374ff2ed61db3c66"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@fluentui/react-toolbar",
|
|
19
|
+
"comment": "Bump @fluentui/react-divider to v9.1.0",
|
|
20
|
+
"commit": "9617a5a46ef4c5e310a066a5374ff2ed61db3c66"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@fluentui/react-toolbar",
|
|
25
|
+
"comment": "Bump @fluentui/react-radio to v9.0.6",
|
|
26
|
+
"commit": "9617a5a46ef4c5e310a066a5374ff2ed61db3c66"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "beachball",
|
|
30
|
+
"package": "@fluentui/react-toolbar",
|
|
31
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.14",
|
|
32
|
+
"commit": "9617a5a46ef4c5e310a066a5374ff2ed61db3c66"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"date": "Thu, 15 Sep 2022 09:49:41 GMT",
|
|
39
|
+
"tag": "@fluentui/react-toolbar_v9.0.0-beta.6",
|
|
40
|
+
"version": "9.0.0-beta.6",
|
|
41
|
+
"comments": {
|
|
42
|
+
"prerelease": [
|
|
43
|
+
{
|
|
44
|
+
"author": "lingfangao@hotmail.com",
|
|
45
|
+
"package": "@fluentui/react-toolbar",
|
|
46
|
+
"commit": "a0cfab0e5f74e3a3bfa9c269fff574295042d7f2",
|
|
47
|
+
"comment": "chore: fix no-context-default-value lint violations"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"author": "olfedias@microsoft.com",
|
|
51
|
+
"package": "@fluentui/react-toolbar",
|
|
52
|
+
"commit": "e610024474cfe5d45f61501a8b6a21daf4c794a2",
|
|
53
|
+
"comment": "chore: Update Griffel to latest version"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"author": "beachball",
|
|
57
|
+
"package": "@fluentui/react-toolbar",
|
|
58
|
+
"comment": "Bump @fluentui/react-button to v9.1.1",
|
|
59
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"author": "beachball",
|
|
63
|
+
"package": "@fluentui/react-toolbar",
|
|
64
|
+
"comment": "Bump @fluentui/react-divider to v9.0.5",
|
|
65
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"author": "beachball",
|
|
69
|
+
"package": "@fluentui/react-toolbar",
|
|
70
|
+
"comment": "Bump @fluentui/react-theme to v9.1.0",
|
|
71
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"author": "beachball",
|
|
75
|
+
"package": "@fluentui/react-toolbar",
|
|
76
|
+
"comment": "Bump @fluentui/react-utilities to v9.1.0",
|
|
77
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"author": "beachball",
|
|
81
|
+
"package": "@fluentui/react-toolbar",
|
|
82
|
+
"comment": "Bump @fluentui/react-radio to v9.0.5",
|
|
83
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"author": "beachball",
|
|
87
|
+
"package": "@fluentui/react-toolbar",
|
|
88
|
+
"comment": "Bump @fluentui/react-tabster to v9.1.1",
|
|
89
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"author": "beachball",
|
|
93
|
+
"package": "@fluentui/react-toolbar",
|
|
94
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.13",
|
|
95
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"none": [
|
|
99
|
+
{
|
|
100
|
+
"author": "chassunc@microsoft.com",
|
|
101
|
+
"package": "@fluentui/react-toolbar",
|
|
102
|
+
"commit": "bee2c5b4e2ced66d3897fe2ca7d255f17f5f865b",
|
|
103
|
+
"comment": "feat: add toolbar controlled state example for toggle buttons"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"author": "chassunc@microsoft.com",
|
|
107
|
+
"package": "@fluentui/react-toolbar",
|
|
108
|
+
"commit": "92a2649587483cef44c5ce186f05b0254e015e02",
|
|
109
|
+
"comment": "chore: add e2e tests for toolbar"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"author": "martinhochel@microsoft.com",
|
|
113
|
+
"package": "@fluentui/react-toolbar",
|
|
114
|
+
"commit": "ba9444d594f3a960cc590eae5237c08bf7c5a07f",
|
|
115
|
+
"comment": "chore: consume cypress.config from it's package boundary"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"author": "martinhochel@microsoft.com",
|
|
119
|
+
"package": "@fluentui/react-toolbar",
|
|
120
|
+
"commit": "e6cf183695d6d67a24e038c49a876224e5ed35e5",
|
|
121
|
+
"comment": "chore: update package scaffold"
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"date": "Wed, 03 Aug 2022 16:04:08 GMT",
|
|
6
128
|
"tag": "@fluentui/react-toolbar_v9.0.0-beta.5",
|
|
7
129
|
"version": "9.0.0-beta.5",
|
|
8
130
|
"comments": {
|
|
@@ -17,31 +139,31 @@
|
|
|
17
139
|
"author": "beachball",
|
|
18
140
|
"package": "@fluentui/react-toolbar",
|
|
19
141
|
"comment": "Bump @fluentui/react-button to v9.1.0",
|
|
20
|
-
"commit": "
|
|
142
|
+
"commit": "ee4a8be0d0831a6615f878f98db6a97cc61a802d"
|
|
21
143
|
},
|
|
22
144
|
{
|
|
23
145
|
"author": "beachball",
|
|
24
146
|
"package": "@fluentui/react-toolbar",
|
|
25
147
|
"comment": "Bump @fluentui/react-divider to v9.0.4",
|
|
26
|
-
"commit": "
|
|
148
|
+
"commit": "ee4a8be0d0831a6615f878f98db6a97cc61a802d"
|
|
27
149
|
},
|
|
28
150
|
{
|
|
29
151
|
"author": "beachball",
|
|
30
152
|
"package": "@fluentui/react-toolbar",
|
|
31
153
|
"comment": "Bump @fluentui/react-radio to v9.0.4",
|
|
32
|
-
"commit": "
|
|
154
|
+
"commit": "ee4a8be0d0831a6615f878f98db6a97cc61a802d"
|
|
33
155
|
},
|
|
34
156
|
{
|
|
35
157
|
"author": "beachball",
|
|
36
158
|
"package": "@fluentui/react-toolbar",
|
|
37
159
|
"comment": "Bump @fluentui/react-tabster to v9.1.0",
|
|
38
|
-
"commit": "
|
|
160
|
+
"commit": "ee4a8be0d0831a6615f878f98db6a97cc61a802d"
|
|
39
161
|
},
|
|
40
162
|
{
|
|
41
163
|
"author": "beachball",
|
|
42
164
|
"package": "@fluentui/react-toolbar",
|
|
43
165
|
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.12",
|
|
44
|
-
"commit": "
|
|
166
|
+
"commit": "ee4a8be0d0831a6615f878f98db6a97cc61a802d"
|
|
45
167
|
}
|
|
46
168
|
],
|
|
47
169
|
"none": [
|
package/CHANGELOG.md
CHANGED
|
@@ -1,22 +1,51 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-toolbar
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 20 Sep 2022 20:54:08 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-beta.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-toolbar_v9.0.0-beta.7)
|
|
8
|
+
|
|
9
|
+
Tue, 20 Sep 2022 20:54:08 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-toolbar_v9.0.0-beta.6..@fluentui/react-toolbar_v9.0.0-beta.7)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- Bump @fluentui/react-button to v9.1.2 ([PR #24870](https://github.com/microsoft/fluentui/pull/24870) by beachball)
|
|
15
|
+
- Bump @fluentui/react-divider to v9.1.0 ([PR #24870](https://github.com/microsoft/fluentui/pull/24870) by beachball)
|
|
16
|
+
- Bump @fluentui/react-radio to v9.0.6 ([PR #24870](https://github.com/microsoft/fluentui/pull/24870) by beachball)
|
|
17
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.14 ([PR #24870](https://github.com/microsoft/fluentui/pull/24870) by beachball)
|
|
18
|
+
|
|
19
|
+
## [9.0.0-beta.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-toolbar_v9.0.0-beta.6)
|
|
20
|
+
|
|
21
|
+
Thu, 15 Sep 2022 09:49:41 GMT
|
|
22
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-toolbar_v9.0.0-beta.5..@fluentui/react-toolbar_v9.0.0-beta.6)
|
|
23
|
+
|
|
24
|
+
### Changes
|
|
25
|
+
|
|
26
|
+
- chore: fix no-context-default-value lint violations ([PR #24276](https://github.com/microsoft/fluentui/pull/24276) by lingfangao@hotmail.com)
|
|
27
|
+
- chore: Update Griffel to latest version ([PR #24221](https://github.com/microsoft/fluentui/pull/24221) by olfedias@microsoft.com)
|
|
28
|
+
- Bump @fluentui/react-button to v9.1.1 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
|
29
|
+
- Bump @fluentui/react-divider to v9.0.5 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
|
30
|
+
- Bump @fluentui/react-theme to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
|
31
|
+
- Bump @fluentui/react-utilities to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
|
32
|
+
- Bump @fluentui/react-radio to v9.0.5 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
|
33
|
+
- Bump @fluentui/react-tabster to v9.1.1 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
|
34
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.13 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
|
35
|
+
|
|
7
36
|
## [9.0.0-beta.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-toolbar_v9.0.0-beta.5)
|
|
8
37
|
|
|
9
|
-
Wed, 03 Aug 2022 16:
|
|
38
|
+
Wed, 03 Aug 2022 16:04:08 GMT
|
|
10
39
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-toolbar_v9.0.0-beta.4..@fluentui/react-toolbar_v9.0.0-beta.5)
|
|
11
40
|
|
|
12
41
|
### Changes
|
|
13
42
|
|
|
14
43
|
- chore: Bump Griffel dependencies ([PR #24114](https://github.com/microsoft/fluentui/pull/24114) by miroslav.stastny@microsoft.com)
|
|
15
|
-
- Bump @fluentui/react-button to v9.1.0 ([PR #
|
|
16
|
-
- Bump @fluentui/react-divider to v9.0.4 ([PR #
|
|
17
|
-
- Bump @fluentui/react-radio to v9.0.4 ([PR #
|
|
18
|
-
- Bump @fluentui/react-tabster to v9.1.0 ([PR #
|
|
19
|
-
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.12 ([PR #
|
|
44
|
+
- Bump @fluentui/react-button to v9.1.0 ([PR #24131](https://github.com/microsoft/fluentui/pull/24131) by beachball)
|
|
45
|
+
- Bump @fluentui/react-divider to v9.0.4 ([PR #24131](https://github.com/microsoft/fluentui/pull/24131) by beachball)
|
|
46
|
+
- Bump @fluentui/react-radio to v9.0.4 ([PR #24131](https://github.com/microsoft/fluentui/pull/24131) by beachball)
|
|
47
|
+
- Bump @fluentui/react-tabster to v9.1.0 ([PR #24131](https://github.com/microsoft/fluentui/pull/24131) by beachball)
|
|
48
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.12 ([PR #24131](https://github.com/microsoft/fluentui/pull/24131) by beachball)
|
|
20
49
|
|
|
21
50
|
## [9.0.0-beta.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-toolbar_v9.0.0-beta.4)
|
|
22
51
|
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export declare type RadioGroupContextValues = {
|
|
|
29
29
|
*/
|
|
30
30
|
export declare const renderToolbar_unstable: (state: ToolbarState, contextValues: ToolbarContextValues) => JSX.Element;
|
|
31
31
|
|
|
32
|
+
declare type ToggableHandler = (e: React_2.MouseEvent | React_2.KeyboardEvent, name?: string, value?: string, checked?: boolean) => void;
|
|
33
|
+
|
|
32
34
|
/**
|
|
33
35
|
* Toolbar component
|
|
34
36
|
*/
|
|
@@ -52,10 +54,19 @@ export declare type ToolbarButtonProps = ComponentProps<ButtonSlots> & Partial<P
|
|
|
52
54
|
*/
|
|
53
55
|
export declare type ToolbarButtonState = ComponentState<Partial<ButtonSlots>> & ButtonState;
|
|
54
56
|
|
|
57
|
+
declare type ToolbarCheckedValueChangeData = {
|
|
58
|
+
/** The items for this value that are checked */
|
|
59
|
+
checkedItems: string[];
|
|
60
|
+
/** The name of the value */
|
|
61
|
+
name: string;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
declare type ToolbarCheckedValueChangeEvent = React_2.MouseEvent | React_2.KeyboardEvent;
|
|
65
|
+
|
|
55
66
|
export declare const toolbarClassNames: SlotClassNames<ToolbarSlots>;
|
|
56
67
|
|
|
57
|
-
export declare type ToolbarContextValue = {
|
|
58
|
-
|
|
68
|
+
export declare type ToolbarContextValue = Pick<ToolbarProps, 'size'> & {
|
|
69
|
+
handleToggleButton?: ToggableHandler;
|
|
59
70
|
};
|
|
60
71
|
|
|
61
72
|
export declare type ToolbarContextValues = {
|
|
@@ -87,6 +98,21 @@ export declare type ToolbarProps = ComponentProps<ToolbarSlots> & {
|
|
|
87
98
|
* @default medium
|
|
88
99
|
*/
|
|
89
100
|
size?: 'small' | 'medium';
|
|
101
|
+
/**
|
|
102
|
+
* Map of all checked values
|
|
103
|
+
*/
|
|
104
|
+
checkedValues?: Record<string, string[]>;
|
|
105
|
+
/**
|
|
106
|
+
* Default values to be checked on mount
|
|
107
|
+
*/
|
|
108
|
+
defaultCheckedValues?: Record<string, string[]>;
|
|
109
|
+
/**
|
|
110
|
+
* Callback when checked items change for value with a name
|
|
111
|
+
*
|
|
112
|
+
* @param event - React's original SyntheticEvent
|
|
113
|
+
* @param data - A data object with relevant information
|
|
114
|
+
*/
|
|
115
|
+
onCheckedValueChange?: (e: ToolbarCheckedValueChangeEvent, data: ToolbarCheckedValueChangeData) => void;
|
|
90
116
|
};
|
|
91
117
|
|
|
92
118
|
/**
|
|
@@ -131,7 +157,9 @@ export declare type ToolbarSlots = {
|
|
|
131
157
|
/**
|
|
132
158
|
* State used in rendering Toolbar
|
|
133
159
|
*/
|
|
134
|
-
export declare type ToolbarState = ComponentState<ToolbarSlots> & Required<Pick<ToolbarProps, 'size'
|
|
160
|
+
export declare type ToolbarState = ComponentState<ToolbarSlots> & Required<Pick<ToolbarProps, 'size' | 'checkedValues'>> & Pick<ToolbarProps, 'defaultCheckedValues' | 'onCheckedValueChange'> & {
|
|
161
|
+
handleToggleButton: ToggableHandler;
|
|
162
|
+
};
|
|
135
163
|
|
|
136
164
|
/**
|
|
137
165
|
* ToolbarToggleButton component
|
|
@@ -141,14 +169,17 @@ export declare const ToolbarToggleButton: ForwardRefComponent<ToolbarToggleButto
|
|
|
141
169
|
/**
|
|
142
170
|
* ToolbarToggleButton Props
|
|
143
171
|
*/
|
|
144
|
-
export declare type ToolbarToggleButtonProps = ComponentProps<ButtonSlots> & Partial<Pick<ToggleButtonProps, 'disabled' | 'disabledFocusable'>> & {
|
|
172
|
+
export declare type ToolbarToggleButtonProps = ComponentProps<ButtonSlots> & Partial<Pick<ToggleButtonProps, 'disabled' | 'disabledFocusable' | 'size'>> & {
|
|
145
173
|
appearance?: 'primary' | 'subtle';
|
|
146
174
|
};
|
|
147
175
|
|
|
148
176
|
/**
|
|
149
177
|
* State used in rendering ToolbarToggleButton
|
|
150
178
|
*/
|
|
151
|
-
export declare type ToolbarToggleButtonState = ComponentState<Partial<ButtonSlots>> & ToggleButtonState
|
|
179
|
+
export declare type ToolbarToggleButtonState = ComponentState<Partial<ButtonSlots>> & ToggleButtonState & Required<Pick<ToggleButtonProps, 'checked'>> & {
|
|
180
|
+
name?: string;
|
|
181
|
+
value?: string;
|
|
182
|
+
};
|
|
152
183
|
|
|
153
184
|
/**
|
|
154
185
|
* Create the state required to render Toolbar.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.types.js","sourceRoot":"../src/","sources":["components/Toolbar/Toolbar.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type ToolbarSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * Toolbar Props\n */\nexport type ToolbarProps = ComponentProps<ToolbarSlots> & {\n /**\n * Toolbar can have small or medium size\n *\n * @default medium\n */\n size?: 'small' | 'medium';\n};\n\n/**\n * State used in rendering Toolbar\n */\nexport type ToolbarState = ComponentState<ToolbarSlots>
|
|
1
|
+
{"version":3,"file":"Toolbar.types.js","sourceRoot":"../src/","sources":["components/Toolbar/Toolbar.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type ToolbarSlots = {\n root: Slot<'div'>;\n};\n\nexport type ToolbarCheckedValueChangeData = {\n /** The items for this value that are checked */\n checkedItems: string[];\n /** The name of the value */\n name: string;\n};\n\nexport type ToolbarCheckedValueChangeEvent = React.MouseEvent | React.KeyboardEvent;\n\n/**\n * Toolbar Props\n */\nexport type ToolbarProps = ComponentProps<ToolbarSlots> & {\n /**\n * Toolbar can have small or medium size\n *\n * @default medium\n */\n size?: 'small' | 'medium';\n\n /**\n * Map of all checked values\n */\n checkedValues?: Record<string, string[]>;\n\n /**\n * Default values to be checked on mount\n */\n defaultCheckedValues?: Record<string, string[]>;\n\n /**\n * Callback when checked items change for value with a name\n *\n * @param event - React's original SyntheticEvent\n * @param data - A data object with relevant information\n */\n onCheckedValueChange?: (e: ToolbarCheckedValueChangeEvent, data: ToolbarCheckedValueChangeData) => void;\n};\n\n/**\n * State used in rendering Toolbar\n */\nexport type ToolbarState = ComponentState<ToolbarSlots> &\n Required<Pick<ToolbarProps, 'size' | 'checkedValues'>> &\n Pick<ToolbarProps, 'defaultCheckedValues' | 'onCheckedValueChange'> & {\n /*\n * Toggles the state of a ToggleButton item\n */\n handleToggleButton: ToggableHandler;\n };\n\nexport type ToolbarContextValue = Pick<ToolbarProps, 'size'> & {\n handleToggleButton?: ToggableHandler;\n};\n\nexport type ToolbarContextValues = {\n toolbar: ToolbarContextValue;\n};\n\nexport type UninitializedToolbarState = Omit<ToolbarState, 'checkedValues' | 'handleToggleButton'> &\n Partial<Pick<ToolbarState, 'checkedValues'>>;\n\nexport type ToggableHandler = (\n e: React.MouseEvent | React.KeyboardEvent,\n name?: string,\n value?: string,\n checked?: boolean,\n) => void;\n"]}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export const ToolbarContext = /*#__PURE__*/React.createContext(undefined);
|
|
3
|
+
const toolbarContextDefaultValue = {
|
|
4
|
+
size: 'medium',
|
|
5
|
+
handleToggleButton: () => null
|
|
6
|
+
};
|
|
7
|
+
export const useToolbarContext = () => {
|
|
8
|
+
var _a;
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
export const useToolbarContext = () => React.useContext(ToolbarContext);
|
|
10
|
+
return (_a = React.useContext(ToolbarContext)) !== null && _a !== void 0 ? _a : toolbarContextDefaultValue;
|
|
11
|
+
};
|
|
7
12
|
//# sourceMappingURL=ToolbarContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/Toolbar/ToolbarContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB,
|
|
1
|
+
{"version":3,"sources":["components/Toolbar/ToolbarContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAGA,OAAO,MAAM,cAAc,gBAAG,KAAK,CAAC,aAAN,CAC5B,SAD4B,CAAvB;AAIP,MAAM,0BAA0B,GAAG;EACjC,IAAI,EAAE,QAD2B;EAEjC,kBAAkB,EAAE,MAAM;AAFO,CAAnC;AAKA,OAAO,MAAM,iBAAiB,GAAG,MAAK;EAAA,IAAA,EAAA;;EAAC,OAAA,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,CAAiB,cAAjB,CAAA,MAAgC,IAAhC,IAAgC,EAAA,KAAA,KAAA,CAAhC,GAAgC,EAAhC,GAAoC,0BAApC;AAA8D,CAA9F","sourcesContent":["import * as React from 'react';\nimport type { ToolbarContextValue } from './Toolbar.types';\n\nexport const ToolbarContext = React.createContext<ToolbarContextValue | undefined>(\n undefined,\n) as React.Context<ToolbarContextValue>;\n\nconst toolbarContextDefaultValue = {\n size: 'medium' as 'medium',\n handleToggleButton: () => null,\n};\n\nexport const useToolbarContext = () => React.useContext(ToolbarContext) ?? toolbarContextDefaultValue;\n"],"sourceRoot":"../src/"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useEventCallback, useControllableState } from '@fluentui/react-utilities';
|
|
1
2
|
import { getNativeElementProps } from '@fluentui/react-utilities';
|
|
2
3
|
import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
3
4
|
/**
|
|
@@ -11,14 +12,14 @@ import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
export const useToolbar_unstable = (props, ref) => {
|
|
15
|
+
const {
|
|
16
|
+
size = 'medium'
|
|
17
|
+
} = props;
|
|
14
18
|
const arrowNavigationProps = useArrowNavigationGroup({
|
|
15
19
|
circular: true,
|
|
16
20
|
axis: 'horizontal'
|
|
17
21
|
});
|
|
18
|
-
const {
|
|
19
|
-
size = 'medium'
|
|
20
|
-
} = props;
|
|
21
|
-
return {
|
|
22
|
+
const initialState = {
|
|
22
23
|
size,
|
|
23
24
|
// TODO add appropriate props/defaults
|
|
24
25
|
components: {
|
|
@@ -28,11 +29,43 @@ export const useToolbar_unstable = (props, ref) => {
|
|
|
28
29
|
// TODO add appropriate slots, for example:
|
|
29
30
|
// mySlot: resolveShorthand(props.mySlot),
|
|
30
31
|
root: getNativeElementProps('div', {
|
|
32
|
+
role: 'toolbar',
|
|
31
33
|
ref,
|
|
32
34
|
...arrowNavigationProps,
|
|
33
35
|
...props
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
const [checkedValues, setCheckedValues] = useControllableState({
|
|
39
|
+
state: initialState.checkedValues,
|
|
40
|
+
defaultState: initialState.defaultCheckedValues,
|
|
41
|
+
initialState: {}
|
|
42
|
+
});
|
|
43
|
+
const {
|
|
44
|
+
onCheckedValueChange
|
|
45
|
+
} = initialState;
|
|
46
|
+
const handleToggleButton = useEventCallback((e, name, value, checked) => {
|
|
47
|
+
if (name && value) {
|
|
48
|
+
const checkedItems = (checkedValues === null || checkedValues === void 0 ? void 0 : checkedValues[name]) || [];
|
|
49
|
+
const newCheckedItems = [...checkedItems];
|
|
50
|
+
|
|
51
|
+
if (checked) {
|
|
52
|
+
newCheckedItems.splice(newCheckedItems.indexOf(value), 1);
|
|
53
|
+
} else {
|
|
54
|
+
newCheckedItems.push(value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
onCheckedValueChange === null || onCheckedValueChange === void 0 ? void 0 : onCheckedValueChange(e, {
|
|
58
|
+
name,
|
|
59
|
+
checkedItems: newCheckedItems
|
|
60
|
+
});
|
|
61
|
+
setCheckedValues(s => ({ ...s,
|
|
62
|
+
[name]: newCheckedItems
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return { ...initialState,
|
|
67
|
+
handleToggleButton,
|
|
68
|
+
checkedValues: checkedValues !== null && checkedValues !== void 0 ? checkedValues : {}
|
|
36
69
|
};
|
|
37
70
|
};
|
|
38
71
|
//# sourceMappingURL=useToolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/Toolbar/useToolbar.ts"],"names":[],"mappings":"AACA,SAAS,qBAAT,QAAsC,2BAAtC;AAEA,SAAS,uBAAT,QAAwC,yBAAxC;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,mBAAmB,GAAG,CAAC,KAAD,EAAsB,GAAtB,KAAmE;EACpG,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;IACnD,QAAQ,EAAE,IADyC;IAEnD,IAAI,EAAE;EAF6C,CAAD,CAApD;EAKA,MAAM
|
|
1
|
+
{"version":3,"sources":["components/Toolbar/useToolbar.ts"],"names":[],"mappings":"AACA,SAAS,gBAAT,EAA2B,oBAA3B,QAAuD,2BAAvD;AACA,SAAS,qBAAT,QAAsC,2BAAtC;AAEA,SAAS,uBAAT,QAAwC,yBAAxC;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,mBAAmB,GAAG,CAAC,KAAD,EAAsB,GAAtB,KAAmE;EACpG,MAAM;IAAE,IAAI,GAAG;EAAT,IAAsB,KAA5B;EAEA,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;IACnD,QAAQ,EAAE,IADyC;IAEnD,IAAI,EAAE;EAF6C,CAAD,CAApD;EAKA,MAAM,YAAY,GAA8B;IAC9C,IAD8C;IAG9C;IACA,UAAU,EAAE;MACV;MACA,IAAI,EAAE;IAFI,CAJkC;IAQ9C;IACA;IACA,IAAI,EAAE,qBAAqB,CAAC,KAAD,EAAQ;MACjC,IAAI,EAAE,SAD2B;MAEjC,GAFiC;MAGjC,GAAG,oBAH8B;MAIjC,GAAG;IAJ8B,CAAR;EAVmB,CAAhD;EAkBA,MAAM,CAAC,aAAD,EAAgB,gBAAhB,IAAoC,oBAAoB,CAAC;IAC7D,KAAK,EAAE,YAAY,CAAC,aADyC;IAE7D,YAAY,EAAE,YAAY,CAAC,oBAFkC;IAG7D,YAAY,EAAE;EAH+C,CAAD,CAA9D;EAMA,MAAM;IAAE;EAAF,IAA2B,YAAjC;EAEA,MAAM,kBAAkB,GAAoB,gBAAgB,CAC1D,CAAC,CAAD,EAA4C,IAA5C,EAA2D,KAA3D,EAA2E,OAA3E,KAAgG;IAC9F,IAAI,IAAI,IAAI,KAAZ,EAAmB;MACjB,MAAM,YAAY,GAAG,CAAA,aAAa,KAAA,IAAb,IAAA,aAAa,KAAA,KAAA,CAAb,GAAa,KAAA,CAAb,GAAA,aAAa,CAAG,IAAH,CAAb,KAAyB,EAA9C;MACA,MAAM,eAAe,GAAG,CAAC,GAAG,YAAJ,CAAxB;;MACA,IAAI,OAAJ,EAAa;QACX,eAAe,CAAC,MAAhB,CAAuB,eAAe,CAAC,OAAhB,CAAwB,KAAxB,CAAvB,EAAuD,CAAvD;MACD,CAFD,MAEO;QACL,eAAe,CAAC,IAAhB,CAAqB,KAArB;MACD;;MAED,oBAAoB,KAAA,IAApB,IAAA,oBAAoB,KAAA,KAAA,CAApB,GAAoB,KAAA,CAApB,GAAA,oBAAoB,CAAG,CAAH,EAAM;QAAE,IAAF;QAAQ,YAAY,EAAE;MAAtB,CAAN,CAApB;MACA,gBAAgB,CAAC,CAAC,KAAK,EAAE,GAAG,CAAL;QAAQ,CAAC,IAAD,GAAQ;MAAhB,CAAL,CAAF,CAAhB;IACD;EACF,CAdyD,CAA5D;EAiBA,OAAO,EACL,GAAG,YADE;IAEL,kBAFK;IAGL,aAAa,EAAE,aAAa,KAAA,IAAb,IAAA,aAAa,KAAA,KAAA,CAAb,GAAA,aAAA,GAAiB;EAH3B,CAAP;AAKD,CAxDM","sourcesContent":["import * as React from 'react';\nimport { useEventCallback, useControllableState } from '@fluentui/react-utilities';\nimport { getNativeElementProps } from '@fluentui/react-utilities';\nimport type { ToggableHandler, ToolbarProps, ToolbarState, UninitializedToolbarState } from './Toolbar.types';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\n\n/**\n * Create the state required to render Toolbar.\n *\n * The returned state can be modified with hooks such as useToolbarStyles_unstable,\n * before being passed to renderToolbar_unstable.\n *\n * @param props - props from this instance of Toolbar\n * @param ref - reference to root HTMLElement of Toolbar\n */\nexport const useToolbar_unstable = (props: ToolbarProps, ref: React.Ref<HTMLElement>): ToolbarState => {\n const { size = 'medium' } = props;\n\n const arrowNavigationProps = useArrowNavigationGroup({\n circular: true,\n axis: 'horizontal',\n });\n\n const initialState: UninitializedToolbarState = {\n size,\n\n // TODO add appropriate props/defaults\n components: {\n // TODO add each slot's element type or component\n root: 'div',\n },\n // TODO add appropriate slots, for example:\n // mySlot: resolveShorthand(props.mySlot),\n root: getNativeElementProps('div', {\n role: 'toolbar',\n ref,\n ...arrowNavigationProps,\n ...props,\n }),\n };\n\n const [checkedValues, setCheckedValues] = useControllableState({\n state: initialState.checkedValues,\n defaultState: initialState.defaultCheckedValues,\n initialState: {},\n });\n\n const { onCheckedValueChange } = initialState;\n\n const handleToggleButton: ToggableHandler = useEventCallback(\n (e: React.MouseEvent | React.KeyboardEvent, name?: string, value?: string, checked?: boolean) => {\n if (name && value) {\n const checkedItems = checkedValues?.[name] || [];\n const newCheckedItems = [...checkedItems];\n if (checked) {\n newCheckedItems.splice(newCheckedItems.indexOf(value), 1);\n } else {\n newCheckedItems.push(value);\n }\n\n onCheckedValueChange?.(e, { name, checkedItems: newCheckedItems });\n setCheckedValues(s => ({ ...s, [name]: newCheckedItems }));\n }\n },\n );\n\n return {\n ...initialState,\n handleToggleButton,\n checkedValues: checkedValues ?? {},\n };\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export function useToolbarContextValues_unstable(state) {
|
|
2
2
|
const {
|
|
3
|
-
size
|
|
3
|
+
size,
|
|
4
|
+
handleToggleButton
|
|
4
5
|
} = state; // This context is created with "@fluentui/react-context-selector", these is no sense to memoize it
|
|
5
6
|
|
|
6
7
|
const toolbar = {
|
|
7
|
-
size
|
|
8
|
+
size,
|
|
9
|
+
handleToggleButton
|
|
8
10
|
};
|
|
9
11
|
return {
|
|
10
12
|
toolbar
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/Toolbar/useToolbarContextValues.tsx"],"names":[],"mappings":"AAEA,OAAM,SAAU,gCAAV,CAA2C,KAA3C,EAA8D;EAClE,MAAM;IAAE;
|
|
1
|
+
{"version":3,"sources":["components/Toolbar/useToolbarContextValues.tsx"],"names":[],"mappings":"AAEA,OAAM,SAAU,gCAAV,CAA2C,KAA3C,EAA8D;EAClE,MAAM;IAAE,IAAF;IAAQ;EAAR,IAA+B,KAArC,CADkE,CAElE;;EACA,MAAM,OAAO,GAAwB;IACnC,IADmC;IAEnC;EAFmC,CAArC;EAKA,OAAO;IAAE;EAAF,CAAP;AACD","sourcesContent":["import type { ToolbarContextValue, ToolbarContextValues, ToolbarState } from './Toolbar.types';\n\nexport function useToolbarContextValues_unstable(state: ToolbarState): ToolbarContextValues {\n const { size, handleToggleButton } = state;\n // This context is created with \"@fluentui/react-context-selector\", these is no sense to memoize it\n const toolbar: ToolbarContextValue = {\n size,\n handleToggleButton,\n };\n\n return { toolbar };\n}\n"],"sourceRoot":"../src/"}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { renderToggleButton_unstable, useToggleButtonStyles_unstable
|
|
3
|
-
import {
|
|
2
|
+
import { renderToggleButton_unstable, useToggleButtonStyles_unstable } from '@fluentui/react-button';
|
|
3
|
+
import { useToolbarToggleButton_unstable } from './useToolbarToggleButton';
|
|
4
4
|
/**
|
|
5
5
|
* ToolbarToggleButton component
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
export const ToolbarToggleButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
9
|
-
const
|
|
10
|
-
size
|
|
11
|
-
} = useToolbarContext();
|
|
12
|
-
const state = useToggleButton_unstable({
|
|
13
|
-
size,
|
|
14
|
-
...props
|
|
15
|
-
}, ref);
|
|
9
|
+
const state = useToolbarToggleButton_unstable(props, ref);
|
|
16
10
|
useToggleButtonStyles_unstable(state);
|
|
17
11
|
return renderToggleButton_unstable(state);
|
|
18
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/ToolbarToggleButton/ToolbarToggleButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAGA,
|
|
1
|
+
{"version":3,"sources":["components/ToolbarToggleButton/ToolbarToggleButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAGA,SAAS,2BAAT,EAAsC,8BAAtC,QAA4E,wBAA5E;AACA,SAAS,+BAAT,QAAgD,0BAAhD;AAEA;;AAEG;;AACH,OAAO,MAAM,mBAAmB,gBAAkD,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;EAChH,MAAM,KAAK,GAAG,+BAA+B,CAAC,KAAD,EAAQ,GAAR,CAA7C;EAEA,8BAA8B,CAAC,KAAD,CAA9B;EACA,OAAO,2BAA2B,CAAC,KAAD,CAAlC;AACD,CALiF,CAA3E;AAOP,mBAAmB,CAAC,WAApB,GAAkC,qBAAlC","sourcesContent":["import * as React from 'react';\nimport type { ToolbarToggleButtonProps } from './ToolbarToggleButton.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { renderToggleButton_unstable, useToggleButtonStyles_unstable } from '@fluentui/react-button';\nimport { useToolbarToggleButton_unstable } from './useToolbarToggleButton';\n\n/**\n * ToolbarToggleButton component\n */\nexport const ToolbarToggleButton: ForwardRefComponent<ToolbarToggleButtonProps> = React.forwardRef((props, ref) => {\n const state = useToolbarToggleButton_unstable(props, ref);\n\n useToggleButtonStyles_unstable(state);\n return renderToggleButton_unstable(state);\n}) as ForwardRefComponent<ToolbarToggleButtonProps>;\n\nToolbarToggleButton.displayName = 'ToolbarToggleButton';\n"],"sourceRoot":"../src/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarToggleButton.types.js","sourceRoot":"../src/","sources":["components/ToolbarToggleButton/ToolbarToggleButton.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState } from '@fluentui/react-utilities';\nimport { ToggleButtonProps, ButtonSlots, ToggleButtonState } from '@fluentui/react-button';\n\n/**\n * ToolbarToggleButton Props\n */\nexport type ToolbarToggleButtonProps = ComponentProps<ButtonSlots> &\n Partial<Pick<ToggleButtonProps, 'disabled' | 'disabledFocusable'>> & {\n appearance?: 'primary' | 'subtle';\n };\n\n/**\n * State used in rendering ToolbarToggleButton\n */\nexport type ToolbarToggleButtonState = ComponentState<Partial<ButtonSlots>> &
|
|
1
|
+
{"version":3,"file":"ToolbarToggleButton.types.js","sourceRoot":"../src/","sources":["components/ToolbarToggleButton/ToolbarToggleButton.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState } from '@fluentui/react-utilities';\nimport { ToggleButtonProps, ButtonSlots, ToggleButtonState } from '@fluentui/react-button';\n\n/**\n * ToolbarToggleButton Props\n */\nexport type ToolbarToggleButtonProps = ComponentProps<ButtonSlots> &\n Partial<Pick<ToggleButtonProps, 'disabled' | 'disabledFocusable' | 'size'>> & {\n appearance?: 'primary' | 'subtle';\n };\n\n/**\n * State used in rendering ToolbarToggleButton\n */\nexport type ToolbarToggleButtonState = ComponentState<Partial<ButtonSlots>> &\n ToggleButtonState &\n Required<Pick<ToggleButtonProps, 'checked'>> & {\n name?: string;\n value?: string;\n };\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useToggleButton_unstable } from '@fluentui/react-button';
|
|
2
|
+
import { useToolbarContext } from '../Toolbar/ToolbarContext';
|
|
3
|
+
/**
|
|
4
|
+
* Given user props, defines default props for the ToggleButton, calls useButtonState and useChecked, and returns
|
|
5
|
+
* processed state.
|
|
6
|
+
* @param props - User provided props to the ToggleButton component.
|
|
7
|
+
* @param ref - User provided ref to be passed to the ToggleButton component.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const useToolbarToggleButton_unstable = (props, ref) => {
|
|
11
|
+
const {
|
|
12
|
+
handleToggleButton,
|
|
13
|
+
size
|
|
14
|
+
} = useToolbarContext();
|
|
15
|
+
const {
|
|
16
|
+
onClick: onClickOriginal
|
|
17
|
+
} = props;
|
|
18
|
+
const state = useToggleButton_unstable({
|
|
19
|
+
size,
|
|
20
|
+
...props
|
|
21
|
+
}, ref);
|
|
22
|
+
|
|
23
|
+
const handleOnClick = e => {
|
|
24
|
+
if (state.disabled) {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
e.stopPropagation();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
handleToggleButton === null || handleToggleButton === void 0 ? void 0 : handleToggleButton(e, state.name, state.value, state.checked);
|
|
31
|
+
onClickOriginal === null || onClickOriginal === void 0 ? void 0 : onClickOriginal(e);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
state.root.onClick = handleOnClick;
|
|
35
|
+
return state;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=useToolbarToggleButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/ToolbarToggleButton/useToolbarToggleButton.ts"],"names":[],"mappings":"AACA,SAAS,wBAAT,QAAyC,wBAAzC;AACA,SAAS,iBAAT,QAAkC,2BAAlC;AAGA;;;;;AAKG;;AACH,OAAO,MAAM,+BAA+B,GAAG,CAC7C,KAD6C,EAE7C,GAF6C,KAGjB;EAC5B,MAAM;IAAE,kBAAF;IAAsB;EAAtB,IAA+B,iBAAiB,EAAtD;EACA,MAAM;IAAE,OAAO,EAAE;EAAX,IAA+B,KAArC;EACA,MAAM,KAAK,GAAG,wBAAwB,CAAC;IAAE,IAAF;IAAQ,GAAG;EAAX,CAAD,EAAqB,GAArB,CAAtC;;EAEA,MAAM,aAAa,GACjB,CADoB,IAElB;IACF,IAAI,KAAK,CAAC,QAAV,EAAoB;MAClB,CAAC,CAAC,cAAF;MACA,CAAC,CAAC,eAAF;MACA;IACD;;IAED,kBAAkB,KAAA,IAAlB,IAAA,kBAAkB,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAA,kBAAkB,CAAG,CAAH,EAAM,KAAK,CAAC,IAAZ,EAAkB,KAAK,CAAC,KAAxB,EAA+B,KAAK,CAAC,OAArC,CAAlB;IACA,eAAe,KAAA,IAAf,IAAA,eAAe,KAAA,KAAA,CAAf,GAAe,KAAA,CAAf,GAAA,eAAe,CAAG,CAAH,CAAf;EACD,CAXD;;EAaA,KAAK,CAAC,IAAN,CAAW,OAAX,GAAqB,aAArB;EACA,OAAO,KAAP;AACD,CAvBM","sourcesContent":["import * as React from 'react';\nimport { useToggleButton_unstable } from '@fluentui/react-button';\nimport { useToolbarContext } from '../Toolbar/ToolbarContext';\nimport { ToolbarToggleButtonProps, ToolbarToggleButtonState } from './ToolbarToggleButton.types';\n\n/**\n * Given user props, defines default props for the ToggleButton, calls useButtonState and useChecked, and returns\n * processed state.\n * @param props - User provided props to the ToggleButton component.\n * @param ref - User provided ref to be passed to the ToggleButton component.\n */\nexport const useToolbarToggleButton_unstable = (\n props: ToolbarToggleButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,\n): ToolbarToggleButtonState => {\n const { handleToggleButton, size } = useToolbarContext();\n const { onClick: onClickOriginal } = props;\n const state = useToggleButton_unstable({ size, ...props }, ref) as ToolbarToggleButtonState;\n\n const handleOnClick = (\n e: React.MouseEvent<HTMLButtonElement, MouseEvent> & React.MouseEvent<HTMLAnchorElement, MouseEvent>,\n ) => {\n if (state.disabled) {\n e.preventDefault();\n e.stopPropagation();\n return;\n }\n\n handleToggleButton?.(e, state.name, state.value, state.checked);\n onClickOriginal?.(e);\n };\n\n state.root.onClick = handleOnClick;\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -5,14 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useToolbarContext = exports.ToolbarContext = void 0;
|
|
7
7
|
|
|
8
|
-
const React = /*#__PURE__*/require("react");
|
|
8
|
+
const React = /*#__PURE__*/require("react");
|
|
9
9
|
|
|
10
|
+
exports.ToolbarContext = /*#__PURE__*/React.createContext(undefined);
|
|
11
|
+
const toolbarContextDefaultValue = {
|
|
12
|
+
size: 'medium',
|
|
13
|
+
handleToggleButton: () => null
|
|
14
|
+
};
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
16
|
+
const useToolbarContext = () => {
|
|
17
|
+
var _a;
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
return (_a = React.useContext(exports.ToolbarContext)) !== null && _a !== void 0 ? _a : toolbarContextDefaultValue;
|
|
20
|
+
};
|
|
16
21
|
|
|
17
22
|
exports.useToolbarContext = useToolbarContext;
|
|
18
23
|
//# sourceMappingURL=ToolbarContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/Toolbar/ToolbarContext.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA,
|
|
1
|
+
{"version":3,"sources":["components/Toolbar/ToolbarContext.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAGa,OAAA,CAAA,cAAA,gBAAiB,KAAK,CAAC,aAAN,CAC5B,SAD4B,CAAjB;AAIb,MAAM,0BAA0B,GAAG;EACjC,IAAI,EAAE,QAD2B;EAEjC,kBAAkB,EAAE,MAAM;AAFO,CAAnC;;AAKO,MAAM,iBAAiB,GAAG,MAAK;EAAA,IAAA,EAAA;;EAAC,OAAA,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,CAAiB,OAAA,CAAA,cAAjB,CAAA,MAAgC,IAAhC,IAAgC,EAAA,KAAA,KAAA,CAAhC,GAAgC,EAAhC,GAAoC,0BAApC;AAA8D,CAA9F;;AAAM,OAAA,CAAA,iBAAA,GAAiB,iBAAjB","sourcesContent":["import * as React from 'react';\nimport type { ToolbarContextValue } from './Toolbar.types';\n\nexport const ToolbarContext = React.createContext<ToolbarContextValue | undefined>(\n undefined,\n) as React.Context<ToolbarContextValue>;\n\nconst toolbarContextDefaultValue = {\n size: 'medium' as 'medium',\n handleToggleButton: () => null,\n};\n\nexport const useToolbarContext = () => React.useContext(ToolbarContext) ?? toolbarContextDefaultValue;\n"],"sourceRoot":"../src/"}
|
|
@@ -7,6 +7,8 @@ exports.useToolbar_unstable = void 0;
|
|
|
7
7
|
|
|
8
8
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
9
9
|
|
|
10
|
+
const react_utilities_2 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
11
|
+
|
|
10
12
|
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
|
11
13
|
/**
|
|
12
14
|
* Create the state required to render Toolbar.
|
|
@@ -20,14 +22,14 @@ const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
const useToolbar_unstable = (props, ref) => {
|
|
25
|
+
const {
|
|
26
|
+
size = 'medium'
|
|
27
|
+
} = props;
|
|
23
28
|
const arrowNavigationProps = react_tabster_1.useArrowNavigationGroup({
|
|
24
29
|
circular: true,
|
|
25
30
|
axis: 'horizontal'
|
|
26
31
|
});
|
|
27
|
-
const {
|
|
28
|
-
size = 'medium'
|
|
29
|
-
} = props;
|
|
30
|
-
return {
|
|
32
|
+
const initialState = {
|
|
31
33
|
size,
|
|
32
34
|
// TODO add appropriate props/defaults
|
|
33
35
|
components: {
|
|
@@ -36,12 +38,44 @@ const useToolbar_unstable = (props, ref) => {
|
|
|
36
38
|
},
|
|
37
39
|
// TODO add appropriate slots, for example:
|
|
38
40
|
// mySlot: resolveShorthand(props.mySlot),
|
|
39
|
-
root:
|
|
41
|
+
root: react_utilities_2.getNativeElementProps('div', {
|
|
42
|
+
role: 'toolbar',
|
|
40
43
|
ref,
|
|
41
44
|
...arrowNavigationProps,
|
|
42
45
|
...props
|
|
43
|
-
})
|
|
44
|
-
|
|
46
|
+
})
|
|
47
|
+
};
|
|
48
|
+
const [checkedValues, setCheckedValues] = react_utilities_1.useControllableState({
|
|
49
|
+
state: initialState.checkedValues,
|
|
50
|
+
defaultState: initialState.defaultCheckedValues,
|
|
51
|
+
initialState: {}
|
|
52
|
+
});
|
|
53
|
+
const {
|
|
54
|
+
onCheckedValueChange
|
|
55
|
+
} = initialState;
|
|
56
|
+
const handleToggleButton = react_utilities_1.useEventCallback((e, name, value, checked) => {
|
|
57
|
+
if (name && value) {
|
|
58
|
+
const checkedItems = (checkedValues === null || checkedValues === void 0 ? void 0 : checkedValues[name]) || [];
|
|
59
|
+
const newCheckedItems = [...checkedItems];
|
|
60
|
+
|
|
61
|
+
if (checked) {
|
|
62
|
+
newCheckedItems.splice(newCheckedItems.indexOf(value), 1);
|
|
63
|
+
} else {
|
|
64
|
+
newCheckedItems.push(value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
onCheckedValueChange === null || onCheckedValueChange === void 0 ? void 0 : onCheckedValueChange(e, {
|
|
68
|
+
name,
|
|
69
|
+
checkedItems: newCheckedItems
|
|
70
|
+
});
|
|
71
|
+
setCheckedValues(s => ({ ...s,
|
|
72
|
+
[name]: newCheckedItems
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return { ...initialState,
|
|
77
|
+
handleToggleButton,
|
|
78
|
+
checkedValues: checkedValues !== null && checkedValues !== void 0 ? checkedValues : {}
|
|
45
79
|
};
|
|
46
80
|
};
|
|
47
81
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/Toolbar/useToolbar.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAEA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;AAEA;;;;;;;;AAQG;;;AACI,MAAM,mBAAmB,GAAG,CAAC,KAAD,EAAsB,GAAtB,KAAmE;EACpG,MAAM,oBAAoB,GAAG,eAAA,CAAA,uBAAA,CAAwB;IACnD,QAAQ,EAAE,IADyC;IAEnD,IAAI,EAAE;EAF6C,CAAxB,CAA7B;EAKA,MAAM
|
|
1
|
+
{"version":3,"sources":["components/Toolbar/useToolbar.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAEA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;AAEA;;;;;;;;AAQG;;;AACI,MAAM,mBAAmB,GAAG,CAAC,KAAD,EAAsB,GAAtB,KAAmE;EACpG,MAAM;IAAE,IAAI,GAAG;EAAT,IAAsB,KAA5B;EAEA,MAAM,oBAAoB,GAAG,eAAA,CAAA,uBAAA,CAAwB;IACnD,QAAQ,EAAE,IADyC;IAEnD,IAAI,EAAE;EAF6C,CAAxB,CAA7B;EAKA,MAAM,YAAY,GAA8B;IAC9C,IAD8C;IAG9C;IACA,UAAU,EAAE;MACV;MACA,IAAI,EAAE;IAFI,CAJkC;IAQ9C;IACA;IACA,IAAI,EAAE,iBAAA,CAAA,qBAAA,CAAsB,KAAtB,EAA6B;MACjC,IAAI,EAAE,SAD2B;MAEjC,GAFiC;MAGjC,GAAG,oBAH8B;MAIjC,GAAG;IAJ8B,CAA7B;EAVwC,CAAhD;EAkBA,MAAM,CAAC,aAAD,EAAgB,gBAAhB,IAAoC,iBAAA,CAAA,oBAAA,CAAqB;IAC7D,KAAK,EAAE,YAAY,CAAC,aADyC;IAE7D,YAAY,EAAE,YAAY,CAAC,oBAFkC;IAG7D,YAAY,EAAE;EAH+C,CAArB,CAA1C;EAMA,MAAM;IAAE;EAAF,IAA2B,YAAjC;EAEA,MAAM,kBAAkB,GAAoB,iBAAA,CAAA,gBAAA,CAC1C,CAAC,CAAD,EAA4C,IAA5C,EAA2D,KAA3D,EAA2E,OAA3E,KAAgG;IAC9F,IAAI,IAAI,IAAI,KAAZ,EAAmB;MACjB,MAAM,YAAY,GAAG,CAAA,aAAa,KAAA,IAAb,IAAA,aAAa,KAAA,KAAA,CAAb,GAAa,KAAA,CAAb,GAAA,aAAa,CAAG,IAAH,CAAb,KAAyB,EAA9C;MACA,MAAM,eAAe,GAAG,CAAC,GAAG,YAAJ,CAAxB;;MACA,IAAI,OAAJ,EAAa;QACX,eAAe,CAAC,MAAhB,CAAuB,eAAe,CAAC,OAAhB,CAAwB,KAAxB,CAAvB,EAAuD,CAAvD;MACD,CAFD,MAEO;QACL,eAAe,CAAC,IAAhB,CAAqB,KAArB;MACD;;MAED,oBAAoB,KAAA,IAApB,IAAA,oBAAoB,KAAA,KAAA,CAApB,GAAoB,KAAA,CAApB,GAAA,oBAAoB,CAAG,CAAH,EAAM;QAAE,IAAF;QAAQ,YAAY,EAAE;MAAtB,CAAN,CAApB;MACA,gBAAgB,CAAC,CAAC,KAAK,EAAE,GAAG,CAAL;QAAQ,CAAC,IAAD,GAAQ;MAAhB,CAAL,CAAF,CAAhB;IACD;EACF,CAdyC,CAA5C;EAiBA,OAAO,EACL,GAAG,YADE;IAEL,kBAFK;IAGL,aAAa,EAAE,aAAa,KAAA,IAAb,IAAA,aAAa,KAAA,KAAA,CAAb,GAAA,aAAA,GAAiB;EAH3B,CAAP;AAKD,CAxDM;;AAAM,OAAA,CAAA,mBAAA,GAAmB,mBAAnB","sourcesContent":["import * as React from 'react';\nimport { useEventCallback, useControllableState } from '@fluentui/react-utilities';\nimport { getNativeElementProps } from '@fluentui/react-utilities';\nimport type { ToggableHandler, ToolbarProps, ToolbarState, UninitializedToolbarState } from './Toolbar.types';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\n\n/**\n * Create the state required to render Toolbar.\n *\n * The returned state can be modified with hooks such as useToolbarStyles_unstable,\n * before being passed to renderToolbar_unstable.\n *\n * @param props - props from this instance of Toolbar\n * @param ref - reference to root HTMLElement of Toolbar\n */\nexport const useToolbar_unstable = (props: ToolbarProps, ref: React.Ref<HTMLElement>): ToolbarState => {\n const { size = 'medium' } = props;\n\n const arrowNavigationProps = useArrowNavigationGroup({\n circular: true,\n axis: 'horizontal',\n });\n\n const initialState: UninitializedToolbarState = {\n size,\n\n // TODO add appropriate props/defaults\n components: {\n // TODO add each slot's element type or component\n root: 'div',\n },\n // TODO add appropriate slots, for example:\n // mySlot: resolveShorthand(props.mySlot),\n root: getNativeElementProps('div', {\n role: 'toolbar',\n ref,\n ...arrowNavigationProps,\n ...props,\n }),\n };\n\n const [checkedValues, setCheckedValues] = useControllableState({\n state: initialState.checkedValues,\n defaultState: initialState.defaultCheckedValues,\n initialState: {},\n });\n\n const { onCheckedValueChange } = initialState;\n\n const handleToggleButton: ToggableHandler = useEventCallback(\n (e: React.MouseEvent | React.KeyboardEvent, name?: string, value?: string, checked?: boolean) => {\n if (name && value) {\n const checkedItems = checkedValues?.[name] || [];\n const newCheckedItems = [...checkedItems];\n if (checked) {\n newCheckedItems.splice(newCheckedItems.indexOf(value), 1);\n } else {\n newCheckedItems.push(value);\n }\n\n onCheckedValueChange?.(e, { name, checkedItems: newCheckedItems });\n setCheckedValues(s => ({ ...s, [name]: newCheckedItems }));\n }\n },\n );\n\n return {\n ...initialState,\n handleToggleButton,\n checkedValues: checkedValues ?? {},\n };\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -7,11 +7,13 @@ exports.useToolbarContextValues_unstable = void 0;
|
|
|
7
7
|
|
|
8
8
|
function useToolbarContextValues_unstable(state) {
|
|
9
9
|
const {
|
|
10
|
-
size
|
|
10
|
+
size,
|
|
11
|
+
handleToggleButton
|
|
11
12
|
} = state; // This context is created with "@fluentui/react-context-selector", these is no sense to memoize it
|
|
12
13
|
|
|
13
14
|
const toolbar = {
|
|
14
|
-
size
|
|
15
|
+
size,
|
|
16
|
+
handleToggleButton
|
|
15
17
|
};
|
|
16
18
|
return {
|
|
17
19
|
toolbar
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/Toolbar/useToolbarContextValues.tsx"],"names":[],"mappings":";;;;;;;AAEA,SAAgB,gCAAhB,CAAiD,KAAjD,EAAoE;EAClE,MAAM;IAAE;
|
|
1
|
+
{"version":3,"sources":["components/Toolbar/useToolbarContextValues.tsx"],"names":[],"mappings":";;;;;;;AAEA,SAAgB,gCAAhB,CAAiD,KAAjD,EAAoE;EAClE,MAAM;IAAE,IAAF;IAAQ;EAAR,IAA+B,KAArC,CADkE,CAElE;;EACA,MAAM,OAAO,GAAwB;IACnC,IADmC;IAEnC;EAFmC,CAArC;EAKA,OAAO;IAAE;EAAF,CAAP;AACD;;AATD,OAAA,CAAA,gCAAA,GAAA,gCAAA","sourcesContent":["import type { ToolbarContextValue, ToolbarContextValues, ToolbarState } from './Toolbar.types';\n\nexport function useToolbarContextValues_unstable(state: ToolbarState): ToolbarContextValues {\n const { size, handleToggleButton } = state;\n // This context is created with \"@fluentui/react-context-selector\", these is no sense to memoize it\n const toolbar: ToolbarContextValue = {\n size,\n handleToggleButton,\n };\n\n return { toolbar };\n}\n"],"sourceRoot":"../src/"}
|
|
@@ -9,20 +9,14 @@ const React = /*#__PURE__*/require("react");
|
|
|
9
9
|
|
|
10
10
|
const react_button_1 = /*#__PURE__*/require("@fluentui/react-button");
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const useToolbarToggleButton_1 = /*#__PURE__*/require("./useToolbarToggleButton");
|
|
13
13
|
/**
|
|
14
14
|
* ToolbarToggleButton component
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
exports.ToolbarToggleButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
19
|
-
const
|
|
20
|
-
size
|
|
21
|
-
} = ToolbarContext_1.useToolbarContext();
|
|
22
|
-
const state = react_button_1.useToggleButton_unstable({
|
|
23
|
-
size,
|
|
24
|
-
...props
|
|
25
|
-
}, ref);
|
|
19
|
+
const state = useToolbarToggleButton_1.useToolbarToggleButton_unstable(props, ref);
|
|
26
20
|
react_button_1.useToggleButtonStyles_unstable(state);
|
|
27
21
|
return react_button_1.renderToggleButton_unstable(state);
|
|
28
22
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/ToolbarToggleButton/ToolbarToggleButton.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAGA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;
|
|
1
|
+
{"version":3,"sources":["components/ToolbarToggleButton/ToolbarToggleButton.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAGA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,wBAAA,gBAAA,OAAA,CAAA,0BAAA,CAAA;AAEA;;AAEG;;;AACU,OAAA,CAAA,mBAAA,gBAAqE,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;EAChH,MAAM,KAAK,GAAG,wBAAA,CAAA,+BAAA,CAAgC,KAAhC,EAAuC,GAAvC,CAAd;EAEA,cAAA,CAAA,8BAAA,CAA+B,KAA/B;EACA,OAAO,cAAA,CAAA,2BAAA,CAA4B,KAA5B,CAAP;AACD,CALiF,CAArE;AAOb,OAAA,CAAA,mBAAA,CAAoB,WAApB,GAAkC,qBAAlC","sourcesContent":["import * as React from 'react';\nimport type { ToolbarToggleButtonProps } from './ToolbarToggleButton.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { renderToggleButton_unstable, useToggleButtonStyles_unstable } from '@fluentui/react-button';\nimport { useToolbarToggleButton_unstable } from './useToolbarToggleButton';\n\n/**\n * ToolbarToggleButton component\n */\nexport const ToolbarToggleButton: ForwardRefComponent<ToolbarToggleButtonProps> = React.forwardRef((props, ref) => {\n const state = useToolbarToggleButton_unstable(props, ref);\n\n useToggleButtonStyles_unstable(state);\n return renderToggleButton_unstable(state);\n}) as ForwardRefComponent<ToolbarToggleButtonProps>;\n\nToolbarToggleButton.displayName = 'ToolbarToggleButton';\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useToolbarToggleButton_unstable = void 0;
|
|
7
|
+
|
|
8
|
+
const react_button_1 = /*#__PURE__*/require("@fluentui/react-button");
|
|
9
|
+
|
|
10
|
+
const ToolbarContext_1 = /*#__PURE__*/require("../Toolbar/ToolbarContext");
|
|
11
|
+
/**
|
|
12
|
+
* Given user props, defines default props for the ToggleButton, calls useButtonState and useChecked, and returns
|
|
13
|
+
* processed state.
|
|
14
|
+
* @param props - User provided props to the ToggleButton component.
|
|
15
|
+
* @param ref - User provided ref to be passed to the ToggleButton component.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const useToolbarToggleButton_unstable = (props, ref) => {
|
|
20
|
+
const {
|
|
21
|
+
handleToggleButton,
|
|
22
|
+
size
|
|
23
|
+
} = ToolbarContext_1.useToolbarContext();
|
|
24
|
+
const {
|
|
25
|
+
onClick: onClickOriginal
|
|
26
|
+
} = props;
|
|
27
|
+
const state = react_button_1.useToggleButton_unstable({
|
|
28
|
+
size,
|
|
29
|
+
...props
|
|
30
|
+
}, ref);
|
|
31
|
+
|
|
32
|
+
const handleOnClick = e => {
|
|
33
|
+
if (state.disabled) {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
handleToggleButton === null || handleToggleButton === void 0 ? void 0 : handleToggleButton(e, state.name, state.value, state.checked);
|
|
40
|
+
onClickOriginal === null || onClickOriginal === void 0 ? void 0 : onClickOriginal(e);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
state.root.onClick = handleOnClick;
|
|
44
|
+
return state;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.useToolbarToggleButton_unstable = useToolbarToggleButton_unstable;
|
|
48
|
+
//# sourceMappingURL=useToolbarToggleButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/ToolbarToggleButton/useToolbarToggleButton.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;;;;AAKG;;;AACI,MAAM,+BAA+B,GAAG,CAC7C,KAD6C,EAE7C,GAF6C,KAGjB;EAC5B,MAAM;IAAE,kBAAF;IAAsB;EAAtB,IAA+B,gBAAA,CAAA,iBAAA,EAArC;EACA,MAAM;IAAE,OAAO,EAAE;EAAX,IAA+B,KAArC;EACA,MAAM,KAAK,GAAG,cAAA,CAAA,wBAAA,CAAyB;IAAE,IAAF;IAAQ,GAAG;EAAX,CAAzB,EAA6C,GAA7C,CAAd;;EAEA,MAAM,aAAa,GACjB,CADoB,IAElB;IACF,IAAI,KAAK,CAAC,QAAV,EAAoB;MAClB,CAAC,CAAC,cAAF;MACA,CAAC,CAAC,eAAF;MACA;IACD;;IAED,kBAAkB,KAAA,IAAlB,IAAA,kBAAkB,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAA,kBAAkB,CAAG,CAAH,EAAM,KAAK,CAAC,IAAZ,EAAkB,KAAK,CAAC,KAAxB,EAA+B,KAAK,CAAC,OAArC,CAAlB;IACA,eAAe,KAAA,IAAf,IAAA,eAAe,KAAA,KAAA,CAAf,GAAe,KAAA,CAAf,GAAA,eAAe,CAAG,CAAH,CAAf;EACD,CAXD;;EAaA,KAAK,CAAC,IAAN,CAAW,OAAX,GAAqB,aAArB;EACA,OAAO,KAAP;AACD,CAvBM;;AAAM,OAAA,CAAA,+BAAA,GAA+B,+BAA/B","sourcesContent":["import * as React from 'react';\nimport { useToggleButton_unstable } from '@fluentui/react-button';\nimport { useToolbarContext } from '../Toolbar/ToolbarContext';\nimport { ToolbarToggleButtonProps, ToolbarToggleButtonState } from './ToolbarToggleButton.types';\n\n/**\n * Given user props, defines default props for the ToggleButton, calls useButtonState and useChecked, and returns\n * processed state.\n * @param props - User provided props to the ToggleButton component.\n * @param ref - User provided ref to be passed to the ToggleButton component.\n */\nexport const useToolbarToggleButton_unstable = (\n props: ToolbarToggleButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,\n): ToolbarToggleButtonState => {\n const { handleToggleButton, size } = useToolbarContext();\n const { onClick: onClickOriginal } = props;\n const state = useToggleButton_unstable({ size, ...props }, ref) as ToolbarToggleButtonState;\n\n const handleOnClick = (\n e: React.MouseEvent<HTMLButtonElement, MouseEvent> & React.MouseEvent<HTMLAnchorElement, MouseEvent>,\n ) => {\n if (state.disabled) {\n e.preventDefault();\n e.stopPropagation();\n return;\n }\n\n handleToggleButton?.(e, state.name, state.value, state.checked);\n onClickOriginal?.(e);\n };\n\n state.root.onClick = handleOnClick;\n return state;\n};\n"],"sourceRoot":"../src/"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-toolbar",
|
|
3
|
-
"version": "9.0.0-beta.
|
|
3
|
+
"version": "9.0.0-beta.7",
|
|
4
4
|
"description": "React components for building web experiences",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -15,29 +15,31 @@
|
|
|
15
15
|
"build": "just-scripts build",
|
|
16
16
|
"clean": "just-scripts clean",
|
|
17
17
|
"code-style": "just-scripts code-style",
|
|
18
|
+
"e2e": "yarn cypress run --component",
|
|
19
|
+
"e2e:local": "yarn cypress open --component",
|
|
18
20
|
"just": "just-scripts",
|
|
19
21
|
"lint": "just-scripts lint",
|
|
20
22
|
"start": "yarn storybook",
|
|
21
23
|
"test": "jest --passWithNoTests",
|
|
22
24
|
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
|
|
23
|
-
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/packages/react-components/react-toolbar/src && yarn docs",
|
|
24
|
-
"storybook": "
|
|
25
|
+
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/types/packages/react-components/react-toolbar/src && yarn docs",
|
|
26
|
+
"storybook": "start-storybook",
|
|
25
27
|
"type-check": "tsc -b tsconfig.json"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"@fluentui/eslint-plugin": "*",
|
|
29
31
|
"@fluentui/react-conformance": "*",
|
|
30
|
-
"@fluentui/react-conformance-griffel": "9.0.0-beta.
|
|
32
|
+
"@fluentui/react-conformance-griffel": "9.0.0-beta.14",
|
|
31
33
|
"@fluentui/scripts": "^1.0.0"
|
|
32
34
|
},
|
|
33
35
|
"dependencies": {
|
|
34
|
-
"@fluentui/react-button": "^9.1.
|
|
35
|
-
"@fluentui/react-divider": "^9.0
|
|
36
|
-
"@fluentui/react-theme": "^9.
|
|
37
|
-
"@fluentui/react-utilities": "^9.0
|
|
38
|
-
"@fluentui/react-radio": "^9.0.
|
|
39
|
-
"@fluentui/react-tabster": "^9.1.
|
|
40
|
-
"@griffel/react": "^1.
|
|
36
|
+
"@fluentui/react-button": "^9.1.2",
|
|
37
|
+
"@fluentui/react-divider": "^9.1.0",
|
|
38
|
+
"@fluentui/react-theme": "^9.1.0",
|
|
39
|
+
"@fluentui/react-utilities": "^9.1.0",
|
|
40
|
+
"@fluentui/react-radio": "^9.0.6",
|
|
41
|
+
"@fluentui/react-tabster": "^9.1.1",
|
|
42
|
+
"@griffel/react": "^1.3.0",
|
|
41
43
|
"tslib": "^2.1.0"
|
|
42
44
|
},
|
|
43
45
|
"peerDependencies": {
|
package/dist/tsdoc-metadata.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.18.1"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|