@workday/canvas-kit-docs 16.0.6 → 16.0.9

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.
@@ -1895,6 +1895,20 @@ module.exports = {specifications: [
1895
1895
  }
1896
1896
  ]
1897
1897
  },
1898
+ {
1899
+ "type": "describe",
1900
+ "name": "when a disabled item has focus and the menu is closed and reopened",
1901
+ "children": [
1902
+ {
1903
+ "type": "it",
1904
+ "name": "should move focus to the first item instead of the disabled item"
1905
+ },
1906
+ {
1907
+ "type": "it",
1908
+ "name": "should not leave focus on the disabled item"
1909
+ }
1910
+ ]
1911
+ },
1898
1912
  {
1899
1913
  "type": "describe",
1900
1914
  "name": "when the enter key is pressed",
@@ -1917,6 +1931,112 @@ module.exports = {specifications: [
1917
1931
  }
1918
1932
  ]
1919
1933
  },
1934
+ {
1935
+ "type": "describe",
1936
+ "name": "given the [Components/Popups/Menu, NestedSiblings] story is rendered",
1937
+ "children": [
1938
+ {
1939
+ "type": "describe",
1940
+ "name": "when the \"Second Item\" submenu is opened by hovering",
1941
+ "children": [
1942
+ {
1943
+ "type": "it",
1944
+ "name": "should set aria-expanded to true on \"Second Item\""
1945
+ },
1946
+ {
1947
+ "type": "describe",
1948
+ "name": "when the sibling \"Third Item\" is then hovered",
1949
+ "children": [
1950
+ {
1951
+ "type": "it",
1952
+ "name": "should close the \"Second Item\" submenu"
1953
+ },
1954
+ {
1955
+ "type": "it",
1956
+ "name": "should set aria-expanded to false on \"Second Item\""
1957
+ },
1958
+ {
1959
+ "type": "it",
1960
+ "name": "should leave only the root menu and one submenu open"
1961
+ },
1962
+ {
1963
+ "type": "describe",
1964
+ "name": "when the original \"Second Item\" is hovered again",
1965
+ "children": [
1966
+ {
1967
+ "type": "it",
1968
+ "name": "should close the \"Third Item\" submenu"
1969
+ },
1970
+ {
1971
+ "type": "it",
1972
+ "name": "should leave only the root menu and one submenu open"
1973
+ }
1974
+ ]
1975
+ }
1976
+ ]
1977
+ }
1978
+ ]
1979
+ },
1980
+ {
1981
+ "type": "describe",
1982
+ "name": "when a submenu is opened with the right arrow key",
1983
+ "children": [
1984
+ {
1985
+ "type": "it",
1986
+ "name": "should open the submenu"
1987
+ },
1988
+ {
1989
+ "type": "it",
1990
+ "name": "should keep the submenu open and move focus into it"
1991
+ },
1992
+ {
1993
+ "type": "describe",
1994
+ "name": "when the left arrow key is pressed",
1995
+ "children": [
1996
+ {
1997
+ "type": "it",
1998
+ "name": "should close the submenu"
1999
+ },
2000
+ {
2001
+ "type": "it",
2002
+ "name": "should return focus to the \"Second Item\" target"
2003
+ }
2004
+ ]
2005
+ }
2006
+ ]
2007
+ }
2008
+ ]
2009
+ },
2010
+ {
2011
+ "type": "describe",
2012
+ "name": "given the [Components/Popups/Menu, NestedDynamic] story is rendered",
2013
+ "children": [
2014
+ {
2015
+ "type": "describe",
2016
+ "name": "when hovering deeper into a chain of nested submenus",
2017
+ "children": [
2018
+ {
2019
+ "type": "it",
2020
+ "name": "should keep the ancestor submenu open"
2021
+ },
2022
+ {
2023
+ "type": "it",
2024
+ "name": "should keep every menu in the open chain visible"
2025
+ },
2026
+ {
2027
+ "type": "describe",
2028
+ "name": "when hovering back onto the ancestor item in the open trail",
2029
+ "children": [
2030
+ {
2031
+ "type": "it",
2032
+ "name": "should keep the open trail intact"
2033
+ }
2034
+ ]
2035
+ }
2036
+ ]
2037
+ }
2038
+ ]
2039
+ },
1920
2040
  {
1921
2041
  "type": "describe",
1922
2042
  "name": "given the [Testing/Popups/Menu, MenuWithFallbackPlacements] example is rendered",
@@ -18,11 +18,11 @@ export const packageJSONFile = `{
18
18
  "@emotion/react": "11.11.4",
19
19
  "@types/react": "18.2.60",
20
20
  "@types/react-dom": "18.2.19",
21
- "@workday/canvas-kit-labs-react": "16.0.6",
22
- "@workday/canvas-kit-preview-react": "16.0.6",
23
- "@workday/canvas-kit-react": "16.0.6",
24
- "@workday/canvas-kit-react-fonts": "^16.0.6",
25
- "@workday/canvas-kit-styling": "16.0.6",
21
+ "@workday/canvas-kit-labs-react": "16.0.9",
22
+ "@workday/canvas-kit-preview-react": "16.0.9",
23
+ "@workday/canvas-kit-react": "16.0.9",
24
+ "@workday/canvas-kit-react-fonts": "^16.0.9",
25
+ "@workday/canvas-kit-styling": "16.0.9",
26
26
  "@workday/canvas-system-icons-web": "^5.0.3",
27
27
  "@workday/canvas-expressive-icons-web": "1.0.1",
28
28
  "@workday/canvas-tokens-web": "4.4.0-beta.11"
@@ -19,11 +19,11 @@ export const packageJSONFile = `{
19
19
  "@emotion/react": "11.11.4",
20
20
  "@types/react": "18.2.60",
21
21
  "@types/react-dom": "18.2.19",
22
- "@workday/canvas-kit-labs-react": "16.0.6",
23
- "@workday/canvas-kit-preview-react": "16.0.6",
24
- "@workday/canvas-kit-react": "16.0.6",
25
- "@workday/canvas-kit-react-fonts": "^16.0.6",
26
- "@workday/canvas-kit-styling": "16.0.6",
22
+ "@workday/canvas-kit-labs-react": "16.0.9",
23
+ "@workday/canvas-kit-preview-react": "16.0.9",
24
+ "@workday/canvas-kit-react": "16.0.9",
25
+ "@workday/canvas-kit-react-fonts": "^16.0.9",
26
+ "@workday/canvas-kit-styling": "16.0.9",
27
27
  "@workday/canvas-system-icons-web": "^5.0.3",
28
28
  "@workday/canvas-expressive-icons-web": "1.0.1",
29
29
  "@workday/canvas-tokens-web": "4.4.0-beta.11"
@@ -34,6 +34,8 @@ yarn add @workday/canvas-kit-react
34
34
  `Menu` will automatically focus on the cursor item (first item by default). The `Menu` uses a menu
35
35
  model which composes a list model and a popup model and sets up accessibility features for you.
36
36
 
37
+ > **Note:** When content exceeds `60vh`, the menu content is clipped and the menu becomes scrollable.
38
+
37
39
  ### Alt Example
38
40
 
39
41
  The `alt` variant is designed for use on alternative page backgrounds (`system.color.bg.alt.default`). Use this variant to maintain proper visual hierarchy when placing components on colored backgrounds. While the default variant should be used on `system.color.bg.default` backgrounds, the `alt` variant ensures the component remains visually elevated on `system.color.bg.alt.default` backgrounds.
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+
3
+ import {Menu} from '@workday/canvas-kit-react/menu';
4
+ import {BodyText} from '@workday/canvas-kit-react/text';
5
+ import {system} from '@workday/canvas-tokens-web';
6
+
7
+ export default () => {
8
+ const [selected, setSelected] = React.useState('');
9
+ return (
10
+ <Menu
11
+ id="first-menu"
12
+ onSelect={data => {
13
+ setSelected(data.id);
14
+ }}
15
+ >
16
+ <Menu.Target>Open Menu</Menu.Target>
17
+ <Menu.Popper>
18
+ <Menu.Card>
19
+ <Menu.List>
20
+ <Menu.Item data-id="first-item">First Item</Menu.Item>
21
+ <Menu.Submenu id="second-menu">
22
+ <Menu.Submenu.TargetItem data-id="second-item">Second Item</Menu.Submenu.TargetItem>
23
+ <Menu.Submenu.Popper>
24
+ <Menu.Submenu.Card>
25
+ <Menu.Submenu.List>
26
+ <Menu.Submenu.Item data-id="second-first-sub-item">
27
+ Second: First Sub Item
28
+ </Menu.Submenu.Item>
29
+ <Menu.Submenu.Item data-id="second-second-sub-item">
30
+ Second: Second Sub Item
31
+ </Menu.Submenu.Item>
32
+ </Menu.Submenu.List>
33
+ </Menu.Submenu.Card>
34
+ </Menu.Submenu.Popper>
35
+ </Menu.Submenu>
36
+ <Menu.Submenu id="third-menu">
37
+ <Menu.Submenu.TargetItem data-id="third-item">Third Item</Menu.Submenu.TargetItem>
38
+ <Menu.Submenu.Popper>
39
+ <Menu.Submenu.Card>
40
+ <Menu.Submenu.List>
41
+ <Menu.Submenu.Item data-id="third-first-sub-item">
42
+ Third: First Sub Item
43
+ </Menu.Submenu.Item>
44
+ <Menu.Submenu.Item data-id="third-second-sub-item">
45
+ Third: Second Sub Item
46
+ </Menu.Submenu.Item>
47
+ </Menu.Submenu.List>
48
+ </Menu.Submenu.Card>
49
+ </Menu.Submenu.Popper>
50
+ </Menu.Submenu>
51
+ <Menu.Item data-id="fourth-item">Fourth Item</Menu.Item>
52
+ </Menu.List>
53
+ </Menu.Card>
54
+ </Menu.Popper>
55
+ <BodyText size="small" cs={{marginBlockStart: system.gap.md}}>
56
+ Selected: <span data-testid="output">{selected}</span>
57
+ </BodyText>
58
+ </Menu>
59
+ );
60
+ };
@@ -7,23 +7,24 @@ import {px2rem} from '@workday/canvas-kit-styling';
7
7
  import {system} from '@workday/canvas-tokens-web';
8
8
 
9
9
  type MyTabItem = {
10
- id: string;
10
+ contextId: string;
11
11
  text: React.ReactNode;
12
12
  contents: string;
13
13
  };
14
14
 
15
15
  export default () => {
16
16
  const [items] = React.useState<MyTabItem[]>([
17
- {id: 'first', text: 'First Tab', contents: 'Contents of First Tab'},
18
- {id: 'second', text: 'Second Tab', contents: 'Contents of Second Tab'},
19
- {id: 'third', text: 'Third Tab', contents: 'Contents of Third Tab'},
20
- {id: 'fourth', text: 'Fourth Tab', contents: 'Contents of Fourth Tab'},
21
- {id: 'fifth', text: 'Fifth Tab', contents: 'Contents of Fifth Tab'},
22
- {id: 'sixth', text: 'Sixth Tab', contents: 'Contents of Sixth Tab'},
23
- {id: 'seventh', text: 'Seventh Tab', contents: 'Contents of Seventh Tab'},
17
+ {contextId: 'first', text: 'First Tab', contents: 'Contents of First Tab'},
18
+ {contextId: 'second', text: 'Second Tab', contents: 'Contents of Second Tab'},
19
+ {contextId: 'third', text: 'Third Tab', contents: 'Contents of Third Tab'},
20
+ {contextId: 'fourth', text: 'Fourth Tab', contents: 'Contents of Fourth Tab'},
21
+ {contextId: 'fifth', text: 'Fifth Tab', contents: 'Contents of Fifth Tab'},
22
+ {contextId: 'sixth', text: 'Sixth Tab', contents: 'Contents of Sixth Tab'},
23
+ {contextId: 'seventh', text: 'Seventh Tab', contents: 'Contents of Seventh Tab'},
24
24
  ]);
25
25
  const model = useTabsModel({
26
26
  items,
27
+ getId: (item: MyTabItem) => item.contextId,
27
28
  });
28
29
  const [containerWidth, setContainerWidth] = React.useState('100%');
29
30
  return (
@@ -1,6 +1,7 @@
1
1
  import {ExampleCodeBlock, Specifications, SymbolDoc} from '@workday/canvas-kit-docs';
2
2
  import {InformationHighlight} from '@workday/canvas-kit-react/information-highlight';
3
3
  import {StatusIndicator} from '@workday/canvas-kit-preview-react/status-indicator';
4
+ import AIDisclosure from './examples/AIDisclosure';
4
5
  import CustomContent from './examples/CustomContent';
5
6
  import Default from './examples/Default';
6
7
  import DelayedTooltip from './examples/DelayedTooltip';
@@ -141,6 +142,15 @@ a dialog instead.
141
142
 
142
143
  <ExampleCodeBlock code={CustomContent} />
143
144
 
145
+ ### AI Disclosure
146
+
147
+ Use a tooltip to disclose when content or functionality is powered by AI. Pair an icon button with a
148
+ tooltip near the content it describes so users understand how it was produced before they act on it.
149
+ The tooltip labels the button, making the disclosure available to both sighted and screen reader
150
+ users.
151
+
152
+ <ExampleCodeBlock code={AIDisclosure} />
153
+
144
154
  ### Delayed Tooltip
145
155
 
146
156
  The default delay for showing and hiding a tooltip are 300ms and 100ms, respectively. You can
@@ -0,0 +1,38 @@
1
+ import {ExternalHyperlink, TertiaryButton} from '@workday/canvas-kit-react/button';
2
+ import {Card} from '@workday/canvas-kit-react/card';
3
+ import {Tooltip} from '@workday/canvas-kit-react/tooltip';
4
+ import {createStyles} from '@workday/canvas-kit-styling';
5
+ import {infoSparkleIcon} from '@workday/canvas-system-icons-web';
6
+ import {system} from '@workday/canvas-tokens-web';
7
+
8
+ const containerStyles = createStyles({
9
+ background: system.color.bg.alt.default,
10
+ padding: system.padding.xl,
11
+ });
12
+
13
+ export default () => {
14
+ return (
15
+ <div className={containerStyles}>
16
+ <Card>
17
+ <Card.Heading>
18
+ Giant Pacific Octopus
19
+ <Tooltip title="This content is generated by AI" variant="alt" placement="right-end">
20
+ <TertiaryButton
21
+ size="extraSmall"
22
+ icon={infoSparkleIcon}
23
+ aria-label="This functionality is powered by AI"
24
+ />
25
+ </Tooltip>
26
+ </Card.Heading>
27
+ <Card.Body>
28
+ The giant Pacific octopus (Enteroctopus dofleini), also known as the North Pacific giant
29
+ octopus, is a large marine cephalopod belonging to the genus Enteroctopus and
30
+ Enteroctopodidae family. –{' '}
31
+ <ExternalHyperlink href="https://en.wikipedia.org/wiki/Giant_Pacific_octopus">
32
+ View Source
33
+ </ExternalHyperlink>
34
+ </Card.Body>
35
+ </Card>
36
+ </div>
37
+ );
38
+ };
@@ -52,6 +52,11 @@ export default () => {
52
52
  <OverflowTooltip>
53
53
  <CustomContent />
54
54
  </OverflowTooltip>
55
+ <OverflowTooltip showDelay={2000} hideDelay={2000}>
56
+ <SecondaryButton cs={{maxWidth: px2rem(200)}}>
57
+ 2 second delay on show and hide content
58
+ </SecondaryButton>
59
+ </OverflowTooltip>
55
60
  </React.Fragment>
56
61
  );
57
62
  };
@@ -405,7 +405,9 @@ To style elements in the render function, we'll need to choose what elements to
405
405
  the example below, we're able to spread the parts directly to elements. The Stencil will generate
406
406
  the type and value most appropriate for the context the part is used. In the Stencil, the part is
407
407
  represented by a string that looks like `[data-part="{partValue}"]` and in the render function, it
408
- is an object that looks like `{'data-part': partValue}`.
408
+ is an object that looks like `{'data-part': partValue}`. That object also has a non-enumerable
409
+ `selector` property (`[data-part="{partValue}"]`) for targeting the part from another stencil's
410
+ style object without writing the attribute selector by hand.
409
411
 
410
412
  ```jsx
411
413
  import {createStencil, handleCsProp} from '@workday/canvas-kit-styling';
@@ -444,6 +446,22 @@ const MyButton = ({children, ...elemProps}) => {
444
446
  };
445
447
  ```
446
448
 
449
+ To target a part from another stencil, use `.selector`. Spreading the part onto an element still
450
+ only applies `data-part`.
451
+
452
+ ```jsx
453
+ const cardStencil = createStencil({
454
+ base: {
455
+ [`&:where(:has(${myButtonStencil.parts.icon.selector}))`]: {
456
+ paddingInlineStart: 0,
457
+ },
458
+ [`& ${myButtonStencil.parts.label.selector}`]: {
459
+ fontWeight: 700,
460
+ },
461
+ },
462
+ });
463
+ ```
464
+
447
465
  As a reusable component, you can use component parts to style elements that are not exposed in the
448
466
  API. Consumers can also use the type safe Stencil to target that element to style it as well. As a
449
467
  general rule, a Stencil maps to a component. Multiple Stencils per component usually means nested
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "16.0.6",
3
+ "version": "16.0.9",
4
4
  "description": "Documentation components of Canvas Kit components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -47,10 +47,10 @@
47
47
  "@stackblitz/sdk": "^1.11.0",
48
48
  "@storybook/csf": "0.0.1",
49
49
  "@workday/canvas-expressive-icons-web": "1.0.2",
50
- "@workday/canvas-kit-labs-react": "^16.0.6",
51
- "@workday/canvas-kit-preview-react": "^16.0.6",
52
- "@workday/canvas-kit-react": "^16.0.6",
53
- "@workday/canvas-kit-styling": "^16.0.6",
50
+ "@workday/canvas-kit-labs-react": "^16.0.9",
51
+ "@workday/canvas-kit-preview-react": "^16.0.9",
52
+ "@workday/canvas-kit-react": "^16.0.9",
53
+ "@workday/canvas-kit-styling": "^16.0.9",
54
54
  "@workday/canvas-system-icons-web": "^5.0.3",
55
55
  "@workday/canvas-tokens-web": "^4.4.0",
56
56
  "markdown-to-jsx": "^7.2.0",
@@ -63,5 +63,5 @@
63
63
  "mkdirp": "^1.0.3",
64
64
  "typescript": "5.0"
65
65
  },
66
- "gitHead": "66fbb19d5308fd96929a6bcad407016f71574a9d"
66
+ "gitHead": "83ec5bdb4736eabff2829149a705ed07f00af83f"
67
67
  }