@workday/canvas-kit-docs 5.3.0 → 5.3.4
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/lib/specs.js +18 -232
- package/dist/es6/lib/specs.js +18 -232
- package/dist/mdx/COMPOUND_COMPONENTS.mdx +30 -31
- package/dist/mdx/react/button/button/Button.mdx +2 -27
- package/dist/mdx/react/button/button/examples/Primary.tsx +1 -10
- package/dist/mdx/react/button/button/examples/Secondary.tsx +1 -10
- package/dist/mdx/react/button/button/examples/Tertiary.tsx +1 -10
- package/dist/mdx/react/loading-animation/LoadingAnimation.mdx +5 -0
- package/dist/mdx/react/loading-animation/examples/RTL.tsx +16 -0
- package/dist/mdx/react/tabs/Tabs.mdx +5 -31
- package/dist/mdx/react/tabs/examples/DisabledTab.tsx +1 -1
- package/dist/mdx/react/tabs/examples/DynamicTabs.tsx +13 -41
- package/dist/mdx/react/tabs/examples/HoistedModel.tsx +4 -4
- package/dist/mdx/react/tabs/examples/{NamedTabs.tsx → NamedKeys.tsx} +0 -0
- package/dist/mdx/react/tabs/examples/SinglePanel.tsx +1 -1
- package/dist/mdx/react/text-area/TextArea.mdx +1 -1
- package/dist/mdx/react/tooltip/Tooltip.mdx +8 -0
- package/dist/mdx/react/tooltip/examples/DelayedTooltip.tsx +16 -0
- package/package.json +3 -3
- package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +0 -554
- package/dist/mdx/labs-react/search-form/SearchForm.mdx +0 -64
- package/dist/mdx/labs-react/search-form/examples/Basic.tsx +0 -61
- package/dist/mdx/labs-react/search-form/examples/CustomTheme.tsx +0 -72
- package/dist/mdx/labs-react/search-form/examples/Grow.tsx +0 -62
- package/dist/mdx/labs-react/search-form/examples/PropTables.splitProps.tsx +0 -4
- package/dist/mdx/labs-react/search-form/examples/RTL.tsx +0 -70
- package/dist/mdx/labs-react/search-form/examples/Theming.tsx +0 -64
- package/dist/mdx/labs-react/text-input/TextInput.mdx +0 -123
- package/dist/mdx/labs-react/text-input/examples/Alert.tsx +0 -46
- package/dist/mdx/labs-react/text-input/examples/Basic.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Disabled.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Error.tsx +0 -43
- package/dist/mdx/labs-react/text-input/examples/Grow.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/HiddenLabel.tsx +0 -17
- package/dist/mdx/labs-react/text-input/examples/LabelPosition.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/LoginForm.tsx +0 -100
- package/dist/mdx/labs-react/text-input/examples/Password.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Placeholder.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/RefForwarding.tsx +0 -27
- package/dist/mdx/labs-react/text-input/examples/Required.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/ThemedAlert.tsx +0 -51
- package/dist/mdx/labs-react/text-input/examples/ThemedError.tsx +0 -40
- package/dist/mdx/react/button/button/examples/PrimaryInverse.tsx +0 -14
- package/dist/mdx/react/button/button/examples/SecondaryInverse.tsx +0 -14
- package/dist/mdx/react/button/button/examples/TertiaryInverse.tsx +0 -14
- package/dist/mdx/react/tabs/examples/Icons.tsx +0 -36
- package/dist/mdx/react/tabs/examples/OverflowTabs.tsx +0 -58
package/dist/es6/lib/specs.js
CHANGED
|
@@ -4579,7 +4579,7 @@ module.exports = {specifications: [
|
|
|
4579
4579
|
},
|
|
4580
4580
|
{
|
|
4581
4581
|
"type": "it",
|
|
4582
|
-
"name": "should not have tabindex
|
|
4582
|
+
"name": "should not have tabindex on the first tab"
|
|
4583
4583
|
},
|
|
4584
4584
|
{
|
|
4585
4585
|
"type": "it",
|
|
@@ -4633,7 +4633,7 @@ module.exports = {specifications: [
|
|
|
4633
4633
|
},
|
|
4634
4634
|
{
|
|
4635
4635
|
"type": "it",
|
|
4636
|
-
"name": "should not have tabindex
|
|
4636
|
+
"name": "should not have tabindex on the second tab"
|
|
4637
4637
|
},
|
|
4638
4638
|
{
|
|
4639
4639
|
"type": "it",
|
|
@@ -4681,7 +4681,7 @@ module.exports = {specifications: [
|
|
|
4681
4681
|
"children": [
|
|
4682
4682
|
{
|
|
4683
4683
|
"type": "it",
|
|
4684
|
-
"name": "should not have tabindex
|
|
4684
|
+
"name": "should not have tabindex on the first tab"
|
|
4685
4685
|
},
|
|
4686
4686
|
{
|
|
4687
4687
|
"type": "it",
|
|
@@ -4707,7 +4707,7 @@ module.exports = {specifications: [
|
|
|
4707
4707
|
},
|
|
4708
4708
|
{
|
|
4709
4709
|
"type": "it",
|
|
4710
|
-
"name": "should not have tabindex
|
|
4710
|
+
"name": "should not have tabindex on the last tab"
|
|
4711
4711
|
},
|
|
4712
4712
|
{
|
|
4713
4713
|
"type": "it",
|
|
@@ -4731,7 +4731,7 @@ module.exports = {specifications: [
|
|
|
4731
4731
|
"children": [
|
|
4732
4732
|
{
|
|
4733
4733
|
"type": "it",
|
|
4734
|
-
"name": "should not have tabindex
|
|
4734
|
+
"name": "should not have tabindex on the first tab"
|
|
4735
4735
|
},
|
|
4736
4736
|
{
|
|
4737
4737
|
"type": "it",
|
|
@@ -4745,7 +4745,7 @@ module.exports = {specifications: [
|
|
|
4745
4745
|
},
|
|
4746
4746
|
{
|
|
4747
4747
|
"type": "describe",
|
|
4748
|
-
"name": "given the [Components/Containers/Tabs/React, Named
|
|
4748
|
+
"name": "given the [Components/Containers/Tabs/React, Named Keys] story is rendered",
|
|
4749
4749
|
"children": [
|
|
4750
4750
|
{
|
|
4751
4751
|
"type": "it",
|
|
@@ -4769,7 +4769,7 @@ module.exports = {specifications: [
|
|
|
4769
4769
|
},
|
|
4770
4770
|
{
|
|
4771
4771
|
"type": "it",
|
|
4772
|
-
"name": "should not have tabindex
|
|
4772
|
+
"name": "should not have tabindex on the first tab"
|
|
4773
4773
|
},
|
|
4774
4774
|
{
|
|
4775
4775
|
"type": "it",
|
|
@@ -4823,7 +4823,7 @@ module.exports = {specifications: [
|
|
|
4823
4823
|
},
|
|
4824
4824
|
{
|
|
4825
4825
|
"type": "it",
|
|
4826
|
-
"name": "should not have tabindex
|
|
4826
|
+
"name": "should not have tabindex on the second tab"
|
|
4827
4827
|
},
|
|
4828
4828
|
{
|
|
4829
4829
|
"type": "it",
|
|
@@ -4871,7 +4871,7 @@ module.exports = {specifications: [
|
|
|
4871
4871
|
"children": [
|
|
4872
4872
|
{
|
|
4873
4873
|
"type": "it",
|
|
4874
|
-
"name": "should not have tabindex
|
|
4874
|
+
"name": "should not have tabindex on the first tab"
|
|
4875
4875
|
},
|
|
4876
4876
|
{
|
|
4877
4877
|
"type": "it",
|
|
@@ -4897,7 +4897,7 @@ module.exports = {specifications: [
|
|
|
4897
4897
|
},
|
|
4898
4898
|
{
|
|
4899
4899
|
"type": "it",
|
|
4900
|
-
"name": "should not have tabindex
|
|
4900
|
+
"name": "should not have tabindex on the last tab"
|
|
4901
4901
|
},
|
|
4902
4902
|
{
|
|
4903
4903
|
"type": "it",
|
|
@@ -4921,7 +4921,7 @@ module.exports = {specifications: [
|
|
|
4921
4921
|
"children": [
|
|
4922
4922
|
{
|
|
4923
4923
|
"type": "it",
|
|
4924
|
-
"name": "should not have tabindex
|
|
4924
|
+
"name": "should not have tabindex on the first tab"
|
|
4925
4925
|
},
|
|
4926
4926
|
{
|
|
4927
4927
|
"type": "it",
|
|
@@ -4937,20 +4937,6 @@ module.exports = {specifications: [
|
|
|
4937
4937
|
"type": "describe",
|
|
4938
4938
|
"name": "given the [Components/Containers/Tabs/React, DisabledTab] story is rendered",
|
|
4939
4939
|
"children": [
|
|
4940
|
-
{
|
|
4941
|
-
"type": "describe",
|
|
4942
|
-
"name": "when the Disabled Tab is clicked",
|
|
4943
|
-
"children": [
|
|
4944
|
-
{
|
|
4945
|
-
"type": "it",
|
|
4946
|
-
"name": "should not set \"[aria-selected=true]\" on the Disabled Tab"
|
|
4947
|
-
},
|
|
4948
|
-
{
|
|
4949
|
-
"type": "it",
|
|
4950
|
-
"name": "should leave the first tab selected"
|
|
4951
|
-
}
|
|
4952
|
-
]
|
|
4953
|
-
},
|
|
4954
4940
|
{
|
|
4955
4941
|
"type": "describe",
|
|
4956
4942
|
"name": "when the first tab is active and focused",
|
|
@@ -4961,21 +4947,7 @@ module.exports = {specifications: [
|
|
|
4961
4947
|
"children": [
|
|
4962
4948
|
{
|
|
4963
4949
|
"type": "it",
|
|
4964
|
-
"name": "should focus on the
|
|
4965
|
-
},
|
|
4966
|
-
{
|
|
4967
|
-
"type": "describe",
|
|
4968
|
-
"name": "when the enter key is pressed",
|
|
4969
|
-
"children": [
|
|
4970
|
-
{
|
|
4971
|
-
"type": "it",
|
|
4972
|
-
"name": "should not set \"[aria-selected=true]\" on the Disabled Tab"
|
|
4973
|
-
},
|
|
4974
|
-
{
|
|
4975
|
-
"type": "it",
|
|
4976
|
-
"name": "should leave the first tab selected"
|
|
4977
|
-
}
|
|
4978
|
-
]
|
|
4950
|
+
"name": "should skip over the second tab and focus on the third tab"
|
|
4979
4951
|
}
|
|
4980
4952
|
]
|
|
4981
4953
|
}
|
|
@@ -5013,7 +4985,7 @@ module.exports = {specifications: [
|
|
|
5013
4985
|
"children": [
|
|
5014
4986
|
{
|
|
5015
4987
|
"type": "describe",
|
|
5016
|
-
"name": "then the Delete key is pressed",
|
|
4988
|
+
"name": "then the Backspace/Delete key is pressed",
|
|
5017
4989
|
"children": [
|
|
5018
4990
|
{
|
|
5019
4991
|
"type": "it",
|
|
@@ -5037,7 +5009,7 @@ module.exports = {specifications: [
|
|
|
5037
5009
|
"children": [
|
|
5038
5010
|
{
|
|
5039
5011
|
"type": "describe",
|
|
5040
|
-
"name": "then the Delete key is pressed",
|
|
5012
|
+
"name": "then the Backspace/Delete key is pressed",
|
|
5041
5013
|
"children": [
|
|
5042
5014
|
{
|
|
5043
5015
|
"type": "it",
|
|
@@ -5057,7 +5029,7 @@ module.exports = {specifications: [
|
|
|
5057
5029
|
},
|
|
5058
5030
|
{
|
|
5059
5031
|
"type": "describe",
|
|
5060
|
-
"name": "then the Delete key is pressed again",
|
|
5032
|
+
"name": "then the Backspace/Delete key is pressed again",
|
|
5061
5033
|
"children": [
|
|
5062
5034
|
{
|
|
5063
5035
|
"type": "it",
|
|
@@ -5075,7 +5047,7 @@ module.exports = {specifications: [
|
|
|
5075
5047
|
"children": [
|
|
5076
5048
|
{
|
|
5077
5049
|
"type": "describe",
|
|
5078
|
-
"name": "then the Delete key is pressed",
|
|
5050
|
+
"name": "then the Backspace/Delete key is pressed",
|
|
5079
5051
|
"children": [
|
|
5080
5052
|
{
|
|
5081
5053
|
"type": "it",
|
|
@@ -5129,7 +5101,7 @@ module.exports = {specifications: [
|
|
|
5129
5101
|
},
|
|
5130
5102
|
{
|
|
5131
5103
|
"type": "it",
|
|
5132
|
-
"name": "should not have tabindex
|
|
5104
|
+
"name": "should not have tabindex on the second tab"
|
|
5133
5105
|
},
|
|
5134
5106
|
{
|
|
5135
5107
|
"type": "it",
|
|
@@ -5161,7 +5133,7 @@ module.exports = {specifications: [
|
|
|
5161
5133
|
},
|
|
5162
5134
|
{
|
|
5163
5135
|
"type": "it",
|
|
5164
|
-
"name": "should not have tabindex
|
|
5136
|
+
"name": "should not have tabindex on the last tab"
|
|
5165
5137
|
},
|
|
5166
5138
|
{
|
|
5167
5139
|
"type": "it",
|
|
@@ -5172,58 +5144,6 @@ module.exports = {specifications: [
|
|
|
5172
5144
|
]
|
|
5173
5145
|
}
|
|
5174
5146
|
]
|
|
5175
|
-
},
|
|
5176
|
-
{
|
|
5177
|
-
"type": "describe",
|
|
5178
|
-
"name": "when [Components/Containers/Tabs/React, OverflowTabs] story is rendered",
|
|
5179
|
-
"children": [
|
|
5180
|
-
{
|
|
5181
|
-
"type": "it",
|
|
5182
|
-
"name": "should pass axe checks"
|
|
5183
|
-
},
|
|
5184
|
-
{
|
|
5185
|
-
"type": "it",
|
|
5186
|
-
"name": "should not show the \"More\" button"
|
|
5187
|
-
},
|
|
5188
|
-
{
|
|
5189
|
-
"type": "describe",
|
|
5190
|
-
"name": "when tab list container is only 500px wide",
|
|
5191
|
-
"children": [
|
|
5192
|
-
{
|
|
5193
|
-
"type": "it",
|
|
5194
|
-
"name": "should pass axe checks"
|
|
5195
|
-
},
|
|
5196
|
-
{
|
|
5197
|
-
"type": "it",
|
|
5198
|
-
"name": "should show the \"More\" button"
|
|
5199
|
-
},
|
|
5200
|
-
{
|
|
5201
|
-
"type": "describe",
|
|
5202
|
-
"name": "when the \"More\" button is clicked",
|
|
5203
|
-
"children": [
|
|
5204
|
-
{
|
|
5205
|
-
"type": "it",
|
|
5206
|
-
"name": "should show the Tab overflow menu"
|
|
5207
|
-
},
|
|
5208
|
-
{
|
|
5209
|
-
"type": "describe",
|
|
5210
|
-
"name": "when the \"Sixth Tab\" is clicked",
|
|
5211
|
-
"children": [
|
|
5212
|
-
{
|
|
5213
|
-
"type": "it",
|
|
5214
|
-
"name": "should select the Sixth Tab"
|
|
5215
|
-
},
|
|
5216
|
-
{
|
|
5217
|
-
"type": "it",
|
|
5218
|
-
"name": "should move focus back to the \"More\" button"
|
|
5219
|
-
}
|
|
5220
|
-
]
|
|
5221
|
-
}
|
|
5222
|
-
]
|
|
5223
|
-
}
|
|
5224
|
-
]
|
|
5225
|
-
}
|
|
5226
|
-
]
|
|
5227
5147
|
}
|
|
5228
5148
|
]
|
|
5229
5149
|
}
|
|
@@ -5497,140 +5417,6 @@ module.exports = {specifications: [
|
|
|
5497
5417
|
}
|
|
5498
5418
|
]
|
|
5499
5419
|
},
|
|
5500
|
-
{
|
|
5501
|
-
"type": "file",
|
|
5502
|
-
"name": "TextInputLabs.spec.ts",
|
|
5503
|
-
"children": [
|
|
5504
|
-
{
|
|
5505
|
-
"type": "describe",
|
|
5506
|
-
"name": "TextInput",
|
|
5507
|
-
"children": [
|
|
5508
|
-
{
|
|
5509
|
-
"type": "describe",
|
|
5510
|
-
"name": "given the 'Basic' story is rendered",
|
|
5511
|
-
"children": [
|
|
5512
|
-
{
|
|
5513
|
-
"type": "it",
|
|
5514
|
-
"name": "should not have any axe errors"
|
|
5515
|
-
},
|
|
5516
|
-
{
|
|
5517
|
-
"type": "describe",
|
|
5518
|
-
"name": "when clicked",
|
|
5519
|
-
"children": [
|
|
5520
|
-
{
|
|
5521
|
-
"type": "it",
|
|
5522
|
-
"name": "should be focused"
|
|
5523
|
-
}
|
|
5524
|
-
]
|
|
5525
|
-
},
|
|
5526
|
-
{
|
|
5527
|
-
"type": "describe",
|
|
5528
|
-
"name": "when text is entered",
|
|
5529
|
-
"children": [
|
|
5530
|
-
{
|
|
5531
|
-
"type": "it",
|
|
5532
|
-
"name": "should reflect the text typed"
|
|
5533
|
-
}
|
|
5534
|
-
]
|
|
5535
|
-
}
|
|
5536
|
-
]
|
|
5537
|
-
},
|
|
5538
|
-
{
|
|
5539
|
-
"type": "describe",
|
|
5540
|
-
"name": "given the 'Alert' story is rendered",
|
|
5541
|
-
"children": [
|
|
5542
|
-
{
|
|
5543
|
-
"type": "it",
|
|
5544
|
-
"name": "should not have any axe errors"
|
|
5545
|
-
},
|
|
5546
|
-
{
|
|
5547
|
-
"type": "describe",
|
|
5548
|
-
"name": "when clicked",
|
|
5549
|
-
"children": [
|
|
5550
|
-
{
|
|
5551
|
-
"type": "it",
|
|
5552
|
-
"name": "should be focused"
|
|
5553
|
-
}
|
|
5554
|
-
]
|
|
5555
|
-
},
|
|
5556
|
-
{
|
|
5557
|
-
"type": "describe",
|
|
5558
|
-
"name": "when text is entered",
|
|
5559
|
-
"children": [
|
|
5560
|
-
{
|
|
5561
|
-
"type": "it",
|
|
5562
|
-
"name": "should reflect the text typed"
|
|
5563
|
-
}
|
|
5564
|
-
]
|
|
5565
|
-
}
|
|
5566
|
-
]
|
|
5567
|
-
},
|
|
5568
|
-
{
|
|
5569
|
-
"type": "describe",
|
|
5570
|
-
"name": "given the 'Error' story is rendered",
|
|
5571
|
-
"children": [
|
|
5572
|
-
{
|
|
5573
|
-
"type": "it",
|
|
5574
|
-
"name": "should not have any axe errors"
|
|
5575
|
-
},
|
|
5576
|
-
{
|
|
5577
|
-
"type": "describe",
|
|
5578
|
-
"name": "when clicked",
|
|
5579
|
-
"children": [
|
|
5580
|
-
{
|
|
5581
|
-
"type": "it",
|
|
5582
|
-
"name": "should be focused"
|
|
5583
|
-
}
|
|
5584
|
-
]
|
|
5585
|
-
},
|
|
5586
|
-
{
|
|
5587
|
-
"type": "describe",
|
|
5588
|
-
"name": "when text is entered",
|
|
5589
|
-
"children": [
|
|
5590
|
-
{
|
|
5591
|
-
"type": "it",
|
|
5592
|
-
"name": "should reflect the text typed"
|
|
5593
|
-
}
|
|
5594
|
-
]
|
|
5595
|
-
}
|
|
5596
|
-
]
|
|
5597
|
-
},
|
|
5598
|
-
{
|
|
5599
|
-
"type": "describe",
|
|
5600
|
-
"name": "given the 'Disabled' story is rendered",
|
|
5601
|
-
"children": [
|
|
5602
|
-
{
|
|
5603
|
-
"type": "it",
|
|
5604
|
-
"name": "should not have any axe errors"
|
|
5605
|
-
},
|
|
5606
|
-
{
|
|
5607
|
-
"type": "it",
|
|
5608
|
-
"name": "should be disabled"
|
|
5609
|
-
}
|
|
5610
|
-
]
|
|
5611
|
-
},
|
|
5612
|
-
{
|
|
5613
|
-
"type": "describe",
|
|
5614
|
-
"name": "given the 'Placeholder' story is rendered",
|
|
5615
|
-
"children": [
|
|
5616
|
-
{
|
|
5617
|
-
"type": "it",
|
|
5618
|
-
"name": "should not have any axe errors"
|
|
5619
|
-
},
|
|
5620
|
-
{
|
|
5621
|
-
"type": "it",
|
|
5622
|
-
"name": "should render a placeholder text"
|
|
5623
|
-
},
|
|
5624
|
-
{
|
|
5625
|
-
"type": "it",
|
|
5626
|
-
"name": "should reflect the text typed"
|
|
5627
|
-
}
|
|
5628
|
-
]
|
|
5629
|
-
}
|
|
5630
|
-
]
|
|
5631
|
-
}
|
|
5632
|
-
]
|
|
5633
|
-
},
|
|
5634
5420
|
{
|
|
5635
5421
|
"type": "file",
|
|
5636
5422
|
"name": "Toast.spec.ts",
|
|
@@ -78,8 +78,8 @@ const Tabs = ({children, model, ...config}) => {
|
|
|
78
78
|
|
|
79
79
|
## Subcomponents
|
|
80
80
|
|
|
81
|
-
A subcomponent typically follows ARIA roles. For the `Tabs` example, these are the `tablist`,
|
|
82
|
-
and `tabpanel` roles. A subcomponent provides direct access to semantic or key elements of a
|
|
81
|
+
A subcomponent typically follows ARIA roles. For the `Tabs` example, these are the `tablist`,
|
|
82
|
+
`tab`, and `tabpanel` roles. A subcomponent provides direct access to semantic or key elements of a
|
|
83
83
|
compound component. In the `IconButton` example, the icon is not semantic and might be hidden from
|
|
84
84
|
screen readers while the `IconButton.Text` content is instead used for a tooltip and as the
|
|
85
85
|
accessible name while being visibly hidden.
|
|
@@ -175,35 +175,35 @@ Components that directly wrap an element (most of them) will have the following
|
|
|
175
175
|
|
|
176
176
|
Compound components are also made up of [models](#models) that accept [guards](#guards) to
|
|
177
177
|
conditionally prevent state changes and [callbacks](#callbacks) to attach listeners. For example, in
|
|
178
|
-
our Tabs component clicking a Tab will
|
|
179
|
-
`
|
|
178
|
+
our Tabs component clicking a Tab will activate that tab. The `Tabs` container component will accept
|
|
179
|
+
a `shouldActivate` and a `onActivate` for the event called `activate`.
|
|
180
180
|
|
|
181
181
|
```tsx
|
|
182
182
|
const MyComponent = () => {
|
|
183
|
-
// `data` is all event data from the `
|
|
183
|
+
// `data` is all event data from the `activate` event
|
|
184
184
|
|
|
185
185
|
// `state` is the current state of the `Tabs` component
|
|
186
|
-
const
|
|
187
|
-
// for some reason, we only want to allow
|
|
188
|
-
// Clicking on the first tab will
|
|
186
|
+
const shouldActivate = ({data, state}) => {
|
|
187
|
+
// for some reason, we only want to allow activation the 'first' tab
|
|
188
|
+
// Clicking on the first tab will activate it, but clicking on the
|
|
189
189
|
// second tab will do nothing
|
|
190
190
|
return data.tab === 'first' ? true : false;
|
|
191
191
|
|
|
192
192
|
// returning true allows the event to trigger a state change and will
|
|
193
|
-
// also call the `
|
|
193
|
+
// also call the `onActivate` callback
|
|
194
194
|
};
|
|
195
195
|
|
|
196
196
|
// `prevState` is the previous state of the model. Callbacks are called _before_ state has resolved.
|
|
197
197
|
// This means the passed state hasn't updated yet. It also means it is safe to call `setState` without
|
|
198
198
|
// triggering extra renders. `setState` calls will add to React's batching system before a state changes
|
|
199
199
|
// are flushed and render functions are called.
|
|
200
|
-
const
|
|
201
|
-
// called any time the `
|
|
202
|
-
console.log('
|
|
200
|
+
const onActivate = ({data, prevState}) => {
|
|
201
|
+
// called any time the `activate` event is triggered
|
|
202
|
+
console.log('onActivate', data, prevState);
|
|
203
203
|
};
|
|
204
204
|
|
|
205
205
|
return (
|
|
206
|
-
<Tabs
|
|
206
|
+
<Tabs shouldActivate={shouldActivate} onActivate={onActivate}>
|
|
207
207
|
<Tabs.List>
|
|
208
208
|
<Tabs.Item name="first">First</Tabs.Item>
|
|
209
209
|
<Tabs.Item name="second">Second</Tabs.Item>
|
|
@@ -324,20 +324,20 @@ const useEllipsisTooltipModel = (config = {}) => {
|
|
|
324
324
|
|
|
325
325
|
Models are meant to be composable. For example, a `TabsModel` uses a `CursorModel` (which itself
|
|
326
326
|
uses `ListModel`) and a `ListModel` for a list of panels. `TabsModel` also keeps track of which tab
|
|
327
|
-
is currently
|
|
327
|
+
is currently active. This might look like the following:
|
|
328
328
|
|
|
329
329
|
```ts
|
|
330
330
|
const useTabsModel = (config = {}) => {
|
|
331
331
|
// id is used for ARIA attributes
|
|
332
332
|
const id = useUniqueId(config.id);
|
|
333
|
-
const [
|
|
333
|
+
const [activeTab, setActiveTab] = React.useState('');
|
|
334
334
|
const cursor = useCursorModel(config);
|
|
335
335
|
const panels = useListModel(config);
|
|
336
336
|
|
|
337
337
|
const state = {
|
|
338
338
|
...cursor.state, // extend the CursorModel state
|
|
339
339
|
id,
|
|
340
|
-
|
|
340
|
+
activeTab,
|
|
341
341
|
panels: panels.state.items, // we only care about
|
|
342
342
|
};
|
|
343
343
|
|
|
@@ -346,12 +346,12 @@ const useTabsModel = (config = {}) => {
|
|
|
346
346
|
registerPanel: panels.events.registerItem,
|
|
347
347
|
unregisterPanel: panels.events.unregisterItem,
|
|
348
348
|
|
|
349
|
-
|
|
350
|
-
if (config.
|
|
349
|
+
activate(data) {
|
|
350
|
+
if (config.shouldActivate?.({data, prevState: state}) === false) {
|
|
351
351
|
return;
|
|
352
352
|
}
|
|
353
|
-
|
|
354
|
-
config.
|
|
353
|
+
setActiveTab(data.tab);
|
|
354
|
+
config.onActivate?.({data, prevState: state});
|
|
355
355
|
},
|
|
356
356
|
};
|
|
357
357
|
|
|
@@ -362,11 +362,10 @@ const useTabsModel = (config = {}) => {
|
|
|
362
362
|
Model composition allows for components to share functionality with other components. In the Tabs
|
|
363
363
|
example, `ListModel` is in charge of maintaining a list of tab elements. The `CursorModel` is in
|
|
364
364
|
charge of maintaining a current cursor position of the tab list. The `Tabs.List` component uses the
|
|
365
|
-
cursor to allow keyboard navigation of the tabs. The `TabsModel` also maintains the currently
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
subcomponents.
|
|
365
|
+
cursor to allow keyboard navigation of the tabs. The `TabsModel` also maintains the currently active
|
|
366
|
+
tab to ensure the correct `TabPanel` is visible. The `TabsModel` is also using a `ListModel` to
|
|
367
|
+
maintain a list of tab panels. The `TabsModel` is in charge of composing all this and providing data
|
|
368
|
+
and events to the `Tabs` compound component - coordination state between subcomponents.
|
|
370
369
|
|
|
371
370
|
Many other components like `Select`, `Breadcrumbs`, or dropdown menus can also use the `ListModel`
|
|
372
371
|
and/or the `CursorModel`. These models could be thought of as abstract models where they do not
|
|
@@ -464,11 +463,11 @@ const TabList = ({children, ...elemProps}) => {
|
|
|
464
463
|
|
|
465
464
|
A container component can either accept model configuration _or_ a model. Passing model
|
|
466
465
|
configuration allows for simpler model configuration of guards, callbacks, or any other model
|
|
467
|
-
configuration. The following example provides an `
|
|
468
|
-
server:
|
|
466
|
+
configuration. The following example provides an `onActivate` callback that fetches some data from
|
|
467
|
+
the server:
|
|
469
468
|
|
|
470
469
|
```tsx
|
|
471
|
-
<Tabs
|
|
470
|
+
<Tabs onActivate={({data}) => fetch('/api/activate' + data.id)}>...</Tabs>
|
|
472
471
|
```
|
|
473
472
|
|
|
474
473
|
If you need direct access to a model's state or events, you can hoist the model into your component
|
|
@@ -480,15 +479,15 @@ look like this:
|
|
|
480
479
|
const MyTabs = () => {
|
|
481
480
|
const model = useTabsModel({
|
|
482
481
|
// we can still load data from the server
|
|
483
|
-
|
|
482
|
+
onActivate: ({data}) => fetch('/api/activate' + data.id),
|
|
484
483
|
});
|
|
485
484
|
|
|
486
485
|
return (
|
|
487
486
|
<>
|
|
488
487
|
<Tabs model={model}>...</Tabs>
|
|
489
|
-
// direct access to the model's state Currently selected tab: {model.state.
|
|
488
|
+
// direct access to the model's state Currently selected tab: {model.state.activeTab}
|
|
490
489
|
// Now we can send events directly to the model
|
|
491
|
-
<button onClick={() => model.events.
|
|
490
|
+
<button onClick={() => model.events.activate({tab: 'third'})}>Activate third tab</button>
|
|
492
491
|
</>
|
|
493
492
|
);
|
|
494
493
|
};
|
|
@@ -7,11 +7,8 @@ import {
|
|
|
7
7
|
import {Specifications} from '@workday/canvas-kit-docs';
|
|
8
8
|
|
|
9
9
|
import Primary from './examples/Primary';
|
|
10
|
-
import PrimaryInverse from './examples/PrimaryInverse';
|
|
11
10
|
import Secondary from './examples/Secondary';
|
|
12
|
-
import SecondaryInverse from './examples/SecondaryInverse';
|
|
13
11
|
import Tertiary from './examples/Tertiary';
|
|
14
|
-
import TertiaryInverse from './examples/TertiaryInverse';
|
|
15
12
|
import Delete from './examples/Delete';
|
|
16
13
|
|
|
17
14
|
|
|
@@ -38,17 +35,8 @@ Primary Buttons are high emphasis. Use once per screen to draw attention to the
|
|
|
38
35
|
action. Multiple primary buttons make it confusing for the user to understand what action they
|
|
39
36
|
should take. Not all screens require a Primary Button.
|
|
40
37
|
|
|
41
|
-
Primary Buttons have four sizes: `extraSmall`, `small`, `medium`, and `large`. Icons are supported
|
|
42
|
-
for every size and can be positioned to the `left` or `right` with the `iconPosition` prop.
|
|
43
|
-
|
|
44
38
|
<ExampleCodeBlock code={Primary} />
|
|
45
39
|
|
|
46
|
-
Primary Buttons also have an `inverse` variant. While it looks similar to the default Secondary
|
|
47
|
-
Button, the default outline as well as the hover and focus states are different. Use this variant
|
|
48
|
-
when you need to place a Primary Button on a dark or colorful background such as `blueberry400`.
|
|
49
|
-
|
|
50
|
-
<ExampleCodeBlock code={PrimaryInverse} />
|
|
51
|
-
|
|
52
40
|
#### Props
|
|
53
41
|
|
|
54
42
|
Undocumented props are spread to the underlying `<button>` element.
|
|
@@ -61,16 +49,10 @@ Secondary Buttons have a medium level of emphasis. Use them for non-critical act
|
|
|
61
49
|
Buttons can be used on most pages without restrictions and work well for multiple actions of equal
|
|
62
50
|
weight. They can be used in conjunction with a Primary Button or independently.
|
|
63
51
|
|
|
64
|
-
|
|
65
|
-
for every size and can be positioned to the `left` or `right` with the `iconPosition` prop.
|
|
52
|
+
Use the `inverse` variants on dark or colorful backgrounds.
|
|
66
53
|
|
|
67
54
|
<ExampleCodeBlock code={Secondary} />
|
|
68
55
|
|
|
69
|
-
Secondary Buttons also have an `inverse` variant. Use this when you need to place a Secondary Button on
|
|
70
|
-
a dark or colorful background such as `blueberry400`.
|
|
71
|
-
|
|
72
|
-
<ExampleCodeBlock code={SecondaryInverse} />
|
|
73
|
-
|
|
74
56
|
#### Props
|
|
75
57
|
|
|
76
58
|
Undocumented props are spread to the underlying `<button>` element.
|
|
@@ -84,17 +66,10 @@ the user may not often be looking to do. Tertiary Buttons have lower prominence
|
|
|
84
66
|
not visible until it is interacted with. Use Tertiary Buttons for supplemental actions such as “View
|
|
85
67
|
More”, “Read More” or “Select a File”. Tertiary Buttons are frequently used on Cards.
|
|
86
68
|
|
|
87
|
-
|
|
88
|
-
for every size and can be positioned to the `left` or `right` with the `iconPosition` prop.
|
|
69
|
+
Use the `inverse` variants on dark or colorful backgrounds.
|
|
89
70
|
|
|
90
71
|
<ExampleCodeBlock code={Tertiary} />
|
|
91
72
|
|
|
92
|
-
Tertiary Buttons also have an `inverse` variant. Use this when you need to place a Tertiary Button on
|
|
93
|
-
a dark or colorful background such as `blueberry400`.
|
|
94
|
-
|
|
95
|
-
<ExampleCodeBlock code={TertiaryInverse} />
|
|
96
|
-
|
|
97
|
-
|
|
98
73
|
#### Props
|
|
99
74
|
|
|
100
75
|
Undocumented props are spread to the underlying `<button>` element.
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
-
import {HStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
-
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
6
4
|
|
|
7
|
-
export default () =>
|
|
8
|
-
<HStack spacing="s" padding="s">
|
|
9
|
-
<PrimaryButton>Primary</PrimaryButton>
|
|
10
|
-
<PrimaryButton icon={plusIcon} iconPosition="right">
|
|
11
|
-
Primary
|
|
12
|
-
</PrimaryButton>
|
|
13
|
-
</HStack>
|
|
14
|
-
);
|
|
5
|
+
export default () => <PrimaryButton>Click Me</PrimaryButton>;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
-
import {HStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
-
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
6
4
|
|
|
7
|
-
export default () =>
|
|
8
|
-
<HStack spacing="s" padding="s">
|
|
9
|
-
<SecondaryButton>Secondary</SecondaryButton>
|
|
10
|
-
<SecondaryButton icon={plusIcon} iconPosition="right">
|
|
11
|
-
Secondary
|
|
12
|
-
</SecondaryButton>
|
|
13
|
-
</HStack>
|
|
14
|
-
);
|
|
5
|
+
export default () => <SecondaryButton>Click Me</SecondaryButton>;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
-
import {HStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
-
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
6
4
|
|
|
7
|
-
export default () =>
|
|
8
|
-
<HStack spacing="s" padding="s">
|
|
9
|
-
<TertiaryButton>Tertiary</TertiaryButton>
|
|
10
|
-
<TertiaryButton icon={plusIcon} iconPosition="right">
|
|
11
|
-
Tertiary
|
|
12
|
-
</TertiaryButton>
|
|
13
|
-
</HStack>
|
|
14
|
-
);
|
|
5
|
+
export default () => <TertiaryButton>Click Me</TertiaryButton>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {LoadingAnimation} from '@workday/canvas-kit-react/loading-animation';
|
|
2
2
|
|
|
3
3
|
import Basic from './examples/Basic';
|
|
4
|
+
import RTL from './examples/RTL';
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
# Canvas Kit Loading Animation
|
|
@@ -22,6 +23,10 @@ yarn add @workday/canvas-kit-react
|
|
|
22
23
|
|
|
23
24
|
<ExampleCodeBlock code={Basic} />
|
|
24
25
|
|
|
26
|
+
### Right-to-Left (RTL)
|
|
27
|
+
|
|
28
|
+
<ExampleCodeBlock code={RTL} />
|
|
29
|
+
|
|
25
30
|
## Props
|
|
26
31
|
|
|
27
32
|
Loading Animation does not have any documented props. Undocumented props are spread to its outermost
|