@patternfly/context-for-ai 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +615 -0
- package/codemod/ALL_COMPONENTS_REFERENCE.md +815 -0
- package/codemod/ATTRIBUTE_DECISION_LOGIC.md +320 -0
- package/codemod/README.md +400 -0
- package/codemod/add-semantic-attributes.sh +69 -0
- package/codemod/component-attributes-reference.json +129 -0
- package/codemod/example-after.tsx +51 -0
- package/codemod/example-before.tsx +19 -0
- package/codemod/static-inference.js +5015 -0
- package/codemod/transform.js +1108 -0
- package/dist/components/advanced/index.d.ts +2 -0
- package/dist/components/advanced/index.d.ts.map +1 -0
- package/dist/components/core/Button.d.ts +14 -0
- package/dist/components/core/Button.d.ts.map +1 -0
- package/dist/components/core/Link.d.ts +15 -0
- package/dist/components/core/Link.d.ts.map +1 -0
- package/dist/components/core/StarIcon.d.ts +15 -0
- package/dist/components/core/StarIcon.d.ts.map +1 -0
- package/dist/components/core/index.d.ts +4 -0
- package/dist/components/core/index.d.ts.map +1 -0
- package/dist/components/data-display/Card.d.ts +14 -0
- package/dist/components/data-display/Card.d.ts.map +1 -0
- package/dist/components/data-display/StatusBadge.d.ts +13 -0
- package/dist/components/data-display/StatusBadge.d.ts.map +1 -0
- package/dist/components/data-display/Tbody.d.ts +12 -0
- package/dist/components/data-display/Tbody.d.ts.map +1 -0
- package/dist/components/data-display/Td.d.ts +14 -0
- package/dist/components/data-display/Td.d.ts.map +1 -0
- package/dist/components/data-display/Th.d.ts +14 -0
- package/dist/components/data-display/Th.d.ts.map +1 -0
- package/dist/components/data-display/Thead.d.ts +12 -0
- package/dist/components/data-display/Thead.d.ts.map +1 -0
- package/dist/components/data-display/Tr.d.ts +16 -0
- package/dist/components/data-display/Tr.d.ts.map +1 -0
- package/dist/components/data-display/index.d.ts +8 -0
- package/dist/components/data-display/index.d.ts.map +1 -0
- package/dist/components/feedback/index.d.ts +2 -0
- package/dist/components/feedback/index.d.ts.map +1 -0
- package/dist/components/forms/Checkbox.d.ts +16 -0
- package/dist/components/forms/Checkbox.d.ts.map +1 -0
- package/dist/components/forms/Form.d.ts +12 -0
- package/dist/components/forms/Form.d.ts.map +1 -0
- package/dist/components/forms/Radio.d.ts +32 -0
- package/dist/components/forms/Radio.d.ts.map +1 -0
- package/dist/components/forms/Select.d.ts +33 -0
- package/dist/components/forms/Select.d.ts.map +1 -0
- package/dist/components/forms/Switch.d.ts +31 -0
- package/dist/components/forms/Switch.d.ts.map +1 -0
- package/dist/components/forms/TextArea.d.ts +29 -0
- package/dist/components/forms/TextArea.d.ts.map +1 -0
- package/dist/components/forms/TextInput.d.ts +29 -0
- package/dist/components/forms/TextInput.d.ts.map +1 -0
- package/dist/components/forms/index.d.ts +8 -0
- package/dist/components/forms/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/layout/Flex.d.ts +16 -0
- package/dist/components/layout/Flex.d.ts.map +1 -0
- package/dist/components/layout/FlexItem.d.ts +16 -0
- package/dist/components/layout/FlexItem.d.ts.map +1 -0
- package/dist/components/layout/index.d.ts +3 -0
- package/dist/components/layout/index.d.ts.map +1 -0
- package/dist/components/navigation/DropdownItem.d.ts +8 -0
- package/dist/components/navigation/DropdownItem.d.ts.map +1 -0
- package/dist/components/navigation/MenuToggle.d.ts +8 -0
- package/dist/components/navigation/MenuToggle.d.ts.map +1 -0
- package/dist/components/navigation/index.d.ts +3 -0
- package/dist/components/navigation/index.d.ts.map +1 -0
- package/dist/components/overlay/Drawer.d.ts +12 -0
- package/dist/components/overlay/Drawer.d.ts.map +1 -0
- package/dist/components/overlay/Modal.d.ts +16 -0
- package/dist/components/overlay/Modal.d.ts.map +1 -0
- package/dist/components/overlay/index.d.ts +3 -0
- package/dist/components/overlay/index.d.ts.map +1 -0
- package/dist/context/SemanticContext.d.ts +28 -0
- package/dist/context/SemanticContext.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useAccessibility.d.ts +13 -0
- package/dist/hooks/useAccessibility.d.ts.map +1 -0
- package/dist/hooks/useSemanticMetadata.d.ts +9 -0
- package/dist/hooks/useSemanticMetadata.d.ts.map +1 -0
- package/dist/index.d.ts +574 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +1362 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1426 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +47 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/accessibility.d.ts +16 -0
- package/dist/utils/accessibility.d.ts.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/inference.d.ts +136 -0
- package/dist/utils/inference.d.ts.map +1 -0
- package/dist/utils/metadata.d.ts +17 -0
- package/dist/utils/metadata.d.ts.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# How We Decide What Goes Into Each Data-* Attribute "Bucket"
|
|
2
|
+
|
|
3
|
+
This document explains in simple terms how we determine the value for each of the 7 data-* attributes we add to PatternFly components.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Each component gets analyzed by 7 functions (one per "bucket"). These functions look at:
|
|
8
|
+
- **Component name** (e.g., "Button", "Card", "TextInput")
|
|
9
|
+
- **Props** (e.g., `variant="primary"`, `isDisabled={true}`, `onClick={...}`)
|
|
10
|
+
- **Parent context** (where the component is used - e.g., inside a Form, Modal, Toolbar)
|
|
11
|
+
- **Children** (for some components, we analyze child elements to infer variants)
|
|
12
|
+
|
|
13
|
+
## The 7 Buckets (Data-* Attributes)
|
|
14
|
+
|
|
15
|
+
### 1. `data-role` - "What the component IS"
|
|
16
|
+
|
|
17
|
+
**Function:** `inferRole(componentName)`
|
|
18
|
+
|
|
19
|
+
**What it does:**
|
|
20
|
+
- Takes the component name (e.g., "Button", "Card", "TextInput")
|
|
21
|
+
- Converts it to lowercase
|
|
22
|
+
- Looks it up in a `roleMap` object that maps component names to semantic roles
|
|
23
|
+
- Returns a more descriptive role than the component name itself
|
|
24
|
+
|
|
25
|
+
**Examples:**
|
|
26
|
+
- `Button` → `"button"`
|
|
27
|
+
- `Card` → `"card"`
|
|
28
|
+
- `TextInput` → `"text-input"`
|
|
29
|
+
- `AccordionItem` → `"accordion-section"` (more descriptive than just "accordion-item")
|
|
30
|
+
- `ActionListItem` → `"action-item"` (more descriptive)
|
|
31
|
+
|
|
32
|
+
**Special cases:**
|
|
33
|
+
- Icons (components ending with "Icon") → always `"icon"`
|
|
34
|
+
- Brand → always `"logo"`
|
|
35
|
+
- Some structural children return `null` (they don't get a role)
|
|
36
|
+
|
|
37
|
+
**Props used:** None (only uses component name)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
### 2. `data-purpose` - "What the component DOES"
|
|
42
|
+
|
|
43
|
+
**Function:** `inferPurpose(componentName, props)`
|
|
44
|
+
|
|
45
|
+
**What it does:**
|
|
46
|
+
- Takes component name and props
|
|
47
|
+
- Checks component name patterns (e.g., includes "button", "card", "form")
|
|
48
|
+
- Checks specific props to determine purpose
|
|
49
|
+
- Returns a purpose that describes the component's function
|
|
50
|
+
|
|
51
|
+
**Common purposes:**
|
|
52
|
+
- `"action"` - Buttons, clickable elements
|
|
53
|
+
- `"display"` - Cards, lists, text that shows information
|
|
54
|
+
- `"input"` - Text inputs, selects, checkboxes, form controls
|
|
55
|
+
- `"navigation"` - Links, nav items, tabs, pagination
|
|
56
|
+
- `"form-container"` - Forms, wizards
|
|
57
|
+
- `"guidance"` - Tooltips, hints, popovers
|
|
58
|
+
- `"selection"` - Toggle groups, tree view items
|
|
59
|
+
- `"status-tracking"` - Progress bars, spinners
|
|
60
|
+
|
|
61
|
+
**Props checked:**
|
|
62
|
+
- `onClick`, `onSubmit` → indicates action
|
|
63
|
+
- `href` → indicates navigation
|
|
64
|
+
- `isSelectable`, `isClickable` → for cards
|
|
65
|
+
- `onClose`, `isDismissible` → for labels (filter purpose)
|
|
66
|
+
- `color` → for labels (status-indicator purpose)
|
|
67
|
+
- `action` prop → for Forms (to infer purpose like "create", "edit")
|
|
68
|
+
|
|
69
|
+
**Examples:**
|
|
70
|
+
- Button with `onClick` → `"action"`
|
|
71
|
+
- Link with `href` → `"navigation"`
|
|
72
|
+
- Card with `isSelectable` → `"selectable"`
|
|
73
|
+
- Form with `action="/api/create"` → purpose inferred from action URL
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
### 3. `data-variant` - "How it LOOKS"
|
|
78
|
+
|
|
79
|
+
**Function:** `inferVariant(componentName, props)` + sometimes `analyzeChildren()` functions
|
|
80
|
+
|
|
81
|
+
**What it does:**
|
|
82
|
+
- Takes component name and props
|
|
83
|
+
- Checks for `variant` prop (most common)
|
|
84
|
+
- Checks for other visual/style props (e.g., `size`, `color`, `orientation`)
|
|
85
|
+
- For some components, analyzes children to infer variants
|
|
86
|
+
- Returns a string or array of variant names (can combine multiple variants)
|
|
87
|
+
|
|
88
|
+
**Props checked:**
|
|
89
|
+
- `variant` → most common (e.g., `variant="primary"`, `variant="danger"`)
|
|
90
|
+
- `size` → for size variants (e.g., `size="sm"`, `size="lg"`)
|
|
91
|
+
- `orientation` → for orientation (e.g., `orientation="vertical"`)
|
|
92
|
+
- `isFilled`, `isCompact`, `isSticky` → boolean style props
|
|
93
|
+
- `color` → for color variants
|
|
94
|
+
- `format` → for Timestamp (12-hour vs 24-hour)
|
|
95
|
+
- `headingLevel` → for Title (h1-h6)
|
|
96
|
+
|
|
97
|
+
**Children analysis (for some components):**
|
|
98
|
+
- `InputGroup` → `analyzeInputGroupChildren()` checks for buttons/icons/text on left/right
|
|
99
|
+
- `List` → `analyzeListChildren()` checks for icons in list items
|
|
100
|
+
- `LoginForm` → `analyzeLoginFormChildren()` checks for password toggles, header utilities
|
|
101
|
+
- `DualListSelector` → checks children for tooltips, search, actions
|
|
102
|
+
- `Masthead` → checks for vertical nav
|
|
103
|
+
- `Menu/Dropdown/Select` → checks children for various menu features
|
|
104
|
+
|
|
105
|
+
**Examples:**
|
|
106
|
+
- Button with `variant="primary"` → `"primary"`
|
|
107
|
+
- Card with `isSelectable` → `"selectable"`
|
|
108
|
+
- InputGroup with icon on left → `"with-icon-before"`
|
|
109
|
+
- List with icons → `"with-icons"`
|
|
110
|
+
- Timestamp with `format="12-hour"` → `"12-hour"`
|
|
111
|
+
|
|
112
|
+
**Note:** Variants can combine (e.g., `"primary-danger"` for a primary button that's also danger)
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### 4. `data-context` - "Where it's USED"
|
|
117
|
+
|
|
118
|
+
**Function:** `inferContext(componentName, props, parentContext, parentPurpose)`
|
|
119
|
+
|
|
120
|
+
**What it does:**
|
|
121
|
+
- Takes component name, props, and parent context/purpose
|
|
122
|
+
- Checks if component should inherit context from parent
|
|
123
|
+
- Returns a context string describing where the component is typically used
|
|
124
|
+
|
|
125
|
+
**Common contexts:**
|
|
126
|
+
- `"form"` - Inside forms
|
|
127
|
+
- `"modal"` - Inside modals
|
|
128
|
+
- `"overlay"` - Inside modals or drawers (overlay components)
|
|
129
|
+
- `"toolbar"` - Inside toolbars
|
|
130
|
+
- `"table"` - Inside tables
|
|
131
|
+
- `"card"` - Inside cards
|
|
132
|
+
- `"page"` - On pages (rendered as `"in-page"` in HTML)
|
|
133
|
+
- `"masthead"` - In the top navigation bar
|
|
134
|
+
- `"sidebar"` - In sidebars
|
|
135
|
+
- `"wizard"` - Inside wizards
|
|
136
|
+
- `"authentication"` - Inside login forms
|
|
137
|
+
|
|
138
|
+
**How it works:**
|
|
139
|
+
1. First checks if component has a specific context (e.g., `LoginForm` → `"authentication"`)
|
|
140
|
+
2. Then checks `parentContext` (inherited from parent via `findParentContext()` in transform.js)
|
|
141
|
+
3. For Forms, checks `parentPurpose` - if Form has purpose like "create", children get context "create" (not "form")
|
|
142
|
+
4. Defaults to a common context if no parent context found
|
|
143
|
+
|
|
144
|
+
**Special cases:**
|
|
145
|
+
- `Page` → returns `null` (it's the root), but its children get `"page"` context
|
|
146
|
+
- `Toolbar` → provides `"toolbar"` context to its children
|
|
147
|
+
- `Wizard` → provides `"wizard"` context to its children
|
|
148
|
+
- `Sidebar` → provides `"sidebar"` context to its children
|
|
149
|
+
- `Modal` and `Drawer` → both return `"overlay"` context
|
|
150
|
+
- `data-context="page"` → rendered as `data-context="in-page"` in HTML
|
|
151
|
+
|
|
152
|
+
**Props checked:**
|
|
153
|
+
- `isModal` → for Wizard (determines if overlay or page context)
|
|
154
|
+
- `parentContext` → inherited from parent component
|
|
155
|
+
- `parentPurpose` → inherited from Form parent (for purpose-based context)
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### 5. `data-state` - "Current STATE"
|
|
160
|
+
|
|
161
|
+
**Function:** `inferState(componentName, props)`
|
|
162
|
+
|
|
163
|
+
**What it does:**
|
|
164
|
+
- Takes component name and props
|
|
165
|
+
- Checks for state-related props (disabled, checked, selected, open, etc.)
|
|
166
|
+
- Returns a state string describing the current state
|
|
167
|
+
|
|
168
|
+
**Common states:**
|
|
169
|
+
- `"disabled"` - Component is disabled
|
|
170
|
+
- `"checked"` - Checkbox/radio is checked
|
|
171
|
+
- `"unchecked"` - Checkbox/radio is unchecked
|
|
172
|
+
- `"selected"` - Item is selected
|
|
173
|
+
- `"unselected"` - Item is not selected
|
|
174
|
+
- `"open"` - Menu/dropdown/modal is open
|
|
175
|
+
- `"closed"` - Menu/dropdown/modal is closed
|
|
176
|
+
- `"expanded"` - Accordion/tree item is expanded
|
|
177
|
+
- `"collapsed"` - Accordion/tree item is collapsed
|
|
178
|
+
- `"read-only"` - Input is read-only
|
|
179
|
+
- `"edit"` - InlineEdit is in edit mode
|
|
180
|
+
- `"error"` - Input has error validation
|
|
181
|
+
- `"warning"` - Input has warning validation
|
|
182
|
+
- `"active"` - Component is active/current
|
|
183
|
+
- `"loading"` - Component is loading
|
|
184
|
+
|
|
185
|
+
**Props checked:**
|
|
186
|
+
- `isDisabled`, `disabled` → `"disabled"`
|
|
187
|
+
- `isChecked`, `checked` → `"checked"`
|
|
188
|
+
- `isSelected`, `selected` → `"selected"`
|
|
189
|
+
- `isOpen`, `open` → `"open"` or `"closed"`
|
|
190
|
+
- `isExpanded`, `expanded` → `"expanded"` or `"collapsed"`
|
|
191
|
+
- `isReadOnly`, `readOnly` → `"read-only"`
|
|
192
|
+
- `isInvalid`, `invalid`, `validated="error"` → `"error"`
|
|
193
|
+
- `validated="warning"` → `"warning"`
|
|
194
|
+
- `isActive`, `active` → `"active"`
|
|
195
|
+
- `isCurrent` → `"current"` (for wizard steps)
|
|
196
|
+
- `isVisited` → `"visited"` (for wizard steps)
|
|
197
|
+
|
|
198
|
+
**Special cases:**
|
|
199
|
+
- Some components don't have states (display components like Timestamp, Title)
|
|
200
|
+
- Some states are component-specific (e.g., wizard steps have "visited", "current", "disabled")
|
|
201
|
+
- HelperText state is detected and applied to the form input it's associated with
|
|
202
|
+
|
|
203
|
+
**Examples:**
|
|
204
|
+
- Button with `isDisabled={true}` → `"disabled"`
|
|
205
|
+
- Checkbox with `isChecked={true}` → `"checked"`
|
|
206
|
+
- Menu with `isOpen={true}` → `"open"`
|
|
207
|
+
- Input with `validated="error"` → `"error"`
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### 6. `data-action-type` - "Type of ACTION"
|
|
212
|
+
|
|
213
|
+
**Function:** `inferActionType(componentName, props)`
|
|
214
|
+
|
|
215
|
+
**What it does:**
|
|
216
|
+
- Takes component name and props
|
|
217
|
+
- Determines the type of action the component performs
|
|
218
|
+
- Only applies to interactive components
|
|
219
|
+
|
|
220
|
+
**Common action types:**
|
|
221
|
+
- `"destructive"` - Dangerous actions (delete, remove) - from `variant="danger"`
|
|
222
|
+
- `"navigation"` - Navigation actions (links, tabs, pagination, skip links)
|
|
223
|
+
- `"actionable"` - Alert links that perform actions
|
|
224
|
+
- `"toggle"` - Toggle actions (Switch, toggle groups)
|
|
225
|
+
- `"selection"` - Selection actions (ToggleGroup, TreeView)
|
|
226
|
+
- `"form"` - Form actions (Wizard)
|
|
227
|
+
- `"determinate"` - Progress with measurable value (Progress, ProgressStepper)
|
|
228
|
+
- `"indeterminate"` - Progress without measurable value (Spinner)
|
|
229
|
+
|
|
230
|
+
**Props checked:**
|
|
231
|
+
- `variant="danger"` → `"destructive"`
|
|
232
|
+
- `href` → `"navigation"`
|
|
233
|
+
- `actionType` prop → if explicitly set
|
|
234
|
+
|
|
235
|
+
**Special cases:**
|
|
236
|
+
- Most components return `null` (no action-type needed)
|
|
237
|
+
- Only interactive components get action-type
|
|
238
|
+
- Progress components use action-type to distinguish determinate vs indeterminate
|
|
239
|
+
|
|
240
|
+
**Examples:**
|
|
241
|
+
- Button with `variant="danger"` → `"destructive"`
|
|
242
|
+
- Link with `href` → `"navigation"`
|
|
243
|
+
- Switch → `"toggle"`
|
|
244
|
+
- Progress → `"determinate"`
|
|
245
|
+
- Spinner → `"indeterminate"`
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### 7. `data-size` - "SIZE/SPACING"
|
|
250
|
+
|
|
251
|
+
**Function:** `inferSize(componentName, props)`
|
|
252
|
+
|
|
253
|
+
**What it does:**
|
|
254
|
+
- Takes component name and props
|
|
255
|
+
- Checks for size-related props
|
|
256
|
+
- Returns a size string
|
|
257
|
+
|
|
258
|
+
**Common sizes:**
|
|
259
|
+
- `"compact"` - Compact spacing
|
|
260
|
+
- `"default"` - Default spacing
|
|
261
|
+
- `"small"`, `"sm"` - Small size
|
|
262
|
+
- `"medium"`, `"md"` - Medium size
|
|
263
|
+
- `"large"`, `"lg"` - Large size
|
|
264
|
+
- `"extra-small"`, `"xs"` - Extra small
|
|
265
|
+
- `"extra-large"`, `"xl"` - Extra large
|
|
266
|
+
|
|
267
|
+
**Props checked:**
|
|
268
|
+
- `size` → most common (e.g., `size="sm"`, `size="lg"`)
|
|
269
|
+
- `isCompact`, `compact` → `"compact"`
|
|
270
|
+
- Component-specific size props
|
|
271
|
+
|
|
272
|
+
**Special cases:**
|
|
273
|
+
- Most components return `null` (size not applicable)
|
|
274
|
+
- Only components that have meaningful size variants get this attribute
|
|
275
|
+
- Icons have size variants (sm, md, lg, xl, 2xl, 3xl)
|
|
276
|
+
- Progress has size variants (small, large)
|
|
277
|
+
- Spinner has size variants (extra-small, small, medium, large)
|
|
278
|
+
|
|
279
|
+
**Examples:**
|
|
280
|
+
- Icon with `size="lg"` → `"lg"`
|
|
281
|
+
- Progress with `size="small"` → `"small"`
|
|
282
|
+
- Spinner with `size="large"` → `"large"`
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Helper Functions
|
|
287
|
+
|
|
288
|
+
### `propsToMap(props)`
|
|
289
|
+
Converts JSX props array to a Map for easy lookup. Handles both `StringLiteral` and `Literal` types.
|
|
290
|
+
|
|
291
|
+
### `findParentContext(path, j)`
|
|
292
|
+
Traverses up the AST to find parent component and determine its context. Returns:
|
|
293
|
+
- `{ context, purpose }` for Forms (so children can inherit purpose)
|
|
294
|
+
- Context string for other parents (Page, Sidebar, Toolbar, Wizard, LoginForm)
|
|
295
|
+
- `null` if no parent context found
|
|
296
|
+
|
|
297
|
+
### Children Analysis Functions
|
|
298
|
+
Some components analyze their children to infer variants:
|
|
299
|
+
- `analyzeInputGroupChildren()` - Checks for buttons/icons/text on left/right
|
|
300
|
+
- `analyzeListChildren()` - Checks for icons in list items
|
|
301
|
+
- `analyzeLoginFormChildren()` - Checks for password toggles, header utilities
|
|
302
|
+
- `analyzeDualListSelectorChildren()` - Checks for tooltips, search, actions
|
|
303
|
+
- `analyzeMastheadChildren()` - Checks for vertical nav
|
|
304
|
+
- `analyzeMenuChildren()` - Checks for menu features (search, favorites, etc.)
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## Summary
|
|
309
|
+
|
|
310
|
+
Each component goes through all 7 functions in order:
|
|
311
|
+
1. `inferRole()` - What it IS (from component name)
|
|
312
|
+
2. `inferPurpose()` - What it DOES (from name + props)
|
|
313
|
+
3. `inferVariant()` - How it LOOKS (from props + sometimes children)
|
|
314
|
+
4. `inferContext()` - Where it's USED (from parent context)
|
|
315
|
+
5. `inferState()` - Current STATE (from props)
|
|
316
|
+
6. `inferActionType()` - Type of ACTION (from name + props)
|
|
317
|
+
7. `inferSize()` - SIZE (from props)
|
|
318
|
+
|
|
319
|
+
If a function returns `null`, that attribute is not added to the component.
|
|
320
|
+
|