@wordpress/components 28.7.0 → 28.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/build/box-control/all-input-control.js +1 -2
- package/build/box-control/all-input-control.js.map +1 -1
- package/build/box-control/utils.js +1 -1
- package/build/box-control/utils.js.map +1 -1
- package/build/card/card/component.js +2 -2
- package/build/card/card/component.js.map +1 -1
- package/build/card/styles.js +18 -18
- package/build/card/styles.js.map +1 -1
- package/build/combobox-control/index.js +3 -1
- package/build/combobox-control/index.js.map +1 -1
- package/build/combobox-control/types.js.map +1 -1
- package/build/composite/context.js +1 -1
- package/build/composite/context.js.map +1 -1
- package/build/composite/group-label.js +1 -1
- package/build/composite/group-label.js.map +1 -1
- package/build/composite/group.js +1 -1
- package/build/composite/group.js.map +1 -1
- package/build/composite/hover.js +1 -1
- package/build/composite/hover.js.map +1 -1
- package/build/composite/index.js +17 -26
- package/build/composite/index.js.map +1 -1
- package/build/composite/item.js +1 -1
- package/build/composite/item.js.map +1 -1
- package/build/composite/legacy/index.js +59 -8
- package/build/composite/legacy/index.js.map +1 -1
- package/build/composite/row.js +1 -1
- package/build/composite/row.js.map +1 -1
- package/build/composite/typeahead.js +1 -1
- package/build/composite/typeahead.js.map +1 -1
- package/build/composite/types.js.map +1 -1
- package/build/custom-select-control-v2/styles.js +9 -9
- package/build/custom-select-control-v2/styles.js.map +1 -1
- package/build/date-time/date/index.js +1 -1
- package/build/date-time/date/index.js.map +1 -1
- package/build/date-time/date/styles.js +35 -24
- package/build/date-time/date/styles.js.map +1 -1
- package/build/date-time/date/use-lilius/index.js +163 -0
- package/build/date-time/date/use-lilius/index.js.map +1 -0
- package/build/dropdown-menu-v2/styles.js +17 -17
- package/build/dropdown-menu-v2/styles.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/modal/index.js +27 -12
- package/build/modal/index.js.map +1 -1
- package/build/modal/types.js.map +1 -1
- package/build/modal/use-modal-exit-animation.js +75 -0
- package/build/modal/use-modal-exit-animation.js.map +1 -0
- package/build/navigator/navigator-screen/component.js +5 -0
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/private-apis.js +0 -9
- package/build/private-apis.js.map +1 -1
- package/build/range-control/styles/range-control-styles.js +28 -28
- package/build/range-control/styles/range-control-styles.js.map +1 -1
- package/build/slot-fill/index.js +1 -0
- package/build/slot-fill/index.js.map +1 -1
- package/build/tabs/styles.js +3 -3
- package/build/tabs/styles.js.map +1 -1
- package/build/tabs/tablist.js +5 -4
- package/build/tabs/tablist.js.map +1 -1
- package/build/utils/config-values.js +4 -5
- package/build/utils/config-values.js.map +1 -1
- package/build/utils/element-rect.js +73 -105
- package/build/utils/element-rect.js.map +1 -1
- package/build-module/box-control/all-input-control.js +2 -2
- package/build-module/box-control/all-input-control.js.map +1 -1
- package/build-module/box-control/utils.js +1 -1
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/card/card/component.js +2 -2
- package/build-module/card/card/component.js.map +1 -1
- package/build-module/card/styles.js +18 -18
- package/build-module/card/styles.js.map +1 -1
- package/build-module/combobox-control/index.js +3 -1
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/combobox-control/types.js.map +1 -1
- package/build-module/composite/context.js +1 -1
- package/build-module/composite/context.js.map +1 -1
- package/build-module/composite/group-label.js +1 -1
- package/build-module/composite/group-label.js.map +1 -1
- package/build-module/composite/group.js +1 -1
- package/build-module/composite/group.js.map +1 -1
- package/build-module/composite/hover.js +1 -1
- package/build-module/composite/hover.js.map +1 -1
- package/build-module/composite/index.js +17 -26
- package/build-module/composite/index.js.map +1 -1
- package/build-module/composite/item.js +1 -1
- package/build-module/composite/item.js.map +1 -1
- package/build-module/composite/legacy/index.js +56 -8
- package/build-module/composite/legacy/index.js.map +1 -1
- package/build-module/composite/row.js +1 -1
- package/build-module/composite/row.js.map +1 -1
- package/build-module/composite/typeahead.js +1 -1
- package/build-module/composite/typeahead.js.map +1 -1
- package/build-module/composite/types.js.map +1 -1
- package/build-module/custom-select-control-v2/styles.js +9 -9
- package/build-module/custom-select-control-v2/styles.js.map +1 -1
- package/build-module/date-time/date/index.js +1 -2
- package/build-module/date-time/date/index.js.map +1 -1
- package/build-module/date-time/date/styles.js +31 -24
- package/build-module/date-time/date/styles.js.map +1 -1
- package/build-module/date-time/date/use-lilius/index.js +158 -0
- package/build-module/date-time/date/use-lilius/index.js.map +1 -0
- package/build-module/dropdown-menu-v2/styles.js +17 -17
- package/build-module/dropdown-menu-v2/styles.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/modal/index.js +29 -12
- package/build-module/modal/index.js.map +1 -1
- package/build-module/modal/types.js.map +1 -1
- package/build-module/modal/use-modal-exit-animation.js +68 -0
- package/build-module/modal/use-modal-exit-animation.js.map +1 -0
- package/build-module/navigator/navigator-screen/component.js +4 -0
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/private-apis.js +0 -9
- package/build-module/private-apis.js.map +1 -1
- package/build-module/range-control/styles/range-control-styles.js +28 -28
- package/build-module/range-control/styles/range-control-styles.js.map +1 -1
- package/build-module/slot-fill/index.js +1 -0
- package/build-module/slot-fill/index.js.map +1 -1
- package/build-module/tabs/styles.js +3 -3
- package/build-module/tabs/styles.js.map +1 -1
- package/build-module/tabs/tablist.js +5 -4
- package/build-module/tabs/tablist.js.map +1 -1
- package/build-module/utils/config-values.js +4 -5
- package/build-module/utils/config-values.js.map +1 -1
- package/build-module/utils/element-rect.js +74 -105
- package/build-module/utils/element-rect.js.map +1 -1
- package/build-style/style-rtl.css +51 -10
- package/build-style/style.css +51 -10
- package/build-types/box-control/all-input-control.d.ts.map +1 -1
- package/build-types/box-control/utils.d.ts +1 -1
- package/build-types/box-control/utils.d.ts.map +1 -1
- package/build-types/button-group/stories/index.story.d.ts +2 -2
- package/build-types/button-group/stories/index.story.d.ts.map +1 -1
- package/build-types/combobox-control/index.d.ts.map +1 -1
- package/build-types/combobox-control/stories/index.story.d.ts +4 -0
- package/build-types/combobox-control/stories/index.story.d.ts.map +1 -1
- package/build-types/combobox-control/types.d.ts +4 -0
- package/build-types/combobox-control/types.d.ts.map +1 -1
- package/build-types/composite/context.d.ts.map +1 -1
- package/build-types/composite/index.d.ts +36 -24
- package/build-types/composite/index.d.ts.map +1 -1
- package/build-types/composite/legacy/index.d.ts +25 -2
- package/build-types/composite/legacy/index.d.ts.map +1 -1
- package/build-types/composite/legacy/stories/index.story.d.ts.map +1 -1
- package/build-types/composite/stories/index.story.d.ts +9 -9
- package/build-types/composite/stories/index.story.d.ts.map +1 -1
- package/build-types/composite/types.d.ts +11 -10
- package/build-types/composite/types.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
- package/build-types/date-time/date/index.d.ts +0 -3
- package/build-types/date-time/date/index.d.ts.map +1 -1
- package/build-types/date-time/date/styles.d.ts.map +1 -1
- package/build-types/date-time/date/test/use-lilius.d.ts +2 -0
- package/build-types/date-time/date/test/use-lilius.d.ts.map +1 -0
- package/build-types/date-time/date/use-lilius/index.d.ts +169 -0
- package/build-types/date-time/date/use-lilius/index.d.ts.map +1 -0
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/modal/stories/index.story.d.ts +3 -0
- package/build-types/modal/stories/index.story.d.ts.map +1 -1
- package/build-types/modal/types.d.ts +6 -10
- package/build-types/modal/types.d.ts.map +1 -1
- package/build-types/modal/use-modal-exit-animation.d.ts +9 -0
- package/build-types/modal/use-modal-exit-animation.d.ts.map +1 -0
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/slot-fill/index.d.ts +3 -0
- package/build-types/slot-fill/index.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/tabs/tablist.d.ts.map +1 -1
- package/build-types/utils/config-values.d.ts +0 -1
- package/build-types/utils/element-rect.d.ts +32 -74
- package/build-types/utils/element-rect.d.ts.map +1 -1
- package/package.json +19 -20
- package/src/box-control/README.md +7 -0
- package/src/box-control/all-input-control.tsx +2 -3
- package/src/box-control/utils.ts +1 -1
- package/src/button-group/stories/index.story.tsx +10 -15
- package/src/card/card/component.tsx +1 -1
- package/src/card/styles.ts +1 -1
- package/src/card/test/__snapshots__/index.tsx.snap +54 -54
- package/src/combobox-control/README.md +7 -0
- package/src/combobox-control/index.tsx +2 -0
- package/src/combobox-control/test/index.tsx +40 -0
- package/src/combobox-control/types.ts +4 -0
- package/src/composite/README.md +5 -24
- package/src/composite/{context.ts → context.tsx} +1 -2
- package/src/composite/group-label.tsx +1 -1
- package/src/composite/group.tsx +1 -1
- package/src/composite/hover.tsx +1 -1
- package/src/composite/index.tsx +17 -28
- package/src/composite/item.tsx +1 -1
- package/src/composite/legacy/index.tsx +72 -11
- package/src/composite/legacy/stories/index.story.tsx +2 -1
- package/src/composite/legacy/test/index.tsx +57 -1
- package/src/composite/row.tsx +1 -1
- package/src/composite/stories/index.story.tsx +185 -169
- package/src/composite/typeahead.tsx +1 -1
- package/src/composite/types.ts +13 -15
- package/src/custom-select-control-v2/styles.ts +1 -0
- package/src/date-time/date/index.tsx +1 -1
- package/src/date-time/date/styles.ts +31 -11
- package/src/date-time/date/test/use-lilius.ts +417 -0
- package/src/date-time/date/use-lilius/index.ts +394 -0
- package/src/dropdown-menu-v2/styles.ts +1 -1
- package/src/form-toggle/style.scss +1 -0
- package/src/index.ts +1 -0
- package/src/modal/index.tsx +42 -19
- package/src/modal/stories/index.story.tsx +8 -14
- package/src/modal/style.scss +30 -8
- package/src/modal/types.ts +6 -18
- package/src/modal/use-modal-exit-animation.ts +99 -0
- package/src/navigator/navigator-screen/component.tsx +7 -0
- package/src/navigator/test/index.tsx +8 -0
- package/src/popover/style.scss +3 -2
- package/src/private-apis.ts +0 -9
- package/src/range-control/styles/range-control-styles.ts +1 -0
- package/src/resizable-box/style.scss +1 -1
- package/src/select-control/README.md +2 -2
- package/src/slot-fill/index.tsx +1 -0
- package/src/snackbar/style.scss +1 -1
- package/src/tabs/styles.ts +40 -11
- package/src/tabs/tablist.tsx +5 -4
- package/src/tooltip/style.scss +1 -0
- package/src/utils/config-values.js +4 -5
- package/src/utils/element-rect.ts +93 -130
- package/tsconfig.tsbuildinfo +1 -1
- package/build/composite/store.js +0 -54
- package/build/composite/store.js.map +0 -1
- package/build-module/composite/store.js +0 -46
- package/build-module/composite/store.js.map +0 -1
- package/build-types/composite/store.d.ts +0 -25
- package/build-types/composite/store.d.ts.map +0 -1
- package/build-types/composite/stories/utils.d.ts +0 -29
- package/build-types/composite/stories/utils.d.ts.map +0 -1
- package/src/composite/store.ts +0 -46
- package/src/composite/stories/utils.tsx +0 -76
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import type { Meta,
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { isRTL } from '@wordpress/i18n';
|
|
10
9
|
import { useContext, useMemo } from '@wordpress/element';
|
|
11
10
|
|
|
12
11
|
/**
|
|
@@ -14,15 +13,11 @@ import { useContext, useMemo } from '@wordpress/element';
|
|
|
14
13
|
*/
|
|
15
14
|
import { createSlotFill, Provider as SlotFillProvider } from '../../slot-fill';
|
|
16
15
|
import { Composite } from '..';
|
|
17
|
-
import { useCompositeStore } from '../store';
|
|
18
|
-
import { UseCompositeStorePlaceholder, transform } from './utils';
|
|
19
16
|
|
|
20
|
-
const meta: Meta< typeof
|
|
21
|
-
title: 'Components/Composite
|
|
22
|
-
component:
|
|
17
|
+
const meta: Meta< typeof Composite > = {
|
|
18
|
+
title: 'Components/Composite',
|
|
19
|
+
component: Composite,
|
|
23
20
|
subcomponents: {
|
|
24
|
-
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
|
|
25
|
-
Composite,
|
|
26
21
|
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
|
|
27
22
|
'Composite.Group': Composite.Group,
|
|
28
23
|
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
|
|
@@ -35,8 +30,12 @@ const meta: Meta< typeof UseCompositeStorePlaceholder > = {
|
|
|
35
30
|
'Composite.Hover': Composite.Hover,
|
|
36
31
|
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
|
|
37
32
|
'Composite.Typeahead': Composite.Typeahead,
|
|
33
|
+
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
|
|
34
|
+
'Composite.Context': Composite.Context,
|
|
38
35
|
},
|
|
39
36
|
argTypes: {
|
|
37
|
+
children: { control: { type: null } },
|
|
38
|
+
render: { control: { type: null } },
|
|
40
39
|
setActiveId: { control: { type: null } },
|
|
41
40
|
focusLoop: {
|
|
42
41
|
control: 'select',
|
|
@@ -47,12 +46,10 @@ const meta: Meta< typeof UseCompositeStorePlaceholder > = {
|
|
|
47
46
|
options: [ true, false, 'horizontal', 'vertical', 'both' ],
|
|
48
47
|
},
|
|
49
48
|
},
|
|
50
|
-
tags: [ 'status-private' ],
|
|
51
49
|
parameters: {
|
|
52
50
|
controls: { expanded: true },
|
|
53
51
|
docs: {
|
|
54
52
|
canvas: { sourceState: 'shown' },
|
|
55
|
-
source: { transform },
|
|
56
53
|
},
|
|
57
54
|
},
|
|
58
55
|
decorators: [
|
|
@@ -93,116 +90,111 @@ const meta: Meta< typeof UseCompositeStorePlaceholder > = {
|
|
|
93
90
|
};
|
|
94
91
|
export default meta;
|
|
95
92
|
|
|
96
|
-
export const Default:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<Composite.Item>Item three</Composite.Item>
|
|
107
|
-
</Composite>
|
|
108
|
-
);
|
|
93
|
+
export const Default: StoryObj< typeof Composite > = {
|
|
94
|
+
args: {
|
|
95
|
+
children: (
|
|
96
|
+
<>
|
|
97
|
+
<Composite.Item>Item one</Composite.Item>
|
|
98
|
+
<Composite.Item>Item two</Composite.Item>
|
|
99
|
+
<Composite.Item>Item three</Composite.Item>
|
|
100
|
+
</>
|
|
101
|
+
),
|
|
102
|
+
},
|
|
109
103
|
};
|
|
110
104
|
|
|
111
|
-
export const Groups:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
<Composite.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
);
|
|
105
|
+
export const Groups: StoryObj< typeof Composite > = {
|
|
106
|
+
...Default,
|
|
107
|
+
args: {
|
|
108
|
+
...Default.args,
|
|
109
|
+
children: (
|
|
110
|
+
<>
|
|
111
|
+
<Composite.Group>
|
|
112
|
+
<Composite.GroupLabel>Group one</Composite.GroupLabel>
|
|
113
|
+
<Composite.Item>Item 1.1</Composite.Item>
|
|
114
|
+
<Composite.Item>Item 1.2</Composite.Item>
|
|
115
|
+
</Composite.Group>
|
|
116
|
+
<Composite.Group>
|
|
117
|
+
<Composite.GroupLabel>Group two</Composite.GroupLabel>
|
|
118
|
+
<Composite.Item>Item 2.1</Composite.Item>
|
|
119
|
+
<Composite.Item>Item 2.1</Composite.Item>
|
|
120
|
+
</Composite.Group>
|
|
121
|
+
</>
|
|
122
|
+
),
|
|
123
|
+
},
|
|
131
124
|
};
|
|
132
125
|
|
|
133
|
-
export const Grid:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
126
|
+
export const Grid: StoryObj< typeof Composite > = {
|
|
127
|
+
...Default,
|
|
128
|
+
args: {
|
|
129
|
+
...Default.args,
|
|
130
|
+
role: 'grid',
|
|
131
|
+
'aria-label': 'Composite',
|
|
132
|
+
children: (
|
|
133
|
+
<>
|
|
134
|
+
<Composite.Row role="row">
|
|
135
|
+
<Composite.Item role="gridcell">Item A1</Composite.Item>
|
|
136
|
+
<Composite.Item role="gridcell">Item A2</Composite.Item>
|
|
137
|
+
<Composite.Item role="gridcell">Item A3</Composite.Item>
|
|
138
|
+
</Composite.Row>
|
|
139
|
+
<Composite.Row role="row">
|
|
140
|
+
<Composite.Item role="gridcell">Item B1</Composite.Item>
|
|
141
|
+
<Composite.Item role="gridcell">Item B2</Composite.Item>
|
|
142
|
+
<Composite.Item role="gridcell">Item B3</Composite.Item>
|
|
143
|
+
</Composite.Row>
|
|
144
|
+
<Composite.Row role="row">
|
|
145
|
+
<Composite.Item role="gridcell">Item C1</Composite.Item>
|
|
146
|
+
<Composite.Item role="gridcell">Item C2</Composite.Item>
|
|
147
|
+
<Composite.Item role="gridcell">Item C3</Composite.Item>
|
|
148
|
+
</Composite.Row>
|
|
149
|
+
</>
|
|
150
|
+
),
|
|
151
|
+
},
|
|
158
152
|
};
|
|
159
153
|
|
|
160
|
-
export const Hover:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
Hover
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
Hover
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
story: 'Elements in the composite widget will receive focus on mouse move and lose focus to the composite base element on mouse leave.',
|
|
154
|
+
export const Hover: StoryObj< typeof Composite > = {
|
|
155
|
+
...Default,
|
|
156
|
+
args: {
|
|
157
|
+
...Default.args,
|
|
158
|
+
children: (
|
|
159
|
+
<>
|
|
160
|
+
<Composite.Hover render={ <Composite.Item /> }>
|
|
161
|
+
Hover item one
|
|
162
|
+
</Composite.Hover>
|
|
163
|
+
<Composite.Hover render={ <Composite.Item /> }>
|
|
164
|
+
Hover item two
|
|
165
|
+
</Composite.Hover>
|
|
166
|
+
<Composite.Hover render={ <Composite.Item /> }>
|
|
167
|
+
Hover item three
|
|
168
|
+
</Composite.Hover>
|
|
169
|
+
</>
|
|
170
|
+
),
|
|
171
|
+
},
|
|
172
|
+
parameters: {
|
|
173
|
+
docs: {
|
|
174
|
+
description: {
|
|
175
|
+
story: 'Elements in the composite widget will receive focus on mouse move and lose focus to the composite base element on mouse leave.',
|
|
176
|
+
},
|
|
184
177
|
},
|
|
185
178
|
},
|
|
186
179
|
};
|
|
187
180
|
|
|
188
|
-
export const Typeahead:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
story: 'When focus in on the composite widget, hitting printable character keys will move focus to the next composite item that begins with the input characters.',
|
|
181
|
+
export const Typeahead: StoryObj< typeof Composite > = {
|
|
182
|
+
args: {
|
|
183
|
+
...Default.args,
|
|
184
|
+
render: <Composite.Typeahead />,
|
|
185
|
+
children: (
|
|
186
|
+
<>
|
|
187
|
+
<Composite.Item>Apple</Composite.Item>
|
|
188
|
+
<Composite.Item>Banana</Composite.Item>
|
|
189
|
+
<Composite.Item>Peach</Composite.Item>
|
|
190
|
+
</>
|
|
191
|
+
),
|
|
192
|
+
},
|
|
193
|
+
parameters: {
|
|
194
|
+
docs: {
|
|
195
|
+
description: {
|
|
196
|
+
story: 'When focus in on the composite widget, hitting printable character keys will move focus to the next composite item that begins with the input characters.',
|
|
197
|
+
},
|
|
206
198
|
},
|
|
207
199
|
},
|
|
208
200
|
};
|
|
@@ -257,82 +249,106 @@ const Fill = ( { children }: { children: React.ReactNode } ) => {
|
|
|
257
249
|
);
|
|
258
250
|
};
|
|
259
251
|
|
|
260
|
-
export const WithSlotFill:
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
252
|
+
export const WithSlotFill: StoryObj< typeof Composite > = {
|
|
253
|
+
...Default,
|
|
254
|
+
args: {
|
|
255
|
+
...Default.args,
|
|
256
|
+
children: (
|
|
257
|
+
<>
|
|
266
258
|
<Composite.Item>Item one (direct child)</Composite.Item>
|
|
267
259
|
<Slot />
|
|
268
260
|
<Composite.Item>Item four (direct child)</Composite.Item>
|
|
269
|
-
|
|
261
|
+
</>
|
|
262
|
+
),
|
|
263
|
+
},
|
|
264
|
+
decorators: [
|
|
265
|
+
( Story ) => {
|
|
266
|
+
return (
|
|
267
|
+
<SlotFillProvider>
|
|
268
|
+
<Story />
|
|
270
269
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
WithSlotFill.parameters = {
|
|
282
|
-
docs: {
|
|
283
|
-
description: {
|
|
284
|
-
story: 'When rendering Composite components across a SlotFill, the Composite.Context should be manually forwarded from the Slot to the Fill component.',
|
|
270
|
+
<Fill>
|
|
271
|
+
<Composite.Item>
|
|
272
|
+
Item two (from slot fill)
|
|
273
|
+
</Composite.Item>
|
|
274
|
+
<Composite.Item>
|
|
275
|
+
Item three (from slot fill)
|
|
276
|
+
</Composite.Item>
|
|
277
|
+
</Fill>
|
|
278
|
+
</SlotFillProvider>
|
|
279
|
+
);
|
|
285
280
|
},
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
281
|
+
],
|
|
282
|
+
parameters: {
|
|
283
|
+
docs: {
|
|
284
|
+
description: {
|
|
285
|
+
story: 'When rendering Composite components across a SlotFill, the Composite.Context should be manually forwarded from the Slot to the Fill component.',
|
|
286
|
+
},
|
|
287
|
+
source: {
|
|
288
|
+
transform: ( code: string ) => {
|
|
289
|
+
return `const ExampleSlotFill = createSlotFill( 'Example' );
|
|
289
290
|
|
|
290
291
|
const Slot = () => {
|
|
291
|
-
|
|
292
|
+
const compositeContext = useContext( Composite.Context );
|
|
292
293
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
294
|
+
// Forward the Slot's composite context to the Fill via fillProps, so that
|
|
295
|
+
// Composite components rendered inside the Fill can work as expected.
|
|
296
|
+
const fillProps = useMemo(
|
|
297
|
+
() => ( {
|
|
298
|
+
forwardedContext: [
|
|
299
|
+
[ Composite.Context.Provider, { value: compositeContext } ],
|
|
300
|
+
],
|
|
301
|
+
} ),
|
|
302
|
+
[ compositeContext ]
|
|
303
|
+
);
|
|
303
304
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
305
|
+
return (
|
|
306
|
+
<ExampleSlotFill.Slot
|
|
307
|
+
fillProps={ fillProps }
|
|
308
|
+
bubblesVirtually
|
|
309
|
+
style={ { display: 'contents' } }
|
|
310
|
+
/>
|
|
311
|
+
);
|
|
311
312
|
};
|
|
312
313
|
|
|
313
314
|
const Fill = ( { children } ) => {
|
|
314
|
-
|
|
315
|
+
const innerMarkup = <>{ children }</>;
|
|
315
316
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
317
|
+
return (
|
|
318
|
+
<ExampleSlotFill.Fill>
|
|
319
|
+
{ ( fillProps ) => {
|
|
320
|
+
const { forwardedContext = [] } = fillProps;
|
|
320
321
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
322
|
+
// Render all context providers forwarded by the Slot via fillProps.
|
|
323
|
+
return forwardedContext.reduce(
|
|
324
|
+
( inner, [ Provider, props ] ) => (
|
|
325
|
+
<Provider { ...props }>{ inner }</Provider>
|
|
326
|
+
),
|
|
327
|
+
innerMarkup
|
|
328
|
+
);
|
|
329
|
+
} }
|
|
330
|
+
</ExampleSlotFill.Fill>
|
|
331
|
+
);
|
|
331
332
|
};
|
|
332
333
|
|
|
333
334
|
// In a separate component:
|
|
334
335
|
|
|
335
|
-
|
|
336
|
+
<SlotFillProvider>
|
|
337
|
+
${
|
|
338
|
+
// Add one level of indentation to match the surrounding code.
|
|
339
|
+
code.replaceAll( '\n', '\n ' )
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
<Fill>
|
|
343
|
+
<Composite.Item>
|
|
344
|
+
Item two (from slot fill)
|
|
345
|
+
</Composite.Item>
|
|
346
|
+
<Composite.Item>
|
|
347
|
+
Item three (from slot fill)
|
|
348
|
+
</Composite.Item>
|
|
349
|
+
</Fill>
|
|
350
|
+
</SlotFillProvider>`;
|
|
351
|
+
},
|
|
336
352
|
},
|
|
337
353
|
},
|
|
338
354
|
},
|
package/src/composite/types.ts
CHANGED
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type * as Ariakit from '@ariakit/react';
|
|
5
5
|
|
|
6
|
-
export type CompositeContextProps =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
export type CompositeContextProps = {
|
|
7
|
+
/**
|
|
8
|
+
* The component store, used for advanced usage of the component.
|
|
9
|
+
*
|
|
10
|
+
* _Note: Using the store directly is not recommended. Instead, use the props
|
|
11
|
+
* exposed by the `Composite` component._
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
store?: unknown;
|
|
15
|
+
};
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
type CompositeStoreProps = {
|
|
16
18
|
/**
|
|
17
19
|
* The current active item `id`. The active item is the element within the
|
|
18
20
|
* composite widget that has either DOM or virtual focus (in case
|
|
@@ -117,22 +119,18 @@ export type CompositeStoreProps = {
|
|
|
117
119
|
*/
|
|
118
120
|
orientation?: Ariakit.CompositeStoreProps[ 'orientation' ];
|
|
119
121
|
/**
|
|
120
|
-
*
|
|
122
|
+
* Controls how the previous and next items are determined.
|
|
121
123
|
* If `rtl` is set to `true`, they will be inverted.
|
|
122
124
|
*
|
|
123
125
|
* This only affects the composite widget behavior. You still need to set
|
|
124
126
|
* `dir="rtl"` on HTML/CSS.
|
|
125
127
|
*
|
|
126
|
-
* @default
|
|
128
|
+
* @default `isRtl()`
|
|
127
129
|
*/
|
|
128
130
|
rtl?: Ariakit.CompositeStoreProps[ 'rtl' ];
|
|
129
131
|
};
|
|
130
132
|
|
|
131
133
|
export type CompositeProps = CompositeStoreProps & {
|
|
132
|
-
/**
|
|
133
|
-
* Object returned by the `useCompositeStore` hook.
|
|
134
|
-
*/
|
|
135
|
-
store?: Ariakit.CompositeStore;
|
|
136
134
|
/**
|
|
137
135
|
* Allows the component to be rendered as a different HTML element or React
|
|
138
136
|
* component. The value can be a React element or a function that takes in the
|
|
@@ -120,6 +120,7 @@ export const SelectPopover = styled( Ariakit.SelectPopover )`
|
|
|
120
120
|
background-color: ${ COLORS.theme.background };
|
|
121
121
|
border-radius: ${ CONFIG.radiusSmall };
|
|
122
122
|
border: 1px solid ${ COLORS.theme.foreground };
|
|
123
|
+
box-shadow: ${ CONFIG.elevationMedium };
|
|
123
124
|
|
|
124
125
|
/* z-index(".components-popover") */
|
|
125
126
|
z-index: 1000000;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useLilius } from 'use-lilius';
|
|
5
4
|
import {
|
|
6
5
|
format,
|
|
7
6
|
isSameDay,
|
|
@@ -29,6 +28,7 @@ import { useState, useRef, useEffect } from '@wordpress/element';
|
|
|
29
28
|
/**
|
|
30
29
|
* Internal dependencies
|
|
31
30
|
*/
|
|
31
|
+
import { useLilius } from './use-lilius';
|
|
32
32
|
import type { DatePickerProps } from '../types';
|
|
33
33
|
import {
|
|
34
34
|
Wrapper,
|
|
@@ -7,13 +7,13 @@ import styled from '@emotion/styled';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import Button from '../../button';
|
|
10
|
-
import { COLORS, CONFIG } from '../../utils';
|
|
10
|
+
import { boxSizingReset, COLORS, CONFIG } from '../../utils';
|
|
11
11
|
import { HStack } from '../../h-stack';
|
|
12
12
|
import { Heading } from '../../heading';
|
|
13
13
|
import { space } from '../../utils/space';
|
|
14
14
|
|
|
15
15
|
export const Wrapper = styled.div`
|
|
16
|
-
|
|
16
|
+
${ boxSizingReset }
|
|
17
17
|
`;
|
|
18
18
|
|
|
19
19
|
export const Navigator = styled( HStack )`
|
|
@@ -38,7 +38,7 @@ export const Calendar = styled.div`
|
|
|
38
38
|
`;
|
|
39
39
|
|
|
40
40
|
export const DayOfWeek = styled.div`
|
|
41
|
-
color: ${ COLORS.gray[ 700 ] };
|
|
41
|
+
color: ${ COLORS.theme.gray[ 700 ] };
|
|
42
42
|
font-size: ${ CONFIG.fontSize };
|
|
43
43
|
line-height: ${ CONFIG.fontLineHeightBase };
|
|
44
44
|
|
|
@@ -90,15 +90,34 @@ export const DayButton = styled( Button, {
|
|
|
90
90
|
${ ( props ) =>
|
|
91
91
|
props.isSelected &&
|
|
92
92
|
`
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
background: ${ COLORS.theme.accent };
|
|
94
|
+
|
|
95
|
+
&,
|
|
96
|
+
&:hover:not(:disabled, [aria-disabled=true]) {
|
|
97
|
+
color: ${ COLORS.theme.accentInverted };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&:focus:not(:disabled),
|
|
101
|
+
&:focus:not(:disabled) {
|
|
102
|
+
border: ${ CONFIG.borderWidthFocus } solid currentColor;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* Highlight the selected day for high-contrast mode */
|
|
106
|
+
&::after {
|
|
107
|
+
content: '';
|
|
108
|
+
position: absolute;
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
inset: 0;
|
|
111
|
+
border-radius: inherit;
|
|
112
|
+
border: 1px solid transparent;
|
|
113
|
+
}
|
|
95
114
|
` }
|
|
96
115
|
|
|
97
116
|
${ ( props ) =>
|
|
98
117
|
! props.isSelected &&
|
|
99
118
|
props.isToday &&
|
|
100
119
|
`
|
|
101
|
-
background: ${ COLORS.gray[ 200 ] };
|
|
120
|
+
background: ${ COLORS.theme.gray[ 200 ] };
|
|
102
121
|
` }
|
|
103
122
|
}
|
|
104
123
|
|
|
@@ -106,15 +125,16 @@ export const DayButton = styled( Button, {
|
|
|
106
125
|
props.hasEvents &&
|
|
107
126
|
`
|
|
108
127
|
::before {
|
|
109
|
-
|
|
128
|
+
border: 2px solid ${
|
|
129
|
+
props.isSelected
|
|
130
|
+
? COLORS.theme.accentInverted
|
|
131
|
+
: COLORS.theme.accent
|
|
132
|
+
};
|
|
110
133
|
border-radius: ${ CONFIG.radiusRound };
|
|
111
|
-
bottom: 2px;
|
|
112
134
|
content: " ";
|
|
113
|
-
height: 4px;
|
|
114
135
|
left: 50%;
|
|
115
|
-
margin-left: -2px;
|
|
116
136
|
position: absolute;
|
|
117
|
-
|
|
137
|
+
transform: translate(-50%, 9px);
|
|
118
138
|
}
|
|
119
139
|
` }
|
|
120
140
|
`;
|