@patternfly/patternfly-doc-core 1.5.0 → 1.7.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.
Files changed (91) hide show
  1. package/.astro/collections/examples.schema.json +56 -0
  2. package/.astro/collections/textContent.schema.json +16 -0
  3. package/.astro/content-modules.mjs +4 -1
  4. package/.astro/content.d.ts +20 -1
  5. package/astro.config.mjs +2 -2
  6. package/declarations.d.ts +2 -0
  7. package/dist/client/_astro/Button.IBWho7ny.js +9 -0
  8. package/dist/client/_astro/CSSTable.DHtMmTtQ.js +1185 -0
  9. package/dist/client/_astro/LiveExample.B7IM_dLQ.css +1 -0
  10. package/dist/client/_astro/LiveExample.CwKQ5TSc.js +33 -0
  11. package/dist/client/_astro/Navigation.BSSYIa2f.js +1 -0
  12. package/dist/client/_astro/PageContext.ipir86Hm.js +1 -0
  13. package/dist/client/_astro/PageSidebarBody.tzSXGYXP.js +1 -0
  14. package/dist/client/_astro/PageToggle.C6_rp-Bm.js +1 -0
  15. package/dist/client/_astro/PageToggleButton.CagcouJB.js +1 -0
  16. package/dist/client/_astro/SearchInput.BjY-zTwj.js +1 -0
  17. package/dist/client/_astro/Toolbar.D4TQG77s.js +1 -0
  18. package/dist/client/_astro/ToolbarContent.DzYW_pmy.js +1 -0
  19. package/dist/client/_astro/_page_.BWicMEzd.css +1 -0
  20. package/dist/client/_astro/_page_.Chv_bGyU.css +1 -0
  21. package/dist/client/_astro/_page_.CtheD08_.css +1 -0
  22. package/dist/client/_astro/_page_.DxJDkZPc.css +1 -0
  23. package/dist/client/_astro/client.zs76E0tG.js +1 -0
  24. package/dist/client/_astro/divider.DTvtnAAt.js +1 -0
  25. package/dist/client/_astro/help-icon.CDKTE3GW.js +8 -0
  26. package/dist/client/_astro/index.BQFV5hT1.js +24 -0
  27. package/dist/client/_astro/index.eCxJ45ll.js +9 -0
  28. package/dist/client/_astro/page.BTC3Kf3x.js +1 -0
  29. package/dist/client/components/accordion/index.html +110 -0
  30. package/dist/client/design-foundations/typography/index.html +35 -8
  31. package/dist/client/design-foundations/usage-and-behavior/index.html +35 -8
  32. package/dist/client/get-started/contribute/index.html +35 -8
  33. package/dist/client/index.html +4 -3
  34. package/dist/server/_@astrojs-ssr-adapter.mjs +1 -1
  35. package/dist/server/chunks/Button_DVSwQ8oX.mjs +639 -0
  36. package/dist/server/chunks/CSSTable_CG80uW98.mjs +740 -0
  37. package/dist/server/chunks/CSSTable_Dj2CroFz.mjs +4 -0
  38. package/dist/server/chunks/{PropsTables_MQNZVYdD.mjs → PropsTables_DUo7F9VR.mjs} +169 -246
  39. package/dist/server/chunks/Stack_Xm3fJVbK.mjs +22 -0
  40. package/dist/server/chunks/{_@astrojs-ssr-adapter_8jk9s5dg.mjs → _@astrojs-ssr-adapter_CbICuCdt.mjs} +2 -2
  41. package/dist/server/chunks/{_astro_assets_CmxVRFAY.mjs → _astro_assets_DaYumpRZ.mjs} +2 -2
  42. package/dist/server/chunks/_astro_data-layer-content_1EAcQtZj.mjs +1 -0
  43. package/dist/server/chunks/{angle-down-icon_BNJvzYv-.mjs → angle-down-icon_DtGGiMR5.mjs} +150 -832
  44. package/dist/server/chunks/astro/{server_zRMEhmuT.mjs → server_Cl9jPh4p.mjs} +179 -89
  45. package/dist/server/chunks/{astro-designed-error-pages_DRBnGamN.mjs → astro-designed-error-pages_BFveJFnQ.mjs} +1 -1
  46. package/dist/server/chunks/content-modules_BzUEG69n.mjs +1 -0
  47. package/dist/server/chunks/{sharp_BAxaBZQw.mjs → sharp_CbOL3WDk.mjs} +2 -2
  48. package/dist/server/entry.mjs +4 -3
  49. package/dist/server/{manifest_7YAgSoyv.mjs → manifest_Dpwo8Jjv.mjs} +3 -3
  50. package/dist/server/pages/_image.astro.mjs +1 -1
  51. package/dist/server/renderers.mjs +63 -14
  52. package/jest.config.ts +1 -1
  53. package/package.json +5 -2
  54. package/src/components/AutoLinkHeader.tsx +56 -0
  55. package/src/components/CSSSearch.tsx +33 -0
  56. package/src/components/CSSTable.astro +33 -0
  57. package/src/components/CSSTable.tsx +268 -0
  58. package/src/components/Content.tsx +61 -0
  59. package/src/components/ExampleToolbar.tsx +296 -0
  60. package/src/components/LiveExample.astro +7 -0
  61. package/src/components/LiveExample.tsx +42 -0
  62. package/src/content.config.ts +10 -3
  63. package/src/content.ts +2 -1
  64. package/src/layouts/Main.astro +12 -8
  65. package/src/pages/[section]/[...page].astro +16 -6
  66. package/src/pages/[section]/[page]/[...tab].astro +107 -40
  67. package/src/pages/index.astro +0 -1
  68. package/src/styles/global.scss +47 -1
  69. package/src/utils/index.ts +1 -0
  70. package/src/utils/slugger.ts +14 -0
  71. package/textContent/contribute.md +19 -13
  72. package/textContent/examples/Accordion/Accordion.mdx +45 -0
  73. package/textContent/examples/Accordion/AccordionBordered.tsx +141 -0
  74. package/textContent/examples/Accordion/AccordionDefinitionList.tsx +102 -0
  75. package/textContent/examples/Accordion/AccordionFixedWithMultipleExpandBehavior.tsx +128 -0
  76. package/textContent/examples/Accordion/AccordionSingleExpandBehavior.tsx +118 -0
  77. package/textContent/examples/Accordion/AccordionToggleIconAtStart.tsx +118 -0
  78. package/dist/client/_astro/Button.C3_jB5tC.js +0 -9
  79. package/dist/client/_astro/Navigation.CULUlMEB.js +0 -1
  80. package/dist/client/_astro/PageContext.C7BqCh9N.js +0 -1
  81. package/dist/client/_astro/PageToggle.DDEjruql.js +0 -1
  82. package/dist/client/_astro/Toolbar.TAdHxLSQ.js +0 -1
  83. package/dist/client/_astro/_page_.CXyz_BEo.css +0 -1
  84. package/dist/client/_astro/_page_.DVvr_Mfl.css +0 -1
  85. package/dist/client/_astro/_page_.SnUmZn2y.css +0 -1
  86. package/dist/client/_astro/client.CeeiqVaE.js +0 -1
  87. package/dist/client/_astro/divider.BSD-oFoh.js +0 -1
  88. package/dist/client/_astro/index.CTH3fVMn.js +0 -32
  89. package/dist/client/_astro/page.B65lVdBS.js +0 -1
  90. /package/dist/server/chunks/{_astro_data-layer-content_DDGBHvtb.mjs → Accordion_CGgMUho2.mjs} +0 -0
  91. /package/dist/server/chunks/{content-modules_Dz-S_Wwv.mjs → Accordion_DlM2LvlF.mjs} +0 -0
@@ -0,0 +1,56 @@
1
+ import { Flex, FlexItem, Content, Button } from '@patternfly/react-core'
2
+ import LinkIcon from '@patternfly/react-icons/dist/esm/icons/link-icon'
3
+ import { slugger } from '../utils/slugger'
4
+ import { css } from '@patternfly/react-styles'
5
+
6
+ interface AutoLinkHeaderProps extends React.HTMLProps<HTMLDivElement> {
7
+ id?: string
8
+ headingLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
9
+ children: React.ReactNode
10
+ metaText?: React.ReactNode
11
+ className?: string
12
+ }
13
+
14
+ export const AutoLinkHeader = ({
15
+ id,
16
+ headingLevel,
17
+ children,
18
+ metaText,
19
+ className,
20
+ }: AutoLinkHeaderProps) => {
21
+ const slug = id || slugger(children)
22
+
23
+ return (
24
+ <Flex
25
+ alignItems={{ default: 'alignItemsCenter' }}
26
+ spaceItems={{ default: 'spaceItemsSm' }}
27
+ >
28
+ <FlexItem>
29
+ <Content
30
+ id={slug}
31
+ component={headingLevel}
32
+ className={css('ws-heading', className)}
33
+ tabIndex={-1}
34
+ isEditorial
35
+ >
36
+ <Button
37
+ href={`#${slug}`}
38
+ component="a"
39
+ className="ws-heading-anchor"
40
+ tabIndex={-1}
41
+ aria-hidden
42
+ variant="plain"
43
+ isInline
44
+ >
45
+ <LinkIcon
46
+ className="ws-heading-anchor-icon"
47
+ style={{ verticalAlign: 'middle' }}
48
+ />
49
+ </Button>
50
+ {children}
51
+ </Content>
52
+ </FlexItem>
53
+ {metaText && <FlexItem>{metaText}</FlexItem>}
54
+ </Flex>
55
+ )
56
+ }
@@ -0,0 +1,33 @@
1
+ import { useState } from 'react'
2
+ import { SearchInput } from '@patternfly/react-core'
3
+
4
+ interface CSSSearchProps {
5
+ getDebouncedFilteredRows: (value: string) => void
6
+ 'aria-label'?: string
7
+ placeholder?: string
8
+ }
9
+
10
+ export const CSSSearch: React.FC<CSSSearchProps> = ({
11
+ getDebouncedFilteredRows,
12
+ 'aria-label': ariaLabel = 'Filter CSS Variables',
13
+ placeholder = 'Filter CSS Variables',
14
+ }: CSSSearchProps) => {
15
+ const [filterValue, setFilterValue] = useState('')
16
+
17
+ const onFilterChange = (
18
+ _event: React.FormEvent<HTMLInputElement>,
19
+ value: string,
20
+ ) => {
21
+ setFilterValue(value)
22
+ getDebouncedFilteredRows(value)
23
+ }
24
+
25
+ return (
26
+ <SearchInput
27
+ aria-label={ariaLabel}
28
+ placeholder={placeholder}
29
+ value={filterValue}
30
+ onChange={onFilterChange}
31
+ />
32
+ )
33
+ }
@@ -0,0 +1,33 @@
1
+ ---
2
+ import { CSSTable as CSSTableComponent } from './CSSTable'
3
+ import { AutoLinkHeader } from './AutoLinkHeader'
4
+ import { Stack, StackItem } from '@patternfly/react-core'
5
+
6
+ const { cssPrefix } = Astro.props
7
+ ---
8
+
9
+ {
10
+ cssPrefix?.length > 0 && (
11
+ <Stack hasGutter>
12
+ <StackItem>
13
+ <AutoLinkHeader
14
+ headingLevel="h2"
15
+ className="pf-v6-c-content--h2"
16
+ id="css-variables"
17
+ >
18
+ CSS variables
19
+ </AutoLinkHeader>
20
+ </StackItem>
21
+
22
+ {cssPrefix.map((prefix: string, index: number) => (
23
+ <StackItem key={index}>
24
+ <CSSTableComponent
25
+ autoLinkHeader={cssPrefix.length > 1}
26
+ cssPrefix={prefix}
27
+ client:only="react"
28
+ />
29
+ </StackItem>
30
+ ))}
31
+ </Stack>
32
+ )
33
+ }
@@ -0,0 +1,268 @@
1
+ import { debounce, List, ListItem, Stack } from '@patternfly/react-core'
2
+ import { Table, Thead, Th, Tr, Tbody, Td } from '@patternfly/react-table'
3
+ import { useState } from 'react'
4
+ import LevelUpAltIcon from '@patternfly/react-icons/dist/esm/icons/level-up-alt-icon'
5
+ import * as tokensModule from '@patternfly/react-tokens/dist/esm/componentIndex'
6
+ import React from 'react'
7
+ import { CSSSearch } from './CSSSearch'
8
+ import { AutoLinkHeader } from './AutoLinkHeader'
9
+
10
+ type Value = {
11
+ name: string
12
+ value: string
13
+ values?: string[]
14
+ }
15
+
16
+ type FileList = {
17
+ [key: string]: {
18
+ name: string
19
+ value: string
20
+ values?: Value[]
21
+ }
22
+ }
23
+
24
+ type List = {
25
+ selector: string
26
+ property: string
27
+ token: string
28
+ value: string
29
+ values?: string[]
30
+ }
31
+
32
+ type FilteredRows = {
33
+ cells: React.ReactNode[]
34
+ isOpen?: boolean
35
+ details?: { parent: number; fullWidth: boolean; data: React.ReactNode }
36
+ }
37
+
38
+ interface CSSTableProps extends React.HTMLProps<HTMLDivElement> {
39
+ cssPrefix: string
40
+ hideSelectorColumn?: boolean
41
+ selector?: string
42
+ debounceLength?: number
43
+ autoLinkHeader?: boolean
44
+ }
45
+
46
+ const isColorRegex = /^(#|rgb)/
47
+ const mappingAsList = (property: string, values: string[]) => (
48
+ <List isPlain>
49
+ <ListItem>{property}</ListItem>
50
+ {values.map((entry: string) => (
51
+ <ListItem key={entry} icon={<LevelUpAltIcon className="rotate-90-deg" />}>
52
+ {entry}
53
+ </ListItem>
54
+ ))}
55
+ </List>
56
+ )
57
+
58
+ const flattenList = (files: FileList[]) => {
59
+ const list = [] as List[]
60
+ files.forEach((file) => {
61
+ Object.entries(file).forEach(([selector, values]) => {
62
+ if (values !== undefined) {
63
+ Object.entries(values).forEach(([key, val]) => {
64
+ if (typeof val === 'object' && val !== null && 'name' in val) {
65
+ const v = val as unknown as Value
66
+ list.push({
67
+ selector,
68
+ property: v.name,
69
+ token: key,
70
+ value: v.value,
71
+ values: v.values,
72
+ })
73
+ }
74
+ })
75
+ }
76
+ })
77
+ })
78
+ return list
79
+ }
80
+
81
+ export const CSSTable: React.FunctionComponent<CSSTableProps> = ({
82
+ cssPrefix,
83
+ hideSelectorColumn = false,
84
+ selector,
85
+ debounceLength = 500,
86
+ autoLinkHeader,
87
+ }) => {
88
+ const prefixToken = cssPrefix.replace('pf-v6-', '').replace(/-+/g, '_')
89
+
90
+ const applicableFiles = Object.entries(tokensModule)
91
+ .filter(([key, _val]) => prefixToken === key)
92
+ .sort(([key1], [key2]) => key1.localeCompare(key2))
93
+ .map(([_key, val]) => {
94
+ if (selector) {
95
+ return {
96
+ selector: (val as Record<string, any>)[selector],
97
+ }
98
+ }
99
+ return val
100
+ })
101
+
102
+ const flatList = flattenList(applicableFiles as any)
103
+
104
+ const getFilteredRows = (searchRE?: RegExp) => {
105
+ const newFilteredRows = [] as FilteredRows[]
106
+ let rowNumber = -1
107
+ flatList.forEach((row) => {
108
+ const { selector, property, value, values } = row
109
+ const passes =
110
+ !searchRE ||
111
+ searchRE.test(selector) ||
112
+ searchRE.test(property) ||
113
+ searchRE.test(value) ||
114
+ (values && searchRE.test(JSON.stringify(values)))
115
+ if (passes) {
116
+ const rowKey = `${selector}_${property}`
117
+ const isColor = isColorRegex.test(value)
118
+ const cells = [
119
+ hideSelectorColumn ? [] : [selector],
120
+ property,
121
+ <div key={rowKey}>
122
+ <div
123
+ key={`${rowKey}_1`}
124
+ className="pf-v6-l-flex pf-m-space-items-sm"
125
+ >
126
+ {isColor && (
127
+ <div
128
+ key={`${rowKey}_2`}
129
+ className="pf-v6-l-flex pf-m-column pf-m-align-self-center"
130
+ >
131
+ <span
132
+ className="circle"
133
+ style={{ backgroundColor: `${value}` }}
134
+ />
135
+ </div>
136
+ )}
137
+ <div
138
+ key={`${rowKey}_3`}
139
+ className="pf-v6-l-flex pf-m-column pf-m-align-self-center ws-td-text"
140
+ >
141
+ {isColor && '(In light theme)'} {value}
142
+ </div>
143
+ </div>
144
+ </div>,
145
+ ]
146
+ newFilteredRows.push({
147
+ isOpen: values ? false : undefined,
148
+ cells,
149
+ details: values
150
+ ? {
151
+ parent: rowNumber,
152
+ fullWidth: true,
153
+ data: mappingAsList(property, values),
154
+ }
155
+ : undefined,
156
+ })
157
+ rowNumber += 1
158
+ if (values) {
159
+ rowNumber += 1
160
+ }
161
+ }
162
+ })
163
+ return newFilteredRows
164
+ }
165
+
166
+ const INITIAL_REGEX = /.*/
167
+ const [searchRE, setSearchRE] = useState<RegExp>(INITIAL_REGEX)
168
+ const [rows, setRows] = useState(getFilteredRows(searchRE))
169
+
170
+ const hasPrefixToRender = !(typeof cssPrefix === 'undefined')
171
+
172
+ const onCollapse = (
173
+ _event: React.MouseEvent,
174
+ rowKey: number,
175
+ isOpen: boolean,
176
+ ) => {
177
+ const collapseAll = rowKey === undefined
178
+ let newRows = Array.from(rows)
179
+
180
+ if (collapseAll) {
181
+ newRows = newRows.map((r) =>
182
+ r.isOpen === undefined ? r : { ...r, isOpen },
183
+ )
184
+ } else {
185
+ newRows[rowKey] = { ...newRows[rowKey], isOpen }
186
+ }
187
+ setRows(newRows)
188
+ }
189
+
190
+ const getDebouncedFilteredRows = debounce((value) => {
191
+ const newSearchRE = new RegExp(value, 'i')
192
+ setSearchRE(newSearchRE)
193
+ setRows(getFilteredRows(newSearchRE))
194
+ }, debounceLength)
195
+
196
+ return (
197
+ <Stack hasGutter>
198
+ {hasPrefixToRender && (
199
+ <>
200
+ {autoLinkHeader && (
201
+ <AutoLinkHeader
202
+ headingLevel="h3"
203
+ className="pf-v6-u-mt-lg pf-v6-u-mb-md"
204
+ >{`Prefixed with '${cssPrefix}'`}</AutoLinkHeader>
205
+ )}
206
+ <CSSSearch getDebouncedFilteredRows={getDebouncedFilteredRows} />
207
+ <Table
208
+ variant="compact"
209
+ aria-label={`CSS Variables prefixed with ${cssPrefix}`}
210
+ >
211
+ <Thead>
212
+ <Tr>
213
+ {!hideSelectorColumn && (
214
+ <React.Fragment>
215
+ <Th screenReaderText="Expand or collapse column" />
216
+ <Th>Selector</Th>
217
+ </React.Fragment>
218
+ )}
219
+ <Th>Variable</Th>
220
+ <Th>Value</Th>
221
+ </Tr>
222
+ </Thead>
223
+ {!hideSelectorColumn ? (
224
+ rows.map((row, rowIndex: number) => (
225
+ <Tbody key={rowIndex} isExpanded={row.isOpen}>
226
+ <Tr>
227
+ <Td
228
+ expand={
229
+ row.details
230
+ ? {
231
+ rowIndex,
232
+ isExpanded: row.isOpen || false,
233
+ onToggle: onCollapse,
234
+ expandId: `css-vars-expandable-toggle-${cssPrefix}`,
235
+ }
236
+ : undefined
237
+ }
238
+ />
239
+ <Td dataLabel="Selector">{row.cells[0]}</Td>
240
+ <Td dataLabel="Variable">{row.cells[1]}</Td>
241
+ <Td dataLabel="Value">{row.cells[2]}</Td>
242
+ </Tr>
243
+ {row.details ? (
244
+ <Tr isExpanded={row.isOpen}>
245
+ {!row.details.fullWidth ? <Td /> : null}
246
+ <Td dataLabel="Selector" colSpan={5}>
247
+ {row.details.data}
248
+ </Td>
249
+ </Tr>
250
+ ) : null}
251
+ </Tbody>
252
+ ))
253
+ ) : (
254
+ <Tbody>
255
+ {rows.map((row, rowIndex: number) => (
256
+ <Tr key={rowIndex}>
257
+ <Td dataLabel="Variable">{row.cells[0]}</Td>
258
+ <Td dataLabel="Value">{row.cells[1]}</Td>
259
+ </Tr>
260
+ ))}
261
+ </Tbody>
262
+ )}
263
+ </Table>
264
+ </>
265
+ )}
266
+ </Stack>
267
+ )
268
+ }
@@ -0,0 +1,61 @@
1
+ import { Content as PFContent } from '@patternfly/react-core'
2
+ import { ReactNode } from 'react'
3
+
4
+ export const h1 = ({ children }: { children: ReactNode }) => (
5
+ <PFContent component="h1">{children}</PFContent>
6
+ )
7
+ export const h2 = ({ children }: { children: ReactNode }) => (
8
+ <PFContent component="h2">{children}</PFContent>
9
+ )
10
+ export const h3 = ({ children }: { children: ReactNode }) => (
11
+ <PFContent component="h3">{children}</PFContent>
12
+ )
13
+ export const h4 = ({ children }: { children: ReactNode }) => (
14
+ <PFContent component="h4">{children}</PFContent>
15
+ )
16
+ export const h5 = ({ children }: { children: ReactNode }) => (
17
+ <PFContent component="h5">{children}</PFContent>
18
+ )
19
+ export const h6 = ({ children }: { children: ReactNode }) => (
20
+ <PFContent component="h6">{children}</PFContent>
21
+ )
22
+
23
+ export const p = ({ children }: { children: ReactNode }) => (
24
+ <PFContent component="p">{children}</PFContent>
25
+ )
26
+ export const a = ({ children }: { children: ReactNode }) => (
27
+ <PFContent component="a">{children}</PFContent>
28
+ )
29
+ export const small = ({ children }: { children: ReactNode }) => (
30
+ <PFContent component="small">{children}</PFContent>
31
+ )
32
+
33
+ export const blockquote = ({ children }: { children: ReactNode }) => (
34
+ <PFContent component="blockquote">{children}</PFContent>
35
+ )
36
+ export const pre = ({ children }: { children: ReactNode }) => (
37
+ <PFContent component="pre">{children}</PFContent>
38
+ )
39
+ export const hr = ({ children }: { children: ReactNode }) => (
40
+ <PFContent component="hr">{children}</PFContent>
41
+ )
42
+
43
+ export const ul = ({ children }: { children: ReactNode }) => (
44
+ <PFContent component="ul">{children}</PFContent>
45
+ )
46
+ export const ol = ({ children }: { children: ReactNode }) => (
47
+ <PFContent component="ol">{children}</PFContent>
48
+ )
49
+ export const dl = ({ children }: { children: ReactNode }) => (
50
+ <PFContent component="dl">{children}</PFContent>
51
+ )
52
+ export const li = ({ children }: { children: ReactNode }) => (
53
+ <PFContent component="li">{children}</PFContent>
54
+ )
55
+
56
+ export const dt = ({ children }: { children: ReactNode }) => (
57
+ <PFContent component="dt">{children}</PFContent>
58
+ )
59
+ export const dd = ({ children }: { children: ReactNode }) => (
60
+ <PFContent component="dd">{children}</PFContent>
61
+ )