@workday/canvas-kit-docs 16.2.1 → 16.2.5

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.
@@ -94223,7 +94223,7 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
94223
94223
  ]
94224
94224
  },
94225
94225
  "required": false,
94226
- "description": "Use this attribute when you have a `FormField` that is in an `Alert` | `Error` or `Required` state. This will add attach an `aria-describedby` to each radio input so that screen readers can read out the message attached to the form field.\nThe value of this attribute needs to match the value passed to `hintId` on the `FormField`.\n\n```tsx\n<FormField\n error=\"caution\"\n hintId=\"hint-alert\"\n hintText=\"Deep dish is an extra $2.99\"\n label=\"Choose Your Pizza Crust\"\n useFieldset={true}\n >\n <RadioGroup\n name=\"crust\"\n onChange={handleChange}\n initialValue={value}\n aria-describedby=\"hint-alert\"\n >\n <RadioGroup.RadioButton value=\"deep-dish\">Deep dish</RadioGroup.RadioButton>\n <RadioGroup.RadioButton value=\"thin\">Thin</RadioGroup.RadioButton>\n <RadioGroup.RadioButton value=\"gluten-free\">Gluten free</RadioGroup.RadioButton>\n <RadioGroup.RadioButton value=\"cauliflower\">Cauliflower</RadioGroup.RadioButton>\n </RadioGroup>\n</FormField>\n```",
94226
+ "description": "The id of hint or error text associated with each radio.\n\nDo not set this when radios are wrapped in `FormFieldGroup.Input`. `FormFieldGroup.Input`\nwrites `aria-describedby=\"hint-{id}\"` on each radio, and that value overrides\n`aria-describedby` set on `RadioGroup`. Put the message in `FormFieldGroup.Hint`.\n\n```tsx\n<FormFieldGroup error=\"caution\">\n <FormFieldGroup.Label>Choose Your Pizza Crust</FormFieldGroup.Label>\n <FormFieldGroup.Field>\n <FormFieldGroup.List as={RadioGroup} name=\"crust\" value={value} onChange={handleChange}>\n <FormFieldGroup.Input as={RadioGroup.RadioButton} value=\"deep-dish\">\n Deep dish\n </FormFieldGroup.Input>\n <FormFieldGroup.Input as={RadioGroup.RadioButton} value=\"thin\">\n Thin\n </FormFieldGroup.Input>\n </FormFieldGroup.List>\n <FormFieldGroup.Hint>Deep dish is an extra $2.99.</FormFieldGroup.Hint>\n </FormFieldGroup.Field>\n</FormFieldGroup>\n```",
94227
94227
  "declarations": [
94228
94228
  {
94229
94229
  "name": "aria-describedby",
@@ -94574,7 +94574,7 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
94574
94574
  ]
94575
94575
  },
94576
94576
  "required": false,
94577
- "description": "Use this attribute when you have a `FormField` that is in an `Alert` | `Error` or `Required` state. This will add attach an `aria-describedby` to each radio input so that screen readers can read out the message attached to the form field.\nThe value of this attribute needs to match the value passed to `hintId` on the `FormField`.\n\n```tsx\n<FormField\n error=\"caution\"\n hintId=\"hint-alert\"\n hintText=\"Deep dish is an extra $2.99\"\n label=\"Choose Your Pizza Crust\"\n useFieldset={true}\n >\n <RadioGroup\n name=\"crust\"\n onChange={handleChange}\n initialValue={value}\n aria-describedby=\"hint-alert\"\n >\n <RadioGroup.RadioButton value=\"deep-dish\">Deep dish</RadioGroup.RadioButton>\n <RadioGroup.RadioButton value=\"thin\">Thin</RadioGroup.RadioButton>\n <RadioGroup.RadioButton value=\"gluten-free\">Gluten free</RadioGroup.RadioButton>\n <RadioGroup.RadioButton value=\"cauliflower\">Cauliflower</RadioGroup.RadioButton>\n </RadioGroup>\n</FormField>\n```",
94577
+ "description": "The id of hint or error text associated with each radio.\n\nDo not set this when radios are wrapped in `FormFieldGroup.Input`. `FormFieldGroup.Input`\nwrites `aria-describedby=\"hint-{id}\"` on each radio, and that value overrides\n`aria-describedby` set on `RadioGroup`. Put the message in `FormFieldGroup.Hint`.\n\n```tsx\n<FormFieldGroup error=\"caution\">\n <FormFieldGroup.Label>Choose Your Pizza Crust</FormFieldGroup.Label>\n <FormFieldGroup.Field>\n <FormFieldGroup.List as={RadioGroup} name=\"crust\" value={value} onChange={handleChange}>\n <FormFieldGroup.Input as={RadioGroup.RadioButton} value=\"deep-dish\">\n Deep dish\n </FormFieldGroup.Input>\n <FormFieldGroup.Input as={RadioGroup.RadioButton} value=\"thin\">\n Thin\n </FormFieldGroup.Input>\n </FormFieldGroup.List>\n <FormFieldGroup.Hint>Deep dish is an extra $2.99.</FormFieldGroup.Hint>\n </FormFieldGroup.Field>\n</FormFieldGroup>\n```",
94578
94578
  "declarations": [
94579
94579
  {
94580
94580
  "name": "aria-describedby",
@@ -238101,7 +238101,7 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
238101
238101
  "value": "DOMRect"
238102
238102
  }
238103
238103
  },
238104
- "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`.",
238104
+ "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`. If an `anchorElement` is also provided, Popper listens to its\nscroll containers and uses it for clipping, so the Popper still updates when it scrolls.",
238105
238105
  "declarations": [
238106
238106
  {
238107
238107
  "name": "getAnchorClientRect",
@@ -271462,7 +271462,7 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
271462
271462
  "value": "DOMRect"
271463
271463
  }
271464
271464
  },
271465
- "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`.",
271465
+ "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`. If an `anchorElement` is also provided, Popper listens to its\nscroll containers and uses it for clipping, so the Popper still updates when it scrolls.",
271466
271466
  "declarations": [
271467
271467
  {
271468
271468
  "name": "getAnchorClientRect",
@@ -336715,6 +336715,31 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
336715
336715
  "name": "usePopupPopper"
336716
336716
  }
336717
336717
  },
336718
+ {
336719
+ "name": "menuPopperOffset",
336720
+ "fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/menu/lib/MenuPopper.tsx",
336721
+ "description": "The `[skidding, distance]` offset every menu popper sits at relative to its anchor.",
336722
+ "declarations": [
336723
+ {
336724
+ "name": "menuPopperOffset",
336725
+ "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/menu/lib/MenuPopper.tsx"
336726
+ }
336727
+ ],
336728
+ "tags": {},
336729
+ "type": {
336730
+ "kind": "tuple",
336731
+ "value": [
336732
+ {
336733
+ "kind": "primitive",
336734
+ "value": "number"
336735
+ },
336736
+ {
336737
+ "kind": "primitive",
336738
+ "value": "number"
336739
+ }
336740
+ ]
336741
+ }
336742
+ },
336718
336743
  {
336719
336744
  "name": "defaultMenuPopperOptions",
336720
336745
  "fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/menu/lib/MenuPopper.tsx",
@@ -336773,11 +336798,17 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
336773
336798
  "parameters": [],
336774
336799
  "members": [],
336775
336800
  "returnType": {
336776
- "kind": "array",
336777
- "value": {
336778
- "kind": "primitive",
336779
- "value": "number"
336780
- }
336801
+ "kind": "union",
336802
+ "value": [
336803
+ {
336804
+ "kind": "primitive",
336805
+ "value": "number"
336806
+ },
336807
+ {
336808
+ "kind": "primitive",
336809
+ "value": "number"
336810
+ }
336811
+ ]
336781
336812
  }
336782
336813
  },
336783
336814
  "type": {
@@ -336785,11 +336816,17 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
336785
336816
  "parameters": [],
336786
336817
  "members": [],
336787
336818
  "returnType": {
336788
- "kind": "array",
336789
- "value": {
336790
- "kind": "primitive",
336791
- "value": "number"
336792
- }
336819
+ "kind": "union",
336820
+ "value": [
336821
+ {
336822
+ "kind": "primitive",
336823
+ "value": "number"
336824
+ },
336825
+ {
336826
+ "kind": "primitive",
336827
+ "value": "number"
336828
+ }
336829
+ ]
336793
336830
  }
336794
336831
  },
336795
336832
  "required": true,
@@ -336815,11 +336852,17 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
336815
336852
  "parameters": [],
336816
336853
  "members": [],
336817
336854
  "returnType": {
336818
- "kind": "array",
336819
- "value": {
336820
- "kind": "primitive",
336821
- "value": "number"
336822
- }
336855
+ "kind": "union",
336856
+ "value": [
336857
+ {
336858
+ "kind": "primitive",
336859
+ "value": "number"
336860
+ },
336861
+ {
336862
+ "kind": "primitive",
336863
+ "value": "number"
336864
+ }
336865
+ ]
336823
336866
  }
336824
336867
  },
336825
336868
  "type": {
@@ -336827,11 +336870,17 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
336827
336870
  "parameters": [],
336828
336871
  "members": [],
336829
336872
  "returnType": {
336830
- "kind": "array",
336831
- "value": {
336832
- "kind": "primitive",
336833
- "value": "number"
336834
- }
336873
+ "kind": "union",
336874
+ "value": [
336875
+ {
336876
+ "kind": "primitive",
336877
+ "value": "number"
336878
+ },
336879
+ {
336880
+ "kind": "primitive",
336881
+ "value": "number"
336882
+ }
336883
+ ]
336835
336884
  }
336836
336885
  },
336837
336886
  "required": true,
@@ -336893,11 +336942,17 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
336893
336942
  "parameters": [],
336894
336943
  "members": [],
336895
336944
  "returnType": {
336896
- "kind": "array",
336897
- "value": {
336898
- "kind": "primitive",
336899
- "value": "number"
336900
- }
336945
+ "kind": "tuple",
336946
+ "value": [
336947
+ {
336948
+ "kind": "primitive",
336949
+ "value": "number"
336950
+ },
336951
+ {
336952
+ "kind": "primitive",
336953
+ "value": "number"
336954
+ }
336955
+ ]
336901
336956
  }
336902
336957
  },
336903
336958
  "description": "",
@@ -337069,7 +337124,7 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
337069
337124
  "value": "DOMRect"
337070
337125
  }
337071
337126
  },
337072
- "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`.",
337127
+ "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`. If an `anchorElement` is also provided, Popper listens to its\nscroll containers and uses it for clipping, so the Popper still updates when it scrolls.",
337073
337128
  "declarations": [
337074
337129
  {
337075
337130
  "name": "getAnchorClientRect",
@@ -338006,7 +338061,7 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
338006
338061
  "value": "DOMRect"
338007
338062
  }
338008
338063
  },
338009
- "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`.",
338064
+ "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`. If an `anchorElement` is also provided, Popper listens to its\nscroll containers and uses it for clipping, so the Popper still updates when it scrolls.",
338010
338065
  "declarations": [
338011
338066
  {
338012
338067
  "name": "getAnchorClientRect",
@@ -388034,7 +388089,7 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
388034
388089
  "value": "DOMRect"
388035
388090
  }
388036
388091
  },
388037
- "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`.",
388092
+ "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`. If an `anchorElement` is also provided, Popper listens to its\nscroll containers and uses it for clipping, so the Popper still updates when it scrolls.",
388038
388093
  "declarations": [
388039
388094
  {
388040
388095
  "name": "getAnchorClientRect",
@@ -393498,7 +393553,7 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
393498
393553
  "value": "DOMRect"
393499
393554
  }
393500
393555
  },
393501
- "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`.",
393556
+ "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`. If an `anchorElement` is also provided, Popper listens to its\nscroll containers and uses it for clipping, so the Popper still updates when it scrolls.",
393502
393557
  "declarations": [
393503
393558
  {
393504
393559
  "name": "getAnchorClientRect",
@@ -454265,7 +454320,7 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
454265
454320
  "value": "DOMRect"
454266
454321
  }
454267
454322
  },
454268
- "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`.",
454323
+ "description": "When provided, this optional callback will be used to determine positioning for the Popper element\ninstead of calling `getBoundingClientRect` on the `anchorElement` prop. Use this when you need\ncomplete control over positioning. When this prop is specified, it is safe to pass `null` into the\n`anchorElement` prop. If `null` is passed into the `anchorElement` prop, an `owner` will not be\nprovided for the `PopupStack`. If an `anchorElement` is also provided, Popper listens to its\nscroll containers and uses it for clipping, so the Popper still updates when it scrolls.",
454269
454324
  "declarations": [
454270
454325
  {
454271
454326
  "name": "getAnchorClientRect",
@@ -5969,6 +5969,282 @@ module.exports = {specifications: [
5969
5969
  }
5970
5970
  ]
5971
5971
  },
5972
+ {
5973
+ "type": "file",
5974
+ "name": "SubmenuPlacement",
5975
+ "children": [
5976
+ {
5977
+ "type": "describe",
5978
+ "name": "Submenu placement",
5979
+ "children": [
5980
+ {
5981
+ "type": "describe",
5982
+ "name": "given a scrollable ltr menu at the start edge",
5983
+ "children": [
5984
+ {
5985
+ "type": "it",
5986
+ "name": "should pass axe checks"
5987
+ },
5988
+ {
5989
+ "type": "it",
5990
+ "name": "should open beside the parent on the right"
5991
+ },
5992
+ {
5993
+ "type": "describe",
5994
+ "name": "when the parent menu is scrolled",
5995
+ "children": [
5996
+ {
5997
+ "type": "it",
5998
+ "name": "should remain beside the parent without covering it"
5999
+ }
6000
+ ]
6001
+ }
6002
+ ]
6003
+ },
6004
+ {
6005
+ "type": "describe",
6006
+ "name": "given a scrollable ltr menu at the end edge",
6007
+ "children": [
6008
+ {
6009
+ "type": "it",
6010
+ "name": "should pass axe checks"
6011
+ },
6012
+ {
6013
+ "type": "it",
6014
+ "name": "should open beside the parent on the left"
6015
+ },
6016
+ {
6017
+ "type": "describe",
6018
+ "name": "when the parent menu is scrolled",
6019
+ "children": [
6020
+ {
6021
+ "type": "it",
6022
+ "name": "should remain beside the parent without covering it"
6023
+ }
6024
+ ]
6025
+ }
6026
+ ]
6027
+ },
6028
+ {
6029
+ "type": "describe",
6030
+ "name": "given a scrollable rtl menu at the start edge",
6031
+ "children": [
6032
+ {
6033
+ "type": "it",
6034
+ "name": "should pass axe checks"
6035
+ },
6036
+ {
6037
+ "type": "it",
6038
+ "name": "should open beside the parent on the left"
6039
+ },
6040
+ {
6041
+ "type": "describe",
6042
+ "name": "when the parent menu is scrolled",
6043
+ "children": [
6044
+ {
6045
+ "type": "it",
6046
+ "name": "should remain beside the parent without covering it"
6047
+ }
6048
+ ]
6049
+ }
6050
+ ]
6051
+ },
6052
+ {
6053
+ "type": "describe",
6054
+ "name": "given a scrollable rtl menu at the end edge",
6055
+ "children": [
6056
+ {
6057
+ "type": "it",
6058
+ "name": "should pass axe checks"
6059
+ },
6060
+ {
6061
+ "type": "it",
6062
+ "name": "should open beside the parent on the right"
6063
+ },
6064
+ {
6065
+ "type": "describe",
6066
+ "name": "when the parent menu is scrolled",
6067
+ "children": [
6068
+ {
6069
+ "type": "it",
6070
+ "name": "should remain beside the parent without covering it"
6071
+ }
6072
+ ]
6073
+ }
6074
+ ]
6075
+ },
6076
+ {
6077
+ "type": "describe",
6078
+ "name": "given an explicit submenu placement",
6079
+ "children": [
6080
+ {
6081
+ "type": "it",
6082
+ "name": "should preserve the custom placement"
6083
+ },
6084
+ {
6085
+ "type": "it",
6086
+ "name": "should pass axe checks"
6087
+ }
6088
+ ]
6089
+ },
6090
+ {
6091
+ "type": "describe",
6092
+ "name": "given an empty fallback list at the right edge",
6093
+ "children": [
6094
+ {
6095
+ "type": "it",
6096
+ "name": "should still allow the opposite placement"
6097
+ },
6098
+ {
6099
+ "type": "it",
6100
+ "name": "should pass axe checks"
6101
+ }
6102
+ ]
6103
+ },
6104
+ {
6105
+ "type": "describe",
6106
+ "name": "given custom Popper options",
6107
+ "children": [
6108
+ {
6109
+ "type": "it",
6110
+ "name": "should preserve the custom offset from the parent menu"
6111
+ },
6112
+ {
6113
+ "type": "it",
6114
+ "name": "should pass axe checks"
6115
+ }
6116
+ ]
6117
+ },
6118
+ {
6119
+ "type": "describe",
6120
+ "name": "given a ltr viewport too narrow for either side",
6121
+ "children": [
6122
+ {
6123
+ "type": "it",
6124
+ "name": "should pass axe checks"
6125
+ },
6126
+ {
6127
+ "type": "it",
6128
+ "name": "should fall back below the parent"
6129
+ },
6130
+ {
6131
+ "type": "it",
6132
+ "name": "should align with the parent's left edge"
6133
+ },
6134
+ {
6135
+ "type": "it",
6136
+ "name": "should stay inside the viewport horizontally"
6137
+ }
6138
+ ]
6139
+ },
6140
+ {
6141
+ "type": "describe",
6142
+ "name": "given a rtl viewport too narrow for either side",
6143
+ "children": [
6144
+ {
6145
+ "type": "it",
6146
+ "name": "should pass axe checks"
6147
+ },
6148
+ {
6149
+ "type": "it",
6150
+ "name": "should fall back below the parent"
6151
+ },
6152
+ {
6153
+ "type": "it",
6154
+ "name": "should align with the parent's right edge"
6155
+ },
6156
+ {
6157
+ "type": "it",
6158
+ "name": "should stay inside the viewport horizontally"
6159
+ }
6160
+ ]
6161
+ },
6162
+ {
6163
+ "type": "describe",
6164
+ "name": "given a parent menu near the bottom of a narrow viewport",
6165
+ "children": [
6166
+ {
6167
+ "type": "it",
6168
+ "name": "should pass axe checks"
6169
+ },
6170
+ {
6171
+ "type": "it",
6172
+ "name": "should fall back above the parent"
6173
+ }
6174
+ ]
6175
+ },
6176
+ {
6177
+ "type": "describe",
6178
+ "name": "given a 320x568 viewport too short to clear the parent",
6179
+ "children": [
6180
+ {
6181
+ "type": "it",
6182
+ "name": "should pass axe checks"
6183
+ },
6184
+ {
6185
+ "type": "it",
6186
+ "name": "should use bottom-start"
6187
+ },
6188
+ {
6189
+ "type": "it",
6190
+ "name": "should stay inside the viewport"
6191
+ },
6192
+ {
6193
+ "type": "describe",
6194
+ "name": "when the parent menu is then scrolled",
6195
+ "children": [
6196
+ {
6197
+ "type": "it",
6198
+ "name": "should keep its placement"
6199
+ },
6200
+ {
6201
+ "type": "it",
6202
+ "name": "should stay inside the viewport"
6203
+ },
6204
+ {
6205
+ "type": "it",
6206
+ "name": "should not move while the parent keeps scrolling"
6207
+ }
6208
+ ]
6209
+ }
6210
+ ]
6211
+ },
6212
+ {
6213
+ "type": "describe",
6214
+ "name": "given a 360x568 viewport too short to clear the parent",
6215
+ "children": [
6216
+ {
6217
+ "type": "it",
6218
+ "name": "should pass axe checks"
6219
+ },
6220
+ {
6221
+ "type": "it",
6222
+ "name": "should use right-start"
6223
+ },
6224
+ {
6225
+ "type": "it",
6226
+ "name": "should stay inside the viewport"
6227
+ },
6228
+ {
6229
+ "type": "describe",
6230
+ "name": "when the parent menu is then scrolled",
6231
+ "children": [
6232
+ {
6233
+ "type": "it",
6234
+ "name": "should keep its placement"
6235
+ },
6236
+ {
6237
+ "type": "it",
6238
+ "name": "should stay inside the viewport"
6239
+ }
6240
+ ]
6241
+ }
6242
+ ]
6243
+ }
6244
+ ]
6245
+ }
6246
+ ]
6247
+ },
5972
6248
  {
5973
6249
  "type": "file",
5974
6250
  "name": "Switch",
@@ -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.2.1",
22
- "@workday/canvas-kit-preview-react": "16.2.1",
23
- "@workday/canvas-kit-react": "16.2.1",
24
- "@workday/canvas-kit-react-fonts": "^16.2.1",
25
- "@workday/canvas-kit-styling": "16.2.1",
21
+ "@workday/canvas-kit-labs-react": "16.2.5",
22
+ "@workday/canvas-kit-preview-react": "16.2.5",
23
+ "@workday/canvas-kit-react": "16.2.5",
24
+ "@workday/canvas-kit-react-fonts": "^16.2.5",
25
+ "@workday/canvas-kit-styling": "16.2.5",
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.2.1",
23
- "@workday/canvas-kit-preview-react": "16.2.1",
24
- "@workday/canvas-kit-react": "16.2.1",
25
- "@workday/canvas-kit-react-fonts": "^16.2.1",
26
- "@workday/canvas-kit-styling": "16.2.1",
22
+ "@workday/canvas-kit-labs-react": "16.2.5",
23
+ "@workday/canvas-kit-preview-react": "16.2.5",
24
+ "@workday/canvas-kit-react": "16.2.5",
25
+ "@workday/canvas-kit-react-fonts": "^16.2.5",
26
+ "@workday/canvas-kit-styling": "16.2.5",
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"
@@ -2,14 +2,14 @@ import {ExampleCodeBlock, SymbolDoc} from '@workday/canvas-kit-docs';
2
2
 
3
3
  import Basic from './examples/Basic';
4
4
  import Caution from './examples/Caution';
5
+ import Custom from './examples/Custom';
6
+ import Disabled from './examples/Disabled';
5
7
  import Error from './examples/Error';
6
8
  import Inverse from './examples/Inverse';
7
9
  import LabelPosition from './examples/LabelPosition';
8
10
  import NoValue from './examples/NoValue';
9
11
  import RefForwarding from './examples/RefForwarding';
10
- import Disabled from './examples/Disabled';
11
12
  import Required from './examples/Required';
12
- import Custom from './examples/Custom';
13
13
  import StandaloneRadio from './examples/StandaloneRadio';
14
14
 
15
15
 
@@ -32,22 +32,20 @@ yarn add @workday/canvas-kit-preview-react
32
32
  Our radio component includes a `RadioGroup` container and `RadioGroup.RadioButton`, which renders an
33
33
  individual radio button. Nest related `RadioGroup.RadioButton` buttons within a `RadioGroup` and
34
34
  provide a `name` prop to the `RadioGroup` to group the radio buttons together. Each
35
- `RadioGroup.Radio` must have a unique `value`. This value is used in conjunction with the `value`
36
- prop set on the `RadioGroup` to determine which radio button is selected. To tie it all together,
37
- provide an `onChange` handler to the `RadioGroup` to track the selected value as it changes.
35
+ `RadioGroup.RadioButton` must have a unique `value`. This value is used in conjunction with the
36
+ `value` prop set on the `RadioGroup` to determine which radio button is selected. To tie it all
37
+ together, provide an `onChange` handler to the `RadioGroup` to track the selected value as it
38
+ changes.
38
39
 
39
- `RadioGroup` should be used in tandem with [Form Field](/components/inputs/form-field/) where the
40
- `useFieldset` prop is set to `true` to meet accessibility standards. This ensures the `label` text
41
- from `FormField` is attached to the `RadioGroup` and read out as a group for voiceover.
40
+ `RadioGroup` should be used in tandem with
41
+ [FormFieldGroup](/components/inputs/form-field/#accessibility). `FormFieldGroup.Label` names the
42
+ group, and `FormFieldGroup.Input` associates hint, error, and required state with each radio.
42
43
 
43
44
  <ExampleCodeBlock code={Basic} />
44
45
 
45
46
  Our example uses [React state](<(https://react.dev/learn/state-a-components-memory)>) to track the
46
47
  value of the `RadioGroup`.
47
48
 
48
- `RadioGroup` and `RadioGroup.Radio` support keyboard navigation through the proper use of WAI-ARIA
49
- [properties](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/radiogroup_role#associated_wai-aria_roles_states_and_properties).
50
-
51
49
  ### Inverse
52
50
 
53
51
  Set the `variant` prop of `RadioGroup.RadioButton` to `inverse` to ensure proper contrast on dark
@@ -78,7 +76,7 @@ input component. By default, the orientation will be set to `vertical`.
78
76
 
79
77
  ### Required
80
78
 
81
- Set the `required` prop of the wrapping `FormField` to `true` to indicate that the field is
79
+ Set the `isRequired` prop of the wrapping `FormFieldGroup` to `true` to indicate that the field is
82
80
  required. Labels for required fields are suffixed by a red asterisk.
83
81
 
84
82
  <ExampleCodeBlock code={Required} />
@@ -110,12 +108,9 @@ some behavior handled for you.
110
108
 
111
109
  ### Error States
112
110
 
113
- Set the `error` prop of the wrapping `FormField` to `"caution"` or
114
- `"error"` to set the `RadioGroup` to the alert or error state, respectively. You
115
- will also need to set the `hintId` and `hintText` props on the `FormField` to meet accessibility
116
- standards. You must set an `aria-describedby` attribute on the `RadioGroup` element that matches the
117
- value of `hintId` set on the `FormField` element. These attributes ensure that the alert message is
118
- associated to the `RadioGroup` and read out by voiceover.
111
+ Set the `error` prop of the wrapping `FormFieldGroup` to `"caution"` or `"error"` to set the group
112
+ to the alert or error state. Put the message in `FormFieldGroup.Hint`. `FormFieldGroup.Input`
113
+ associates that text with each radio.
119
114
 
120
115
  #### Caution
121
116
 
@@ -141,6 +136,126 @@ Radio and its subcomponents support custom styling via the `cs` prop. For more i
141
136
  our
142
137
  ["How To Customize Styles"](https://workday.github.io/canvas-kit/?path=/docs/styling-guides-customizing-styles--docs).
143
138
 
139
+ ## Accessibility
140
+
141
+ The primary accessibility goal is to ensure users can identify the radio group and each option,
142
+ determine which option is selected, and hear associated hints, errors, and required state when a
143
+ radio receives focus. Use **Radio** when the user must choose one option from a list. For
144
+ independent options, use
145
+ [**Checkbox**](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-checkbox--docs)
146
+ instead.
147
+
148
+ ### Minimum Accessible Structure
149
+
150
+ The following matches the [Basic Example](#basic-example): a **`FormFieldGroup`** with
151
+ **`FormFieldGroup.List as={RadioGroup}`**, and two or more
152
+ **`FormFieldGroup.Input as={RadioGroup.RadioButton}`** options.
153
+
154
+ ```tsx
155
+ import {RadioGroup} from '@workday/canvas-kit-preview-react/radio';
156
+ import {FormFieldGroup} from '@workday/canvas-kit-react/form-field';
157
+
158
+ <FormFieldGroup>
159
+ <FormFieldGroup.Label>Choose Your Pizza Crust</FormFieldGroup.Label>
160
+ <FormFieldGroup.Field>
161
+ <FormFieldGroup.List as={RadioGroup}>
162
+ <FormFieldGroup.Input as={RadioGroup.RadioButton}>Deep dish</FormFieldGroup.Input>
163
+ <FormFieldGroup.Input as={RadioGroup.RadioButton}>Thin</FormFieldGroup.Input>
164
+ </FormFieldGroup.List>
165
+ </FormFieldGroup.Field>
166
+ </FormFieldGroup>;
167
+ ```
168
+
169
+ Each option needs visible text. See the [Basic Example](#basic-example) for selection behavior.
170
+
171
+ ### Built-in Behaviors
172
+
173
+ Canvas Kit applies these automatically when you compose **`FormFieldGroup`** with **`RadioGroup`**.
174
+ **Do not duplicate them** in consuming code.
175
+
176
+ **ARIA and DOM** (_applied by `RadioGroup` and `FormFieldGroup`_):
177
+
178
+ - **`RadioGroup`**: Renders a `div`. It does not set `role="radiogroup"`.
179
+ - **`RadioGroup.RadioButton`**: Renders a `<label>` around `<input type="radio">` and the visible
180
+ text. The wrapping `<label>` is the association, so an `htmlFor` pairing is not needed. That text
181
+ is the option's accessible name, and clicking it selects the radio.
182
+
183
+ **Keyboard** (_native radio behavior_):
184
+
185
+ **`RadioGroup`** uses native radio keyboard behavior. <kbd>Tab</kbd> moves to the selected radio, or
186
+ to the first radio when none is selected, and then leaves the group. Arrow keys move and select
187
+ within the group.
188
+
189
+ **Screen reader expectations** (_when built-in behaviors are used as intended_):
190
+
191
+ - On focus, assistive technology announces the group name from **`FormFieldGroup.Label`**, along
192
+ with the option name, radio role, and checked state.
193
+ - When applicable, it also announces required state, invalid state (`error="error"`), and hint or
194
+ error text. Caution does not set `aria-invalid`.
195
+ - Disabled radios are announced as unavailable.
196
+
197
+ For group, hint, error, and required association, see
198
+ [FormField's Built-in Behaviors](/components/inputs/form-field/#built-in-behaviors).
199
+
200
+ ### Accessibility Requirements
201
+
202
+ Required in application code for an accessible Radio group. Rows marked _(conditional)_ apply only
203
+ when the situation matches—otherwise omit.
204
+
205
+ **If no design spec is provided:** use a visible **`FormFieldGroup.Label`**. On
206
+ **`FormFieldGroup.List as={RadioGroup}`**, set a shared **`name`** and render two or more
207
+ **`RadioGroup.RadioButton`** options with visible text and their own **`value`**. Omit **`error`**,
208
+ **`isRequired`**, **`FormFieldGroup.Hint`**, **`disabled`**, **`aria-describedby`** on
209
+ **`RadioGroup`**, **`error`** on **`RadioGroup`**, a **`ref`**, and **`StyledRadioButton`** unless
210
+ the spec requires them.
211
+
212
+ **Programmatic focus** _(conditional — omit by default)_:
213
+
214
+ Attach a **`ref`** only when the product must move focus to a radio after an action. Do not attach a
215
+ **`ref`** or call `focus()` unless the design or developer asks for it. See
216
+ [Ref Forwarding](#ref-forwarding).
217
+
218
+ | Requirement | How to satisfy |
219
+ | ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
220
+ | Group and option names | Use **`FormFieldGroup`** with a visible **`FormFieldGroup.Label`**. Render **`FormFieldGroup.List as={RadioGroup}`** with a shared **`name`**, and give every **`FormFieldGroup.Input as={RadioGroup.RadioButton}`** visible text and its own **`value`**. The shared **`name`** groups the inputs, and each option **`value`** is what the selected state matches. See [Basic Example](#basic-example). |
221
+ | Error state _(conditional)_ | When the selection is invalid, set `error="error"` on **`FormFieldGroup`** and prefix **`FormFieldGroup.Hint`** with "Error:". See [Error States](#error-states). |
222
+ | Hint, caution, or required _(conditional)_ | On **`FormFieldGroup`**, use **`FormFieldGroup.Hint`** for hint text, `error="caution"` for caution, and **`isRequired`** for required state, only when the spec includes that state. See [Required](#required) and [FormField accessibility](/components/inputs/form-field/#accessibility). |
223
+ | Disabled _(conditional)_ | Set **`disabled`** on an unavailable **`RadioGroup.RadioButton`**. Never disable the selected radio. See [Disabled](#disabled). |
224
+
225
+ **Summary for code generation:**
226
+
227
+ - **REQUIRED:** **`FormFieldGroup`**, visible **`FormFieldGroup.Label`**,
228
+ **`FormFieldGroup.List as={RadioGroup}`** with a shared **`name`**, and two or more
229
+ **`RadioGroup.RadioButton`** options, each with visible text and its own **`value`**
230
+ - **CONDITIONAL:** when the selection is invalid, `error="error"` on **`FormFieldGroup`** and
231
+ **`FormFieldGroup.Hint`** prefixed with "Error:". Hint text, `error="caution"`, and
232
+ **`isRequired`** only when the spec includes that state. Also **`disabled`** (not on the selected
233
+ radio). See [FormField accessibility](/components/inputs/form-field/#accessibility) for group
234
+ hint, caution, and required.
235
+
236
+ ### Anti-Patterns
237
+
238
+ Do **not** generate code that does the following (see **Accessibility Requirements** above for what
239
+ to supply instead):
240
+
241
+ - Add `role="radiogroup"` to **`RadioGroup`** — **`FormFieldGroup`** provides the group semantics
242
+ - Manually set `aria-checked`, `aria-invalid`, `aria-required`, or `aria-describedby` —
243
+ **`RadioGroup`** and **`FormFieldGroup.Input`** wire these attributes
244
+ - Use **`FormField`** with `useFieldset`, or set `hintId` and `hintText` — group radios with
245
+ **`FormFieldGroup`** and put the message in **`FormFieldGroup.Hint`**
246
+ - Wrap radios in **`FormField.Input`** — use **`FormFieldGroup.Input as={RadioGroup.RadioButton}`**
247
+ - Use **`StyledRadioButton`** unless the spec requires a radio outside **`RadioGroup`**. In that
248
+ case supply accessible option and group names and the necessary behavior. See
249
+ [Standalone Radio Button](#standalone-radio-button)
250
+ - Intercept <kbd>Tab</kbd> or arrow keys — native radio behavior moves and selects within the group
251
+ - Set **`disabled`** on the selected radio — that removes the group's tab stop, so keyboard users
252
+ cannot move within the group. See [Disabled](#disabled)
253
+ - Set **`error`** on **`RadioGroup`** — set it on **`FormFieldGroup`** so Canvas Kit provides both
254
+ the visual and accessible error state. See [Error States](#error-states)
255
+ - Rely on color alone for an error or caution — include **`FormFieldGroup.Hint`**. Use
256
+ `error="error"` when the selection is invalid so `aria-invalid` is set. See
257
+ [Error States](#error-states)
258
+
144
259
  ## Component API
145
260
 
146
261
  <SymbolDoc name="RadioGroup" fileName="/preview-react/" />
@@ -20,7 +20,6 @@ export default () => {
20
20
  name="crust-required"
21
21
  onChange={handleChange}
22
22
  value={value}
23
- aria-describedby="choose-crust"
24
23
  >
25
24
  <FormFieldGroup.Input as={RadioGroup.RadioButton} value="deep-dish">
26
25
  Deep dish
@@ -75,6 +75,125 @@ Switch supports right-to-left languages when specified in the CanvasProvider the
75
75
  Switch supports custom styling via the `cs` prop. For more information, check our
76
76
  ["How To Customize Styles"](https://workday.github.io/canvas-kit/?path=/docs/styling-guides-customizing-styles--docs).
77
77
 
78
+ ## Accessibility
79
+
80
+ The primary accessibility goal is a visible, programmatically determinable name and an on or off
81
+ state that assistive technology can expose. Use **Switch** for a single setting that takes effect
82
+ immediately when toggled (for example, "Dark Mode"). When the user selects one or more options that
83
+ are applied on form submission, use [**Checkbox**](/components/inputs/checkbox/) instead. **Switch**
84
+ does not render its own `<label>`, so it relies on **`FormField`** for its name, hint, error, and
85
+ required wiring — see [FormField's accessibility documentation](/components/inputs/form-field/#accessibility).
86
+
87
+ ### Minimum Accessible Structure
88
+
89
+ The following matches the [Basic Example](#basic-example). Every **Switch** needs **`FormField`**, a
90
+ visible **`FormField.Label`**, and **`FormField.Input as={Switch}`** inside **`FormField.Field`**.
91
+
92
+ ```tsx
93
+ import React from 'react';
94
+
95
+ import {Switch} from '@workday/canvas-kit-preview-react/switch';
96
+ import {FormField} from '@workday/canvas-kit-react/form-field';
97
+
98
+ const Example = () => {
99
+
100
+ return (
101
+ <FormField>
102
+ <FormField.Label>Dark Mode</FormField.Label>
103
+ <FormField.Field>
104
+ <FormField.Input as={Switch} />
105
+ </FormField.Field>
106
+ </FormField>
107
+ );
108
+ };
109
+ ```
110
+
111
+ ### Built-in Behaviors
112
+
113
+ Canvas Kit applies these automatically when you compose **Switch** with **`FormField`**
114
+ subcomponents. **Do not duplicate them** in consuming code.
115
+
116
+ **ARIA and DOM** (_applied by Switch and FormField_):
117
+
118
+ - **`Switch`**: Renders a native `<input type="checkbox">` with `role="switch"`. The native `checked`
119
+ state is exposed to assistive technology as on or off, so no `aria-checked` is needed. Canvas Kit
120
+ assigns an `id` with `useUniqueId` unless you pass **`id`**.
121
+ - **Track, thumb, and check/x icon**: Purely visual. The icon is a Canvas Kit **`SystemIcon`**, whose
122
+ SVG markup sets `role="presentation"` and `focusable="false"`, so it is not announced.
123
+ - **`disabled`**: Maps to the native `disabled` attribute.
124
+
125
+ **Keyboard** (_native checkbox behavior_):
126
+
127
+ **`Switch`** uses native `<input type="checkbox">` keyboard behavior (tab order and Space to
128
+ toggle). Do not intercept <kbd>Space</kbd> or otherwise prevent the native toggle.
129
+
130
+ **Screen reader expectations** (_when built-in behaviors are used as intended_):
131
+
132
+ - On focus, assistive technology announces the **`FormField.Label`** text, the "switch" role, and
133
+ the on or off state; when applicable, required state, invalid state (`error="error"`), and
134
+ **`FormField.Hint`** text via `aria-describedby`
135
+ - Toggling announces the new on or off state
136
+ - The Caution state is visual only — `aria-invalid` is **not** set for `error="caution"`
137
+ - Disabled switches are skipped in the tab order and may be announced as unavailable
138
+
139
+ For label, hint, and error association details, see
140
+ [FormField's Built-in Behaviors](/components/inputs/form-field/#built-in-behaviors).
141
+
142
+ ### Accessibility Requirements
143
+
144
+ Required in application code for an accessible **Switch**. Rows marked _(conditional)_ apply only
145
+ when the situation matches—otherwise omit.
146
+
147
+ **If no design spec is provided:** use a visible **`FormField.Label`**, wrap the control with
148
+ **`FormField.Input as={Switch}`** inside **`FormField.Field`**, and control it with **`checked`** and
149
+ **`onChange`**. Omit **`isRequired`**, **`error`**, **`FormField.Hint`**, **`disabled`**,
150
+ **`isHidden`**, a custom **`id`**, and a **`ref`** unless the spec requires them.
151
+
152
+ **Programmatic focus** _(conditional — omit by default)_:
153
+
154
+ Attach a `ref` only when the product must move focus to the Switch after an action. Do not attach a
155
+ `ref` or call `focus()` unless the design or developer asks for it. See
156
+ [Ref Forwarding](#ref-forwarding) under Usage for a complete Storybook example.
157
+
158
+ | Requirement | How to satisfy |
159
+ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
160
+ | Accessible name | Visible, non-empty **`FormField.Label`** describing the setting (for example, "Dark Mode"), not the state ("On"/"Off"). Use **`FormField.Label isHidden`** only when an equally clear visible alternative exists |
161
+ | Input wiring | **`FormField.Input as={Switch}`** inside **`FormField.Field`**. See [FormField accessibility](/components/inputs/form-field/#accessibility) for label, hint, error, and required wiring |
162
+ | Required state _(conditional)_ | `isRequired` on **`FormField`** only when the form cannot be submitted unless the Switch is on — native `required` on a checkbox means it must be checked |
163
+ | Disabled _(conditional)_ | `disabled` on **`FormField.Input`** when the spec marks the setting unavailable. See [Disabled](#disabled) |
164
+ | Programmatic focus _(conditional)_ | `ref` on **`FormField.Input`** and call `focus()` when the product requires it — omit by default (see **Programmatic focus** above and [Ref Forwarding](#ref-forwarding)) |
165
+
166
+ **Summary for code generation:**
167
+
168
+ - **REQUIRED:** **`FormField`** + visible **`FormField.Label`** + **`FormField.Input as={Switch}`**
169
+ inside **`FormField.Field`**
170
+ - **CONDITIONAL:** `isRequired` only when the Switch must be on; `disabled`; programmatic focus via
171
+ `ref`. See [FormField accessibility](/components/inputs/form-field/#accessibility) for shared
172
+ FormField conditionals (hint, error, and caution).
173
+
174
+ ### Anti-Patterns
175
+
176
+ Do **not** generate code that does the following (see **Accessibility Requirements** above for what
177
+ to supply instead):
178
+
179
+ - Render **Switch** without **`FormField`** and **`FormField.Label`** — **Switch** has no built-in
180
+ label. For shared FormField anti-patterns (manual ARIA wiring, color-only errors, broken ID
181
+ references), see [FormField Anti-Patterns](/components/inputs/form-field/#anti-patterns)
182
+ - Manually set `role`, `aria-checked`, `aria-labelledby`, `aria-describedby`, `aria-invalid`, or
183
+ `id` on **Switch** — Canvas Kit wires these from the native checkbox and **`FormField`**
184
+ - Nest **`FormField`** inside **`FormField`** instead of using **`FormField.Field`** — the inner
185
+ **`FormField`** breaks the label association
186
+ - Put the state in the label (for example, "Dark Mode: On") or add a visually hidden "on"/"off"
187
+ string — the state is already announced from `role="switch"` and `checked`
188
+ - Set **`error`** directly on **Switch** inside **`FormField`** — set it on **`FormField`** so
189
+ `aria-invalid` and the visual ring stay in sync. Setting **`error`** on a Switch outside
190
+ **`FormField`** is visual only and does not set `aria-invalid`
191
+ - Use **`isRequired`** for a setting that can validly be off
192
+ - Use **Switch** for selections that only apply on form submission, or for multiple related
193
+ options — use [**Checkbox**](/components/inputs/checkbox/) instead
194
+ - Use **`aria-disabled`** instead of **`disabled`** — **Switch** maps unavailability to the native
195
+ **`disabled`** attribute
196
+
78
197
  ## Component API
79
198
 
80
199
  <SymbolDoc name="Switch" fileName="/react/" />
@@ -11,7 +11,7 @@ export default () => {
11
11
  };
12
12
 
13
13
  return (
14
- <FormField isRequired>
14
+ <FormField>
15
15
  <FormField.Label>Dark Mode</FormField.Label>
16
16
  <FormField.Field>
17
17
  <FormField.Input as={Switch} checked={checked} onChange={handleChange} />
@@ -0,0 +1,69 @@
1
+ import {CanvasProvider} from '@workday/canvas-kit-react/common';
2
+ import {Flex} from '@workday/canvas-kit-react/layout';
3
+ import {Menu, menuCardStencil} from '@workday/canvas-kit-react/menu';
4
+ import {PopperProps} from '@workday/canvas-kit-react/popup';
5
+ import {createStencil, createStyles, px2rem} from '@workday/canvas-kit-styling';
6
+
7
+ const containerStencil = createStencil({
8
+ base: {},
9
+ modifiers: {
10
+ atEnd: {true: {justifyContent: 'flex-end'}},
11
+ alignBottom: {true: {position: 'fixed', bottom: 0, left: 0, right: 0}},
12
+ },
13
+ });
14
+
15
+ // A fixed height makes the parent list scroll independently of the page.
16
+ const cardStyles = createStyles({[menuCardStencil.vars.maxHeight]: px2rem(280)});
17
+ // Short enough that a Sana submenu cannot fit below the target when the menu is pinned to the
18
+ // bottom of the viewport, so placement falls back above the parent.
19
+ const bottomEdgeCardStyles = createStyles({[menuCardStencil.vars.maxHeight]: px2rem(160)});
20
+
21
+ export default ({
22
+ dir = 'ltr',
23
+ atEnd = false,
24
+ alignBottom = false,
25
+ submenuPopperProps,
26
+ }: {
27
+ dir?: 'ltr' | 'rtl';
28
+ atEnd?: boolean;
29
+ alignBottom?: boolean;
30
+ submenuPopperProps?: Pick<PopperProps, 'placement' | 'fallbackPlacements' | 'popperOptions'>;
31
+ }) => (
32
+ <CanvasProvider dir={dir}>
33
+ <Flex cs={containerStencil({atEnd, alignBottom})}>
34
+ <Menu>
35
+ <Menu.Target>Open Menu</Menu.Target>
36
+ <Menu.Popper>
37
+ <Menu.Card
38
+ cs={alignBottom ? bottomEdgeCardStyles : cardStyles}
39
+ data-testid="scrollable-menu"
40
+ >
41
+ <Menu.List>
42
+ <Menu.Item data-id="first">First Item</Menu.Item>
43
+ <Menu.Item data-id="second">Second Item</Menu.Item>
44
+ <Menu.Submenu>
45
+ <Menu.Submenu.TargetItem data-id="submenu">More Items</Menu.Submenu.TargetItem>
46
+ <Menu.Submenu.Popper {...submenuPopperProps}>
47
+ <Menu.Submenu.Card>
48
+ <Menu.Submenu.List data-testid="submenu">
49
+ {Array.from({length: 6}, (_, index) => (
50
+ <Menu.Submenu.Item key={index} data-id={`sub-${index}`}>
51
+ Additional Menu Item {index + 1}
52
+ </Menu.Submenu.Item>
53
+ ))}
54
+ </Menu.Submenu.List>
55
+ </Menu.Submenu.Card>
56
+ </Menu.Submenu.Popper>
57
+ </Menu.Submenu>
58
+ {Array.from({length: 15}, (_, index) => (
59
+ <Menu.Item key={index} data-id={`item-${index}`}>
60
+ Item {index + 1}
61
+ </Menu.Item>
62
+ ))}
63
+ </Menu.List>
64
+ </Menu.Card>
65
+ </Menu.Popper>
66
+ </Menu>
67
+ </Flex>
68
+ </CanvasProvider>
69
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "16.2.1",
3
+ "version": "16.2.5",
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.2.1",
51
- "@workday/canvas-kit-preview-react": "^16.2.1",
52
- "@workday/canvas-kit-react": "^16.2.1",
53
- "@workday/canvas-kit-styling": "^16.2.1",
50
+ "@workday/canvas-kit-labs-react": "^16.2.5",
51
+ "@workday/canvas-kit-preview-react": "^16.2.5",
52
+ "@workday/canvas-kit-react": "^16.2.5",
53
+ "@workday/canvas-kit-styling": "^16.2.5",
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": "24223441c4c032707012c80f81aa445981c5042d"
66
+ "gitHead": "e5b96bcbbd1f827623f9e75b13699b74b4ac03dd"
67
67
  }