@workday/canvas-kit-docs 9.0.0-alpha.413-next.15 → 9.0.0-alpha.415-next.17

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.
@@ -74007,6 +74007,126 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
74007
74007
  ]
74008
74008
  }
74009
74009
  },
74010
+ {
74011
+ "name": "useListItemAllowChildStrings",
74012
+ "fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/collection/lib/useListItemAllowChildStrings.ts",
74013
+ "description": "This elemProps hook allows for children values to be considered identifiers if the children\nare strings. This can be useful for autocomplete or select components that allow string values.\nThis hook must be defined _before_ {@link useListItemRegister} because it sets the `data-id`\nattribute if one hasn't been defined by the application.\n\nAn example might look like:\n```tsx\nconst useMyListItem = composeHooks(\n // any other hooks here\n useListItemSelect,\n useListItemRegister,\n useListItemAllowChildStrings\n)\n\n\n<MyList onSelect={({id}) => {\n console.log(id) // will be \"First\" or \"Second\"\n}}>\n <MyList.Item>First</MyList.Item>\n <MyList.Item>Second</MyList.Item>\n</MyList>\n```",
74014
+ "declarations": [
74015
+ {
74016
+ "name": "useListItemAllowChildStrings",
74017
+ "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/collection/lib/useListItemAllowChildStrings.ts"
74018
+ }
74019
+ ],
74020
+ "tags": {},
74021
+ "type": {
74022
+ "kind": "function",
74023
+ "name": {
74024
+ "kind": "symbol",
74025
+ "name": "createElemPropsHook"
74026
+ },
74027
+ "parameters": [
74028
+ {
74029
+ "kind": "parameter",
74030
+ "name": "model",
74031
+ "description": "",
74032
+ "tags": {},
74033
+ "declarations": [],
74034
+ "type": {
74035
+ "kind": "symbol",
74036
+ "name": "ListModel"
74037
+ },
74038
+ "required": true
74039
+ },
74040
+ {
74041
+ "kind": "parameter",
74042
+ "name": "elemProps",
74043
+ "description": "",
74044
+ "tags": {},
74045
+ "declarations": [],
74046
+ "type": {
74047
+ "kind": "object",
74048
+ "properties": [
74049
+ {
74050
+ "kind": "property",
74051
+ "name": "data-id",
74052
+ "required": false,
74053
+ "type": {
74054
+ "kind": "primitive",
74055
+ "value": "string"
74056
+ },
74057
+ "description": "",
74058
+ "declarations": [
74059
+ {
74060
+ "name": "data-id",
74061
+ "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/collection/lib/useListItemAllowChildStrings.ts"
74062
+ }
74063
+ ],
74064
+ "tags": {}
74065
+ },
74066
+ {
74067
+ "kind": "property",
74068
+ "name": "children",
74069
+ "required": false,
74070
+ "type": {
74071
+ "kind": "external",
74072
+ "name": "ReactNode",
74073
+ "url": "https://reactjs.org/docs/rendering-elements.html"
74074
+ },
74075
+ "description": "",
74076
+ "declarations": [
74077
+ {
74078
+ "name": "children",
74079
+ "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/collection/lib/useListItemAllowChildStrings.ts"
74080
+ }
74081
+ ],
74082
+ "tags": {}
74083
+ }
74084
+ ]
74085
+ },
74086
+ "required": false
74087
+ },
74088
+ {
74089
+ "kind": "parameter",
74090
+ "name": "ref",
74091
+ "description": "",
74092
+ "tags": {},
74093
+ "declarations": [],
74094
+ "type": {
74095
+ "kind": "external",
74096
+ "name": "React.Ref",
74097
+ "url": "https://reactjs.org/docs/refs-and-the-dom.html"
74098
+ },
74099
+ "required": false
74100
+ }
74101
+ ],
74102
+ "returnType": {
74103
+ "kind": "object",
74104
+ "properties": [
74105
+ {
74106
+ "kind": "property",
74107
+ "name": "data-id",
74108
+ "required": false,
74109
+ "type": {
74110
+ "kind": "union",
74111
+ "value": [
74112
+ {
74113
+ "kind": "primitive",
74114
+ "value": "string"
74115
+ },
74116
+ {
74117
+ "kind": "primitive",
74118
+ "value": "undefined"
74119
+ }
74120
+ ]
74121
+ },
74122
+ "description": "",
74123
+ "tags": {},
74124
+ "declarations": []
74125
+ }
74126
+ ]
74127
+ }
74128
+ }
74129
+ },
74010
74130
  {
74011
74131
  "name": "useListItemRegister",
74012
74132
  "fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/collection/lib/useListItemRegister.tsx",
@@ -74335,6 +74455,18 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
74335
74455
  "description": "",
74336
74456
  "tags": {},
74337
74457
  "declarations": []
74458
+ },
74459
+ {
74460
+ "kind": "property",
74461
+ "name": "id",
74462
+ "required": true,
74463
+ "type": {
74464
+ "kind": "primitive",
74465
+ "value": "string"
74466
+ },
74467
+ "description": "",
74468
+ "tags": {},
74469
+ "declarations": []
74338
74470
  }
74339
74471
  ]
74340
74472
  }
@@ -106164,6 +106296,46 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
106164
106296
  }
106165
106297
  }
106166
106298
  },
106299
+ {
106300
+ "name": "slugify",
106301
+ "fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/utils/slugify.ts",
106302
+ "description": "Function that takes a string and returns a \"slug\" which can be used in HTML",
106303
+ "declarations": [
106304
+ {
106305
+ "name": "slugify",
106306
+ "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/utils/slugify.ts"
106307
+ }
106308
+ ],
106309
+ "tags": {},
106310
+ "type": {
106311
+ "kind": "function",
106312
+ "parameters": [
106313
+ {
106314
+ "kind": "parameter",
106315
+ "name": "input",
106316
+ "type": {
106317
+ "kind": "primitive",
106318
+ "value": "string"
106319
+ },
106320
+ "required": true,
106321
+ "rest": false,
106322
+ "description": "",
106323
+ "declarations": [
106324
+ {
106325
+ "name": "input",
106326
+ "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/utils/slugify.ts"
106327
+ }
106328
+ ],
106329
+ "tags": {}
106330
+ }
106331
+ ],
106332
+ "members": [],
106333
+ "returnType": {
106334
+ "kind": "primitive",
106335
+ "value": "string"
106336
+ }
106337
+ }
106338
+ },
106167
106339
  {
106168
106340
  "name": "useConstant",
106169
106341
  "fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/utils/useConstant.ts",
@@ -3,6 +3,7 @@ import {SymbolDoc} from '@workday/canvas-kit-docs';
3
3
  import {ListBox} from '@workday/canvas-kit-react/collection';
4
4
 
5
5
  import Basic from './examples/Basic';
6
+ import StringChildren from './examples/StringChildren';
6
7
  import DynamicItems from './examples/DynamicItems';
7
8
  import BasicVirtual from './examples/BasicVirtual';
8
9
  import IdentifiedItems from './examples/IdentifiedItems';
@@ -33,7 +34,7 @@ yarn add @workday/canvas-kit-react
33
34
  The `ListBox` on its own isn't very useful. It registers each item with the model. The
34
35
  `ListBox.Item` only uses the `useListItemRegister` hook which handles registration of static items
35
36
  to the model. The `ListBox` uses `useListRenderItems` which handles rendering static items as well
36
- as [Dynamic List](#dynamic-list) example).
37
+ as [Dynamic List](#dynamic-list) example.
37
38
 
38
39
  <ExampleCodeBlock code={Basic} />
39
40
 
@@ -87,6 +88,16 @@ uses `ListBox` and creates a custom `SelectableItem` elemProps hook and componen
87
88
 
88
89
  <ExampleCodeBlock code={Selection} />
89
90
 
91
+ ### String Children
92
+
93
+ Sometimes it is desired to allow the string children to be the identifiers for each item. This could
94
+ be useful for autocomplete components where the item's text is the desired identifier. Normally, if
95
+ no `data-id` is provided to the item, the system will choose the registration index. This would be `'0'`, `'1'`, and so on.
96
+ By passing `useListItemAllowChildStrings` to an item component, it will change this behavior to use the child text if no
97
+ `data-id` is provided.
98
+
99
+ <ExampleCodeBlock code={StringChildren} />
100
+
90
101
  #### Multiple Selection
91
102
 
92
103
  The `selection` manager can be passed directly to the model configuration to handle different
@@ -147,6 +158,10 @@ columns, but not rows. This is the default navigation manager for lists.
147
158
 
148
159
  <SymbolDoc name="useListItemRegister" fileName="/react/" />
149
160
 
161
+ ### `useListItemAllowChildStrings`
162
+
163
+ <SymbolDoc name="useListItemAllowChildStrings" fileName="/react/" />
164
+
150
165
  ### `useListItemRovingFocus`
151
166
 
152
167
  <SymbolDoc name="useListItemRovingFocus" fileName="/react/" />
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ ListBox,
5
+ useListItemRegister,
6
+ useListItemAllowChildStrings,
7
+ useListItemSelect,
8
+ useListModel,
9
+ } from '@workday/canvas-kit-react/collection';
10
+ import {composeHooks, createSubcomponent} from '@workday/canvas-kit-react/common';
11
+
12
+ const useItem = composeHooks(useListItemSelect, useListItemRegister, useListItemAllowChildStrings);
13
+
14
+ const Item = createSubcomponent('button')({
15
+ modelHook: useListModel,
16
+ elemPropsHook: useItem,
17
+ })((elemProps, Element) => {
18
+ return <Element {...elemProps} />;
19
+ });
20
+
21
+ export default () => {
22
+ const model = useListModel();
23
+
24
+ return (
25
+ <>
26
+ <ListBox model={model}>
27
+ <Item>First</Item>
28
+ <Item>Second</Item>
29
+ </ListBox>
30
+ <div>
31
+ Selected: <span id="selected">{model.state.selectedIds[0] || 'Nothing'}</span>
32
+ </div>
33
+ </>
34
+ );
35
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "9.0.0-alpha.413-next.15+76b571ed",
3
+ "version": "9.0.0-alpha.415-next.17+5fd436a0",
4
4
  "description": "Documentation components of Canvas Kit components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -44,9 +44,9 @@
44
44
  "dependencies": {
45
45
  "@emotion/styled": "^11.6.0",
46
46
  "@storybook/csf": "0.0.1",
47
- "@workday/canvas-kit-labs-react": "^9.0.0-alpha.413-next.15+76b571ed",
48
- "@workday/canvas-kit-preview-react": "^9.0.0-alpha.413-next.15+76b571ed",
49
- "@workday/canvas-kit-react": "^9.0.0-alpha.413-next.15+76b571ed",
47
+ "@workday/canvas-kit-labs-react": "^9.0.0-alpha.415-next.17+5fd436a0",
48
+ "@workday/canvas-kit-preview-react": "^9.0.0-alpha.415-next.17+5fd436a0",
49
+ "@workday/canvas-kit-react": "^9.0.0-alpha.415-next.17+5fd436a0",
50
50
  "@workday/canvas-system-icons-web": "^3.0.0",
51
51
  "markdown-to-jsx": "^6.10.3",
52
52
  "ts-node": "^10.9.1"
@@ -57,5 +57,5 @@
57
57
  "mkdirp": "^1.0.3",
58
58
  "typescript": "4.2"
59
59
  },
60
- "gitHead": "76b571ed215127f6badf7a3834a761709aac303d"
60
+ "gitHead": "5fd436a0c644d68c8a97fd0f52f4b32c1d5b2bec"
61
61
  }