@workday/canvas-kit-preview-react 15.0.0-alpha.0074-next.0 → 15.0.0-alpha.0075-next.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/dist/commonjs/index.d.ts +0 -1
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +0 -1
- package/dist/commonjs/multi-select/lib/MultiSelectedItem.js +1 -1
- package/dist/es6/index.d.ts +0 -1
- package/dist/es6/index.d.ts.map +1 -1
- package/dist/es6/index.js +0 -1
- package/dist/es6/multi-select/lib/MultiSelectedItem.js +1 -1
- package/index.ts +0 -1
- package/multi-select/lib/MultiSelectedItem.tsx +1 -1
- package/package.json +4 -4
- package/dist/commonjs/pill/index.d.ts +0 -8
- package/dist/commonjs/pill/index.d.ts.map +0 -1
- package/dist/commonjs/pill/index.js +0 -23
- package/dist/commonjs/pill/lib/Pill.d.ts +0 -265
- package/dist/commonjs/pill/lib/Pill.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/Pill.js +0 -147
- package/dist/commonjs/pill/lib/PillAvatar.d.ts +0 -526
- package/dist/commonjs/pill/lib/PillAvatar.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/PillAvatar.js +0 -22
- package/dist/commonjs/pill/lib/PillCount.d.ts +0 -12
- package/dist/commonjs/pill/lib/PillCount.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/PillCount.js +0 -21
- package/dist/commonjs/pill/lib/PillIcon.d.ts +0 -54
- package/dist/commonjs/pill/lib/PillIcon.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/PillIcon.js +0 -20
- package/dist/commonjs/pill/lib/PillIconButton.d.ts +0 -148
- package/dist/commonjs/pill/lib/PillIconButton.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/PillIconButton.js +0 -21
- package/dist/commonjs/pill/lib/PillLabel.d.ts +0 -14
- package/dist/commonjs/pill/lib/PillLabel.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/PillLabel.js +0 -17
- package/dist/commonjs/pill/lib/usePillModel.d.ts +0 -46
- package/dist/commonjs/pill/lib/usePillModel.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/usePillModel.js +0 -24
- package/dist/es6/pill/index.d.ts +0 -8
- package/dist/es6/pill/index.d.ts.map +0 -1
- package/dist/es6/pill/index.js +0 -7
- package/dist/es6/pill/lib/Pill.d.ts +0 -265
- package/dist/es6/pill/lib/Pill.d.ts.map +0 -1
- package/dist/es6/pill/lib/Pill.js +0 -144
- package/dist/es6/pill/lib/PillAvatar.d.ts +0 -526
- package/dist/es6/pill/lib/PillAvatar.d.ts.map +0 -1
- package/dist/es6/pill/lib/PillAvatar.js +0 -19
- package/dist/es6/pill/lib/PillCount.d.ts +0 -12
- package/dist/es6/pill/lib/PillCount.d.ts.map +0 -1
- package/dist/es6/pill/lib/PillCount.js +0 -18
- package/dist/es6/pill/lib/PillIcon.d.ts +0 -54
- package/dist/es6/pill/lib/PillIcon.d.ts.map +0 -1
- package/dist/es6/pill/lib/PillIcon.js +0 -17
- package/dist/es6/pill/lib/PillIconButton.d.ts +0 -148
- package/dist/es6/pill/lib/PillIconButton.d.ts.map +0 -1
- package/dist/es6/pill/lib/PillIconButton.js +0 -18
- package/dist/es6/pill/lib/PillLabel.d.ts +0 -14
- package/dist/es6/pill/lib/PillLabel.d.ts.map +0 -1
- package/dist/es6/pill/lib/PillLabel.js +0 -14
- package/dist/es6/pill/lib/usePillModel.d.ts +0 -46
- package/dist/es6/pill/lib/usePillModel.d.ts.map +0 -1
- package/dist/es6/pill/lib/usePillModel.js +0 -21
- package/pill/index.ts +0 -7
- package/pill/lib/Pill.tsx +0 -285
- package/pill/lib/PillAvatar.tsx +0 -35
- package/pill/lib/PillCount.tsx +0 -44
- package/pill/lib/PillIcon.tsx +0 -32
- package/pill/lib/PillIconButton.tsx +0 -86
- package/pill/lib/PillLabel.tsx +0 -32
- package/pill/lib/usePillModel.tsx +0 -23
- package/pill/package.json +0 -6
package/pill/lib/Pill.tsx
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import {buttonStencil} from '@workday/canvas-kit-react/button';
|
|
2
|
-
import {createContainer, focusRing} from '@workday/canvas-kit-react/common';
|
|
3
|
-
import {Box, BoxProps, mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
4
|
-
import {px2rem, createStencil, cssVar} from '@workday/canvas-kit-styling';
|
|
5
|
-
|
|
6
|
-
import {usePillModel} from './usePillModel';
|
|
7
|
-
|
|
8
|
-
import {PillIcon} from './PillIcon';
|
|
9
|
-
import {PillIconButton} from './PillIconButton';
|
|
10
|
-
import {PillCount, pillCountStencil} from './PillCount';
|
|
11
|
-
import {PillAvatar} from './PillAvatar';
|
|
12
|
-
import {PillLabel} from './PillLabel';
|
|
13
|
-
import {systemIconStencil} from '@workday/canvas-kit-react/icon';
|
|
14
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
15
|
-
|
|
16
|
-
export interface PillProps extends BoxProps {
|
|
17
|
-
/**
|
|
18
|
-
* Defines what kind of pill to render stylistically and its interaction states
|
|
19
|
-
* @default 'default'
|
|
20
|
-
*/
|
|
21
|
-
variant?: 'readOnly' | 'removable';
|
|
22
|
-
/**
|
|
23
|
-
* Determines the max width of the pill. If the pill text is longer than the max width,
|
|
24
|
-
* text will be truncated and a tooltip will show the rest of the content when hovered over
|
|
25
|
-
*/
|
|
26
|
-
maxWidth?: string | number;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const pillStencil = createStencil({
|
|
30
|
-
extends: buttonStencil,
|
|
31
|
-
vars: {
|
|
32
|
-
maxWidth: '',
|
|
33
|
-
},
|
|
34
|
-
base: ({maxWidth}) => ({
|
|
35
|
-
display: 'initial',
|
|
36
|
-
flexDirection: 'row',
|
|
37
|
-
alignItems: 'center',
|
|
38
|
-
borderRadius: system.shape.x1,
|
|
39
|
-
...system.type.subtext.large,
|
|
40
|
-
lineHeight: system.lineHeight.subtext.small, // ensure correct line height when there's no elements and just text
|
|
41
|
-
boxShadow: 'none',
|
|
42
|
-
outline: 'none',
|
|
43
|
-
fontWeight: system.fontWeight.medium,
|
|
44
|
-
WebkitFontSmoothing: 'antialiased',
|
|
45
|
-
MozOsxFontSmoothing: 'grayscale',
|
|
46
|
-
width: 'fit-content',
|
|
47
|
-
padding: `${px2rem(2)} ${cssVar(system.space.x2)}`,
|
|
48
|
-
height: system.space.x6,
|
|
49
|
-
position: 'relative',
|
|
50
|
-
gap: system.space.x1,
|
|
51
|
-
maxWidth,
|
|
52
|
-
whiteSpace: 'nowrap',
|
|
53
|
-
textOverflow: 'ellipsis',
|
|
54
|
-
overflow: 'hidden',
|
|
55
|
-
[buttonStencil.vars.background]: system.color.bg.alt.default,
|
|
56
|
-
[buttonStencil.vars.border]: system.color.border.input.default,
|
|
57
|
-
[buttonStencil.vars.label]: system.color.fg.strong,
|
|
58
|
-
[systemIconStencil.vars.color]: 'currentColor',
|
|
59
|
-
[pillCountStencil.vars.borderColor]: 'transparent',
|
|
60
|
-
|
|
61
|
-
'&:has(span)': {
|
|
62
|
-
display: 'flex',
|
|
63
|
-
lineHeight: system.lineHeight.subtext.large, // ensure correct line height
|
|
64
|
-
},
|
|
65
|
-
'&:hover, &.hover': {
|
|
66
|
-
[buttonStencil.vars.background]: system.color.bg.alt.strong,
|
|
67
|
-
[buttonStencil.vars.border]: system.color.border.input.strong,
|
|
68
|
-
[buttonStencil.vars.label]: system.color.fg.strong,
|
|
69
|
-
[systemIconStencil.vars.color]: 'currentColor',
|
|
70
|
-
[pillCountStencil.vars.backgroundColor]: system.color.bg.muted.softer,
|
|
71
|
-
[pillCountStencil.vars.borderColor]: 'transparent',
|
|
72
|
-
},
|
|
73
|
-
'&:active, &.active': {
|
|
74
|
-
[buttonStencil.vars.background]: system.color.bg.alt.stronger,
|
|
75
|
-
[buttonStencil.vars.border]: system.color.border.input.strong,
|
|
76
|
-
[buttonStencil.vars.label]: system.color.fg.strong,
|
|
77
|
-
[systemIconStencil.vars.color]: 'currentColor',
|
|
78
|
-
[pillCountStencil.vars.backgroundColor]: system.color.bg.muted.softer,
|
|
79
|
-
[pillCountStencil.vars.borderColor]: 'transparent',
|
|
80
|
-
},
|
|
81
|
-
'&:focus-visible, &.focus': {
|
|
82
|
-
[buttonStencil.vars.background]: system.color.bg.alt.default,
|
|
83
|
-
[buttonStencil.vars.border]: system.color.border.primary.default,
|
|
84
|
-
[buttonStencil.vars.label]: system.color.fg.strong,
|
|
85
|
-
borderColor: system.color.border.primary.default,
|
|
86
|
-
[systemIconStencil.vars.color]: 'currentColor',
|
|
87
|
-
[pillCountStencil.vars.borderColor]: system.color.border.primary.default,
|
|
88
|
-
|
|
89
|
-
...focusRing({
|
|
90
|
-
width: 0,
|
|
91
|
-
inset: 'inner',
|
|
92
|
-
innerColor: system.color.border.primary.default,
|
|
93
|
-
outerColor: system.color.border.primary.default,
|
|
94
|
-
separation: 1,
|
|
95
|
-
}),
|
|
96
|
-
},
|
|
97
|
-
'&:disabled, &.disabled': {
|
|
98
|
-
[buttonStencil.vars.background]: system.color.bg.alt.default,
|
|
99
|
-
[buttonStencil.vars.border]: system.color.border.input.disabled,
|
|
100
|
-
[buttonStencil.vars.label]: system.color.fg.disabled,
|
|
101
|
-
[systemIconStencil.vars.color]: 'currentColor',
|
|
102
|
-
[pillCountStencil.vars.backgroundColor]: system.color.bg.alt.strong,
|
|
103
|
-
[pillCountStencil.vars.borderColor]: 'transparent',
|
|
104
|
-
},
|
|
105
|
-
}),
|
|
106
|
-
modifiers: {
|
|
107
|
-
variant: {
|
|
108
|
-
readOnly: {
|
|
109
|
-
border: `${px2rem(1)} solid ${system.color.border.container}`,
|
|
110
|
-
cursor: 'default',
|
|
111
|
-
[buttonStencil.vars.background]: system.color.bg.default,
|
|
112
|
-
'&:hover, &.hover': {
|
|
113
|
-
borderColor: system.color.border.container,
|
|
114
|
-
[buttonStencil.vars.background]: system.color.bg.default,
|
|
115
|
-
},
|
|
116
|
-
'&:focus-visible, &.focus': {
|
|
117
|
-
[buttonStencil.vars.background]: system.color.bg.default,
|
|
118
|
-
},
|
|
119
|
-
'&:active, &.active': {
|
|
120
|
-
[buttonStencil.vars.background]: system.color.bg.default,
|
|
121
|
-
},
|
|
122
|
-
'&:disabled, &.disabled': {
|
|
123
|
-
[buttonStencil.vars.background]: system.color.bg.default,
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
removable: {
|
|
127
|
-
'&:focus-visible, &.focus': {
|
|
128
|
-
[buttonStencil.vars.background]: system.color.bg.alt.default,
|
|
129
|
-
[buttonStencil.vars.border]: system.color.border.input.default,
|
|
130
|
-
[buttonStencil.vars.label]: system.color.fg.strong,
|
|
131
|
-
boxShadow: 'none',
|
|
132
|
-
},
|
|
133
|
-
'&:hover, &.hover': {
|
|
134
|
-
[buttonStencil.vars.background]: system.color.bg.alt.strong,
|
|
135
|
-
},
|
|
136
|
-
'&:active, &.active': {
|
|
137
|
-
[buttonStencil.vars.background]: system.color.bg.alt.stronger,
|
|
138
|
-
},
|
|
139
|
-
'&:disabled, &.disabled': {
|
|
140
|
-
[buttonStencil.vars.background]: system.color.bg.alt.default,
|
|
141
|
-
[systemIconStencil.vars.color]: 'currentColor',
|
|
142
|
-
},
|
|
143
|
-
cursor: 'default',
|
|
144
|
-
overflow: 'revert', // override BaseButton overflow styles so the click target exists outside the pill for removable
|
|
145
|
-
position: 'relative',
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* By default, a `Pill` renders an interactive element that accepts subcomponents. By "interactive"
|
|
153
|
-
* we mean that the Pill container is a focusable element (a `<button>`). All leading elements
|
|
154
|
-
* (icons or avatars) are intended to be descriptive, helping support the label. They should not
|
|
155
|
-
* receive focus.
|
|
156
|
-
*
|
|
157
|
-
* `Pill` is the container component. It also provides a React context model for its subcomponents.
|
|
158
|
-
* Based on the `variant` prop this component will render different styled `Pill`s.
|
|
159
|
-
*
|
|
160
|
-
* Example of read only:
|
|
161
|
-
*
|
|
162
|
-
* ```tsx
|
|
163
|
-
* <Pill variant="readOnly">This is a read only</Pill>
|
|
164
|
-
* ```
|
|
165
|
-
*
|
|
166
|
-
* Example of interactive:
|
|
167
|
-
*
|
|
168
|
-
* ```tsx
|
|
169
|
-
* <Pill onClick={() => console.log('clicked')}>
|
|
170
|
-
* <Pill.Avatar /> Regina Skeltor
|
|
171
|
-
* </Pill>
|
|
172
|
-
* ```
|
|
173
|
-
*
|
|
174
|
-
* Example of removable:
|
|
175
|
-
*
|
|
176
|
-
* ```tsx
|
|
177
|
-
* <Pill variant="removable">
|
|
178
|
-
* <Pill.Avatar /> Regina Skeltor
|
|
179
|
-
* <Pill.IconButton aria-label='Remove user' onClick={() => console.log('clicked')} />
|
|
180
|
-
* </Pill>
|
|
181
|
-
* ```
|
|
182
|
-
*
|
|
183
|
-
* If you set the `Pill` `variant` to `removable`, it will render a `<span>` element. You can then
|
|
184
|
-
* provide a `Pill.IconButton` that acts as the focus target. This creates a smaller, more
|
|
185
|
-
* intentional click target that prevents users from accidentally deleting an item.
|
|
186
|
-
*
|
|
187
|
-
* ```tsx
|
|
188
|
-
* <Pill variant="removable">
|
|
189
|
-
* Shoes
|
|
190
|
-
* <Pill.IconButton aria-label='Remove user' onClick={() => console.log('handle remove')} />
|
|
191
|
-
* </Pill>
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
export const Pill = createContainer('button')({
|
|
195
|
-
displayName: 'Pill',
|
|
196
|
-
modelHook: usePillModel,
|
|
197
|
-
subComponents: {
|
|
198
|
-
/**
|
|
199
|
-
* This component renders an avatar. It supports all props of the `Avatar` component.
|
|
200
|
-
*
|
|
201
|
-
* ```tsx
|
|
202
|
-
* <Pill variant="removable">
|
|
203
|
-
* <Pill.Avatar url={avatarUrl} />
|
|
204
|
-
* <Pill.Label>Regina Skeltor</Pill.Label>
|
|
205
|
-
* <Pill.IconButton aria-label='Remove user' onClick={() => console.log('handle remove')} />
|
|
206
|
-
* </Pill>
|
|
207
|
-
* ```
|
|
208
|
-
*/
|
|
209
|
-
Avatar: PillAvatar,
|
|
210
|
-
/**
|
|
211
|
-
* This component renders its `children` as the count.
|
|
212
|
-
*
|
|
213
|
-
* ```tsx
|
|
214
|
-
* <Pill onClick={() => console.warn('clicked')}>
|
|
215
|
-
* <Pill.Label>Shoes</Pill.Label>
|
|
216
|
-
* <Pill.Count>30</Pill.Count>
|
|
217
|
-
* </Pill>
|
|
218
|
-
* ```
|
|
219
|
-
*/
|
|
220
|
-
Count: PillCount,
|
|
221
|
-
/**
|
|
222
|
-
* This component renders an `icon`. By default it renders a `plusIcon` but it can be overridden by
|
|
223
|
-
* providing an icon to the `icon` prop. You must provide an `aria-label` for the icon.
|
|
224
|
-
*
|
|
225
|
-
* ```tsx
|
|
226
|
-
* <Pill onClick={() => console.warn('clicked')}>
|
|
227
|
-
* <Pill.Icon aria-label='Add user' />
|
|
228
|
-
* <Pill.Label>Regina Skeltor</Pill.Label>
|
|
229
|
-
* </Pill>
|
|
230
|
-
* ```
|
|
231
|
-
*/
|
|
232
|
-
Icon: PillIcon,
|
|
233
|
-
/**
|
|
234
|
-
* This component renders a custom icon button. It is only intended to be used with the
|
|
235
|
-
* `removable` variant. By default, it renders a `xSmallIcon` but can be overridden by providing
|
|
236
|
-
* an icon to the `icon` prop.
|
|
237
|
-
*
|
|
238
|
-
* ```tsx
|
|
239
|
-
* <Pill variant="removable">
|
|
240
|
-
* <Pill.Label>Pink Shirts</Pill.Label>
|
|
241
|
-
* <Pill.IconButton aria-label='Remove item' onClick={() => console.warn('clicked')} />
|
|
242
|
-
* </Pill>
|
|
243
|
-
* ```
|
|
244
|
-
*/
|
|
245
|
-
IconButton: PillIconButton,
|
|
246
|
-
/**
|
|
247
|
-
* This component renders a `<span>` that automatically handles overflow by rendering a tooltip.
|
|
248
|
-
* There's no need to use this component directly since the overflow is handled for you automatically unless you have an icon or other element.
|
|
249
|
-
*
|
|
250
|
-
* ```tsx
|
|
251
|
-
* <Pill variant="readOnly">
|
|
252
|
-
* <Pill.Label>Read-only</Pill.Label>
|
|
253
|
-
* </Pill>
|
|
254
|
-
* ```
|
|
255
|
-
*/
|
|
256
|
-
Label: PillLabel,
|
|
257
|
-
},
|
|
258
|
-
})<PillProps>(({variant, maxWidth = 200, children, ...elemProps}, Element, model) => {
|
|
259
|
-
const maxWidthCSSValue = typeof maxWidth === 'number' ? px2rem(maxWidth) : maxWidth;
|
|
260
|
-
|
|
261
|
-
const isReadOnly = variant === 'readOnly';
|
|
262
|
-
|
|
263
|
-
return variant?.match(/^(readOnly|removable)$/) ? (
|
|
264
|
-
<Box
|
|
265
|
-
as={Element !== 'button' ? Element : 'span'}
|
|
266
|
-
id={isReadOnly ? model.state.id : undefined}
|
|
267
|
-
{...mergeStyles(elemProps, [
|
|
268
|
-
model.state.disabled ? 'disabled' : undefined,
|
|
269
|
-
pillStencil({maxWidth: maxWidthCSSValue, variant}),
|
|
270
|
-
])}
|
|
271
|
-
>
|
|
272
|
-
{isReadOnly ? <PillLabel>{children}</PillLabel> : children}
|
|
273
|
-
</Box>
|
|
274
|
-
) : (
|
|
275
|
-
<Element
|
|
276
|
-
disabled={model.state.disabled}
|
|
277
|
-
{...mergeStyles(elemProps, [
|
|
278
|
-
model.state.disabled ? 'disabled' : undefined,
|
|
279
|
-
pillStencil({maxWidth: maxWidthCSSValue}),
|
|
280
|
-
])}
|
|
281
|
-
>
|
|
282
|
-
{children}
|
|
283
|
-
</Element>
|
|
284
|
-
);
|
|
285
|
-
});
|
package/pill/lib/PillAvatar.tsx
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {createSubcomponent} from '@workday/canvas-kit-react/common';
|
|
2
|
-
import {Avatar, AvatarProps, avatarStencil} from '@workday/canvas-kit-preview-react/avatar';
|
|
3
|
-
import {usePillModel} from './usePillModel';
|
|
4
|
-
import {createStencil, px2rem} from '@workday/canvas-kit-styling';
|
|
5
|
-
import {mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
6
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
7
|
-
|
|
8
|
-
export interface PillAvatarProps extends AvatarProps {}
|
|
9
|
-
|
|
10
|
-
export const pillAvatarStencil = createStencil({
|
|
11
|
-
extends: avatarStencil,
|
|
12
|
-
base: {
|
|
13
|
-
flex: '0 0 auto',
|
|
14
|
-
...system.type.subtext.small,
|
|
15
|
-
'&:disabled, &.disabled': {
|
|
16
|
-
opacity: system.opacity.disabled,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export const PillAvatar = createSubcomponent('div')({
|
|
22
|
-
modelHook: usePillModel,
|
|
23
|
-
})<PillAvatarProps>(({size, ...elemProps}: PillAvatarProps, Element, _model) => {
|
|
24
|
-
return (
|
|
25
|
-
<Avatar
|
|
26
|
-
isDecorative
|
|
27
|
-
as={Element}
|
|
28
|
-
size={px2rem(18)}
|
|
29
|
-
{...mergeStyles(elemProps, [
|
|
30
|
-
pillAvatarStencil(),
|
|
31
|
-
_model.state.disabled ? 'disabled' : undefined,
|
|
32
|
-
])}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
});
|
package/pill/lib/PillCount.tsx
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {createComponent} from '@workday/canvas-kit-react/common';
|
|
2
|
-
import {FlexProps, mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
3
|
-
import {calc, createStencil, cssVar, px2rem} from '@workday/canvas-kit-styling';
|
|
4
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
5
|
-
|
|
6
|
-
export interface PillCountProps extends FlexProps {}
|
|
7
|
-
|
|
8
|
-
export const pillCountStencil = createStencil({
|
|
9
|
-
vars: {
|
|
10
|
-
backgroundColor: '',
|
|
11
|
-
borderColor: '',
|
|
12
|
-
},
|
|
13
|
-
base: ({backgroundColor, borderColor}) => ({
|
|
14
|
-
borderStartStartRadius: system.shape.zero,
|
|
15
|
-
borderStartEndRadius: system.shape.x1,
|
|
16
|
-
borderEndStartRadius: system.shape.zero,
|
|
17
|
-
borderEndEndRadius: system.shape.x1,
|
|
18
|
-
borderWidth: px2rem(1),
|
|
19
|
-
borderInlineStartWidth: system.space.zero,
|
|
20
|
-
borderStyle: 'solid',
|
|
21
|
-
borderColor: cssVar(borderColor, system.color.border.transparent),
|
|
22
|
-
display: 'inline-flex',
|
|
23
|
-
alignItems: 'center',
|
|
24
|
-
justifyContent: 'center',
|
|
25
|
-
height: px2rem(22),
|
|
26
|
-
width: system.space.x6,
|
|
27
|
-
padding: `${system.space.zero} ${system.space.x1}`,
|
|
28
|
-
marginInlineEnd: calc.negate(system.space.x2),
|
|
29
|
-
marginInlineStart: system.space.x1,
|
|
30
|
-
backgroundColor: cssVar(backgroundColor, system.color.bg.alt.stronger),
|
|
31
|
-
flex: '0 0 auto',
|
|
32
|
-
}),
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
export const PillCount = createComponent('span')({
|
|
36
|
-
displayName: 'Pill.Count',
|
|
37
|
-
Component: ({children, ...elemProps}: PillCountProps, ref, Element) => {
|
|
38
|
-
return (
|
|
39
|
-
<Element ref={ref} {...mergeStyles(elemProps, pillCountStencil())}>
|
|
40
|
-
{children}
|
|
41
|
-
</Element>
|
|
42
|
-
);
|
|
43
|
-
},
|
|
44
|
-
});
|
package/pill/lib/PillIcon.tsx
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {createSubcomponent} from '@workday/canvas-kit-react/common';
|
|
2
|
-
|
|
3
|
-
import {SystemIcon, SystemIconProps, systemIconStencil} from '@workday/canvas-kit-react/icon';
|
|
4
|
-
import {usePillModel} from './usePillModel';
|
|
5
|
-
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
6
|
-
import {calc, createStencil, px2rem} from '@workday/canvas-kit-styling';
|
|
7
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
8
|
-
import {mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
9
|
-
|
|
10
|
-
export interface PillIconProps extends Partial<SystemIconProps> {}
|
|
11
|
-
|
|
12
|
-
export const pillIconStencil = createStencil({
|
|
13
|
-
extends: systemIconStencil,
|
|
14
|
-
base: {
|
|
15
|
-
marginInlineStart: calc.negate(system.space.x1),
|
|
16
|
-
[systemIconStencil.vars.size]: px2rem(20),
|
|
17
|
-
flex: '0 0 auto',
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export const PillIcon = createSubcomponent('span')({
|
|
22
|
-
modelHook: usePillModel,
|
|
23
|
-
})<PillIconProps>(({icon, ...elemProps}, Element) => {
|
|
24
|
-
return (
|
|
25
|
-
<SystemIcon
|
|
26
|
-
as={Element}
|
|
27
|
-
role="img"
|
|
28
|
-
icon={icon || plusIcon}
|
|
29
|
-
{...mergeStyles(elemProps, pillIconStencil())}
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
});
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {focusRing, createSubcomponent} from '@workday/canvas-kit-react/common';
|
|
2
|
-
import {SystemIcon, SystemIconProps, systemIconStencil} from '@workday/canvas-kit-react/icon';
|
|
3
|
-
import {usePillModel} from './usePillModel';
|
|
4
|
-
import {xSmallIcon} from '@workday/canvas-system-icons-web';
|
|
5
|
-
import {buttonStencil} from '@workday/canvas-kit-react/button';
|
|
6
|
-
import {calc, createStencil, px2rem} from '@workday/canvas-kit-styling';
|
|
7
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
8
|
-
import {mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
9
|
-
|
|
10
|
-
export interface PillIconButtonProps extends Partial<SystemIconProps> {
|
|
11
|
-
/**
|
|
12
|
-
* The aria label for the removable icon. You must provide a valid string to represent the action.
|
|
13
|
-
*/
|
|
14
|
-
'aria-label'?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const pillIconButtonStencil = createStencil({
|
|
18
|
-
extends: buttonStencil,
|
|
19
|
-
base: {
|
|
20
|
-
marginInlineEnd: calc.negate(px2rem(7)), // visually pull in the pill to the right size by -7px
|
|
21
|
-
marginInlineStart: calc.negate(px2rem(2)), // visually create space between label and the button by -2px
|
|
22
|
-
borderRadius: system.shape.half,
|
|
23
|
-
height: calc.add(system.space.x4, system.space.x1),
|
|
24
|
-
width: calc.add(system.space.x4, system.space.x1),
|
|
25
|
-
padding: system.space.zero,
|
|
26
|
-
overflow: 'visible',
|
|
27
|
-
flex: '0 0 auto',
|
|
28
|
-
[buttonStencil.vars.border]: system.color.border.transparent,
|
|
29
|
-
[buttonStencil.vars.background]: system.color.bg.alt.default,
|
|
30
|
-
[systemIconStencil.vars.color]: system.color.fg.strong,
|
|
31
|
-
[systemIconStencil.vars.size]: system.space.x6,
|
|
32
|
-
'::after': {
|
|
33
|
-
content: '""',
|
|
34
|
-
height: system.space.x8,
|
|
35
|
-
width: system.space.x8,
|
|
36
|
-
position: 'absolute',
|
|
37
|
-
left: calc.negate(px2rem(7)),
|
|
38
|
-
bottom: calc.negate(px2rem(7)),
|
|
39
|
-
margin: system.space.zero,
|
|
40
|
-
pointerEvents: 'all',
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
'&:focus-visible, &.focus': {
|
|
44
|
-
[buttonStencil.vars.border]: system.color.border.transparent,
|
|
45
|
-
[buttonStencil.vars.background]: system.color.bg.alt.default,
|
|
46
|
-
...focusRing({
|
|
47
|
-
innerColor: system.color.border.transparent,
|
|
48
|
-
}),
|
|
49
|
-
},
|
|
50
|
-
'&:hover, &.hover': {
|
|
51
|
-
[buttonStencil.vars.border]: system.color.border.transparent,
|
|
52
|
-
[buttonStencil.vars.background]: system.color.bg.alt.strong,
|
|
53
|
-
},
|
|
54
|
-
'&:active, &.active': {
|
|
55
|
-
[buttonStencil.vars.border]: system.color.border.transparent,
|
|
56
|
-
[buttonStencil.vars.background]: system.color.bg.alt.stronger,
|
|
57
|
-
},
|
|
58
|
-
'&:disabled, &.disabled': {
|
|
59
|
-
[buttonStencil.vars.border]: system.color.border.transparent,
|
|
60
|
-
[buttonStencil.vars.background]: system.color.bg.alt.default,
|
|
61
|
-
[systemIconStencil.vars.color]: system.color.fg.disabled,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
export const PillIconButton = createSubcomponent('button')({
|
|
67
|
-
modelHook: usePillModel,
|
|
68
|
-
})<PillIconButtonProps>(
|
|
69
|
-
({size, icon, children, 'aria-label': ariaLabel = '', ...elemProps}, Element, model) => {
|
|
70
|
-
return (
|
|
71
|
-
<Element
|
|
72
|
-
disabled={model.state.disabled}
|
|
73
|
-
aria-labelledby={`removable-${model.state.id} label-${model.state.id}`}
|
|
74
|
-
{...mergeStyles(elemProps, pillIconButtonStencil())}
|
|
75
|
-
>
|
|
76
|
-
<SystemIcon
|
|
77
|
-
aria-label={ariaLabel}
|
|
78
|
-
id={`removable-${model.state.id}`}
|
|
79
|
-
icon={icon || xSmallIcon}
|
|
80
|
-
aria-hidden // This works for Chrome but not needed in Safari
|
|
81
|
-
role="img"
|
|
82
|
-
/>
|
|
83
|
-
</Element>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
);
|
package/pill/lib/PillLabel.tsx
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {createSubcomponent} from '@workday/canvas-kit-react/common';
|
|
2
|
-
import {BoxProps, mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
3
|
-
import {OverflowTooltip, OverflowTooltipProps} from '@workday/canvas-kit-react/tooltip';
|
|
4
|
-
|
|
5
|
-
import {usePillModel} from './usePillModel';
|
|
6
|
-
|
|
7
|
-
import {createStencil} from '@workday/canvas-kit-styling';
|
|
8
|
-
|
|
9
|
-
export interface PillLabelProps extends BoxProps {
|
|
10
|
-
tooltipProps?: Omit<OverflowTooltipProps, 'children'>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const pillLabelStencil = createStencil({
|
|
14
|
-
base: {
|
|
15
|
-
flexShrink: 1,
|
|
16
|
-
whiteSpace: 'nowrap',
|
|
17
|
-
textOverflow: 'ellipsis',
|
|
18
|
-
overflow: 'hidden',
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export const PillLabel = createSubcomponent('span')({
|
|
23
|
-
modelHook: usePillModel,
|
|
24
|
-
})<PillLabelProps>(({tooltipProps, children, ...elemProps}, Element, model) => {
|
|
25
|
-
return (
|
|
26
|
-
<OverflowTooltip {...tooltipProps}>
|
|
27
|
-
<Element id={`label-${model.state.id}`} {...mergeStyles(elemProps, pillLabelStencil())}>
|
|
28
|
-
{children}
|
|
29
|
-
</Element>
|
|
30
|
-
</OverflowTooltip>
|
|
31
|
-
);
|
|
32
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {createModelHook, useUniqueId} from '@workday/canvas-kit-react/common';
|
|
2
|
-
|
|
3
|
-
export const usePillModel = createModelHook({
|
|
4
|
-
defaultConfig: {
|
|
5
|
-
/**
|
|
6
|
-
* Used to disable a pill and apply the correct styles.
|
|
7
|
-
*/
|
|
8
|
-
disabled: false,
|
|
9
|
-
/**
|
|
10
|
-
* ID used to add accessibility labels to pill elements.
|
|
11
|
-
* @default `useUniqueId()`
|
|
12
|
-
*/
|
|
13
|
-
id: '',
|
|
14
|
-
},
|
|
15
|
-
})(config => {
|
|
16
|
-
const id = useUniqueId(config.id);
|
|
17
|
-
const state = {
|
|
18
|
-
...config,
|
|
19
|
-
id,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
return {state, events: {}};
|
|
23
|
-
});
|