@papillonarts/components 0.34.0 → 0.36.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/build/Legacy/Alert/__tests__/{Alert.markdown.docs.md → Alert.doc.md} +12 -12
- package/build/Legacy/Blankslate/__tests__/Blankslate.doc.md +57 -0
- package/build/Legacy/Breadcrumb/__tests__/Breadcrumb.doc.md +33 -0
- package/build/Legacy/Markdown/Markdown.d.ts +3 -0
- package/build/Legacy/Markdown/Markdown.d.ts.map +1 -0
- package/build/Legacy/{MarkdownDocs/MarkdownDocs.js → Markdown/Markdown.js} +15 -15
- package/build/Legacy/Markdown/Markdown.type.d.ts +15 -0
- package/build/Legacy/Markdown/Markdown.type.d.ts.map +1 -0
- package/build/Legacy/Markdown/Markdown.type.js +14 -0
- package/build/Legacy/Markdown/__tests__/Markdown.doc.md +33 -0
- package/build/Legacy/Markdown/index.d.ts +2 -0
- package/build/Legacy/Markdown/index.d.ts.map +1 -0
- package/build/Legacy/Markdown/index.js +12 -0
- package/build/Legacy/SyntaxHighlighter/SyntaxHighlighter.d.ts +3 -0
- package/build/Legacy/SyntaxHighlighter/SyntaxHighlighter.d.ts.map +1 -0
- package/build/Legacy/SyntaxHighlighter/SyntaxHighlighter.js +39 -0
- package/build/Legacy/SyntaxHighlighter/SyntaxHighlighter.type.d.ts +32 -0
- package/build/Legacy/SyntaxHighlighter/SyntaxHighlighter.type.d.ts.map +1 -0
- package/build/Legacy/SyntaxHighlighter/SyntaxHighlighter.type.js +25 -0
- package/build/Legacy/SyntaxHighlighter/SyntaxHighlighterHLJS.d.ts +3 -0
- package/build/Legacy/SyntaxHighlighter/SyntaxHighlighterHLJS.d.ts.map +1 -0
- package/build/Legacy/{PreformattedCode/PreformattedCodeHLJS.js → SyntaxHighlighter/SyntaxHighlighterHLJS.js} +6 -6
- package/build/Legacy/SyntaxHighlighter/SyntaxHighlighterPrism.d.ts +3 -0
- package/build/Legacy/SyntaxHighlighter/SyntaxHighlighterPrism.d.ts.map +1 -0
- package/build/Legacy/{PreformattedCode/PreformattedCodePrism.js → SyntaxHighlighter/SyntaxHighlighterPrism.js} +6 -6
- package/build/Legacy/SyntaxHighlighter/__tests__/SyntaxHighlighter.doc.md +61 -0
- package/build/Legacy/SyntaxHighlighter/index.d.ts +3 -0
- package/build/Legacy/SyntaxHighlighter/index.d.ts.map +1 -0
- package/build/Legacy/SyntaxHighlighter/index.js +31 -0
- package/build/Legacy/index.d.ts +4 -4
- package/build/Legacy/index.d.ts.map +1 -1
- package/build/Legacy/index.js +4 -4
- package/build/Modern/Flash/Flash.d.ts +1 -2
- package/build/Modern/Flash/Flash.d.ts.map +1 -1
- package/build/Modern/Flash/Flash.js +3 -4
- package/build/Modern/Flash/__tests__/Flash.doc.md +11 -0
- package/build/Modern/Flash/index.d.ts +1 -1
- package/build/Modern/Flash/index.d.ts.map +1 -1
- package/build/Modern/Flash/index.js +3 -4
- package/build/Modern/Link/Link.d.ts +19 -0
- package/build/Modern/Link/Link.d.ts.map +1 -0
- package/build/Modern/Link/Link.docs.json +61 -0
- package/build/Modern/Link/Link.js +57 -0
- package/build/Modern/Link/Link.module.scss +39 -0
- package/build/Modern/Link/__tests__/Link.doc.md +10 -0
- package/build/Modern/Link/index.d.ts +3 -0
- package/build/Modern/Link/index.d.ts.map +1 -0
- package/build/Modern/Link/index.js +12 -0
- package/build/Modern/Pagination/Pagination.d.ts +22 -0
- package/build/Modern/Pagination/Pagination.d.ts.map +1 -0
- package/build/Modern/Pagination/Pagination.docs.json +77 -0
- package/build/Modern/Pagination/Pagination.js +132 -0
- package/build/Modern/Pagination/Pagination.model.d.ts +26 -0
- package/build/Modern/Pagination/Pagination.model.d.ts.map +1 -0
- package/build/Modern/Pagination/Pagination.model.js +211 -0
- package/build/Modern/Pagination/Pagination.module.scss +141 -0
- package/build/Modern/Pagination/__tests__/Pagination.doc.md +12 -0
- package/build/Modern/Pagination/index.d.ts +3 -0
- package/build/Modern/Pagination/index.d.ts.map +1 -0
- package/build/Modern/Pagination/index.js +12 -0
- package/build/Modern/hooks/index.d.ts +3 -0
- package/build/Modern/hooks/index.d.ts.map +1 -0
- package/build/Modern/hooks/index.js +19 -0
- package/build/Modern/hooks/useMedia.d.ts +37 -0
- package/build/Modern/hooks/useMedia.d.ts.map +1 -0
- package/build/Modern/hooks/useMedia.js +141 -0
- package/build/Modern/hooks/useRefObjectAsForwardedRef.d.ts +10 -0
- package/build/Modern/hooks/useRefObjectAsForwardedRef.d.ts.map +1 -0
- package/build/Modern/hooks/useRefObjectAsForwardedRef.hookDocs.json +22 -0
- package/build/Modern/hooks/useRefObjectAsForwardedRef.js +19 -0
- package/build/Modern/hooks/useResponsiveValue.d.ts +31 -0
- package/build/Modern/hooks/useResponsiveValue.d.ts.map +1 -0
- package/build/Modern/hooks/useResponsiveValue.js +73 -0
- package/build/Modern/index.d.ts +24 -0
- package/build/Modern/index.d.ts.map +1 -1
- package/build/Modern/index.js +11 -3
- package/build/Modern/type.d.ts +4 -0
- package/build/Modern/type.d.ts.map +1 -0
- package/build/Modern/type.js +5 -0
- package/build/Modern/utils/environment.d.ts +11 -0
- package/build/Modern/utils/environment.d.ts.map +1 -0
- package/build/Modern/utils/environment.js +13 -0
- package/build/Modern/utils/modern-polymorphic.d.ts +22 -0
- package/build/Modern/utils/modern-polymorphic.d.ts.map +1 -0
- package/build/Modern/utils/modern-polymorphic.js +28 -0
- package/build/Modern/utils/types/ComponentProps.d.ts +9 -0
- package/build/Modern/utils/types/ComponentProps.d.ts.map +1 -0
- package/build/Modern/utils/types/ComponentProps.js +5 -0
- package/build/Modern/utils/types/index.d.ts +3 -0
- package/build/Modern/utils/types/index.d.ts.map +1 -0
- package/build/Modern/utils/types/index.js +27 -0
- package/build/Modern/utils/warning.d.ts +4 -0
- package/build/Modern/utils/warning.d.ts.map +1 -0
- package/build/Modern/utils/warning.js +25 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/build/Legacy/MarkdownDocs/MarkdownDocs.d.ts +0 -3
- package/build/Legacy/MarkdownDocs/MarkdownDocs.d.ts.map +0 -1
- package/build/Legacy/MarkdownDocs/MarkdownDocs.type.d.ts +0 -15
- package/build/Legacy/MarkdownDocs/MarkdownDocs.type.d.ts.map +0 -1
- package/build/Legacy/MarkdownDocs/MarkdownDocs.type.js +0 -14
- package/build/Legacy/MarkdownDocs/__tests__/MarkdownDocs.markdown.docs.md +0 -33
- package/build/Legacy/MarkdownDocs/index.d.ts +0 -2
- package/build/Legacy/MarkdownDocs/index.d.ts.map +0 -1
- package/build/Legacy/MarkdownDocs/index.js +0 -12
- package/build/Legacy/PreformattedCode/PreformattedCode.d.ts +0 -3
- package/build/Legacy/PreformattedCode/PreformattedCode.d.ts.map +0 -1
- package/build/Legacy/PreformattedCode/PreformattedCode.js +0 -39
- package/build/Legacy/PreformattedCode/PreformattedCode.type.d.ts +0 -32
- package/build/Legacy/PreformattedCode/PreformattedCode.type.d.ts.map +0 -1
- package/build/Legacy/PreformattedCode/PreformattedCode.type.js +0 -25
- package/build/Legacy/PreformattedCode/PreformattedCodeHLJS.d.ts +0 -3
- package/build/Legacy/PreformattedCode/PreformattedCodeHLJS.d.ts.map +0 -1
- package/build/Legacy/PreformattedCode/PreformattedCodePrism.d.ts +0 -3
- package/build/Legacy/PreformattedCode/PreformattedCodePrism.d.ts.map +0 -1
- package/build/Legacy/PreformattedCode/__tests__/PreformattedCode.markdown.docs.md +0 -61
- package/build/Legacy/PreformattedCode/index.d.ts +0 -3
- package/build/Legacy/PreformattedCode/index.d.ts.map +0 -1
- package/build/Legacy/PreformattedCode/index.js +0 -31
- package/build/Modern/Typing/index.d.js +0 -1
- package/build/Modern/global.d.js +0 -1
- /package/build/Modern/Flash/__tests__/{Flash.features.stories.module.scss → Flash.feature.scss} +0 -0
- /package/build/{Legacy/Typing → Typing}/index.d.js +0 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.buildComponentData = buildComponentData;
|
|
8
|
+
exports.buildPaginationModel = buildPaginationModel;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
+
/* eslint-disable @typescript-eslint/no-inferrable-types */
|
|
13
|
+
function buildPaginationModel(pageCount, currentPage, showPages, marginPageCount, surroundingPageCount) {
|
|
14
|
+
var prev = {
|
|
15
|
+
type: 'PREV',
|
|
16
|
+
num: currentPage - 1,
|
|
17
|
+
disabled: currentPage === 1
|
|
18
|
+
};
|
|
19
|
+
var next = {
|
|
20
|
+
type: 'NEXT',
|
|
21
|
+
num: currentPage + 1,
|
|
22
|
+
disabled: currentPage === pageCount
|
|
23
|
+
};
|
|
24
|
+
if (!showPages) {
|
|
25
|
+
return [prev, next];
|
|
26
|
+
}
|
|
27
|
+
if (pageCount <= 0) {
|
|
28
|
+
return [prev, _objectSpread(_objectSpread({}, next), {}, {
|
|
29
|
+
disabled: true
|
|
30
|
+
})];
|
|
31
|
+
}
|
|
32
|
+
var pages = [];
|
|
33
|
+
|
|
34
|
+
// number of pages shown on each side of the current page
|
|
35
|
+
// [1, ..., 7, 8, _9_, 10, 11, ..., 15]
|
|
36
|
+
// standardGap: 3
|
|
37
|
+
var standardGap = surroundingPageCount + marginPageCount;
|
|
38
|
+
|
|
39
|
+
// the maximum number of pages that can be shown at a given time (account for current page, left and right ellipsis)
|
|
40
|
+
// [1, ..., 7, 8, _9_, 10, 11, ..., 15]
|
|
41
|
+
// maxVisiblePages: 9
|
|
42
|
+
var maxVisiblePages = standardGap + standardGap + 3;
|
|
43
|
+
|
|
44
|
+
// if the number of pages is less than the maximum number of pages that can be shown just return all of them
|
|
45
|
+
if (pageCount <= maxVisiblePages) {
|
|
46
|
+
addPages(1, pageCount, false);
|
|
47
|
+
return [prev].concat(pages, [next]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// startGap is the number of pages hidden by the start ellipsis
|
|
51
|
+
// startOffset is the number of pages to offset at the start to compensate
|
|
52
|
+
// [1, ..., 7, 8, _9_, 10, 11, ..., 15]
|
|
53
|
+
// startGap: 5
|
|
54
|
+
// startOffset: 0
|
|
55
|
+
// when the margin and the surrounding windows overlap.
|
|
56
|
+
// [1, _2_, 3, 4, 5, 6, ..., 15]
|
|
57
|
+
// startGap = 0
|
|
58
|
+
// startOffset: -3 <--
|
|
59
|
+
var startGap = 0;
|
|
60
|
+
var startOffset = 0;
|
|
61
|
+
|
|
62
|
+
// When there is overlap
|
|
63
|
+
if (currentPage - standardGap - 1 <= 1) {
|
|
64
|
+
startOffset = currentPage - standardGap - 2;
|
|
65
|
+
} else {
|
|
66
|
+
startGap = currentPage - standardGap - 1;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// These are equivalent to startGap and startOffset but at the end of the list
|
|
70
|
+
var endGap = 0;
|
|
71
|
+
var endOffset = 0;
|
|
72
|
+
|
|
73
|
+
// When there is overlap
|
|
74
|
+
if (pageCount - currentPage - standardGap <= 1) {
|
|
75
|
+
endOffset = pageCount - currentPage - standardGap - 1;
|
|
76
|
+
} else {
|
|
77
|
+
endGap = pageCount - currentPage - standardGap;
|
|
78
|
+
}
|
|
79
|
+
var hasStartEllipsis = startGap > 0;
|
|
80
|
+
var hasEndEllipsis = endGap > 0;
|
|
81
|
+
|
|
82
|
+
// add pages "before" the start ellipsis (if any)
|
|
83
|
+
// [1, ..., 7, 8, _9_, 10, 11, ..., 15]
|
|
84
|
+
// marginPageCount: 1
|
|
85
|
+
// addPages(1, 1, true)
|
|
86
|
+
addPages(1, marginPageCount, hasStartEllipsis);
|
|
87
|
+
if (hasStartEllipsis) {
|
|
88
|
+
addEllipsis(marginPageCount);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// add middle pages
|
|
92
|
+
// [1, ..., 7, 8, _9_, 10, 11, ..., 15]
|
|
93
|
+
// marginPageCount: 1
|
|
94
|
+
// surroundingPageCount: 2
|
|
95
|
+
// startGap: 5
|
|
96
|
+
// startOffset: 0
|
|
97
|
+
// endGap: 3
|
|
98
|
+
// endOffset: 0
|
|
99
|
+
// addPages(7, 11, true)
|
|
100
|
+
addPages(marginPageCount + startGap + endOffset + 1, pageCount - startOffset - endGap - marginPageCount, hasEndEllipsis);
|
|
101
|
+
if (hasEndEllipsis) {
|
|
102
|
+
addEllipsis(pageCount - startOffset - endGap - marginPageCount);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// add pages "after" the start ellipsis (if any)
|
|
106
|
+
// [1, ..., 7, 8, _9_, 10, 11, ..., 15]
|
|
107
|
+
// marginPageCount: 1
|
|
108
|
+
// surroundingPageCount: 2
|
|
109
|
+
// startGap: 5
|
|
110
|
+
// startOffset: 0
|
|
111
|
+
// endGap: 3
|
|
112
|
+
// endOffset: 0
|
|
113
|
+
// addPages(15, 15)
|
|
114
|
+
addPages(pageCount - marginPageCount + 1, pageCount);
|
|
115
|
+
return [prev].concat(pages, [next]);
|
|
116
|
+
function addEllipsis(previousPage) {
|
|
117
|
+
pages.push({
|
|
118
|
+
type: 'BREAK',
|
|
119
|
+
num: previousPage + 1
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function addPages(start, end) {
|
|
123
|
+
var precedesBreak = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
124
|
+
for (var i = start; i <= end; i++) {
|
|
125
|
+
pages.push({
|
|
126
|
+
type: 'NUM',
|
|
127
|
+
num: i,
|
|
128
|
+
selected: i === currentPage,
|
|
129
|
+
precedesBreak: i === end && precedesBreak
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function buildComponentData(page, hrefBuilder, onClick) {
|
|
135
|
+
var props = {};
|
|
136
|
+
var content = '';
|
|
137
|
+
var key = '';
|
|
138
|
+
switch (page.type) {
|
|
139
|
+
case 'PREV':
|
|
140
|
+
{
|
|
141
|
+
key = 'page-prev';
|
|
142
|
+
content = 'Previous';
|
|
143
|
+
if (page.disabled) {
|
|
144
|
+
Object.assign(props, {
|
|
145
|
+
rel: 'prev',
|
|
146
|
+
'aria-hidden': 'true',
|
|
147
|
+
'aria-disabled': 'true'
|
|
148
|
+
});
|
|
149
|
+
} else {
|
|
150
|
+
Object.assign(props, {
|
|
151
|
+
rel: 'prev',
|
|
152
|
+
href: hrefBuilder(page.num),
|
|
153
|
+
'aria-label': 'Previous Page',
|
|
154
|
+
'data-testid': 'page-prev',
|
|
155
|
+
onClick: onClick
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
case 'NEXT':
|
|
161
|
+
{
|
|
162
|
+
key = 'page-next';
|
|
163
|
+
content = 'Next';
|
|
164
|
+
if (page.disabled) {
|
|
165
|
+
Object.assign(props, {
|
|
166
|
+
rel: 'next',
|
|
167
|
+
'aria-hidden': 'true',
|
|
168
|
+
'aria-disabled': 'true'
|
|
169
|
+
});
|
|
170
|
+
} else {
|
|
171
|
+
Object.assign(props, {
|
|
172
|
+
rel: 'next',
|
|
173
|
+
href: hrefBuilder(page.num),
|
|
174
|
+
'aria-label': 'Next Page',
|
|
175
|
+
'data-testid': 'page-next',
|
|
176
|
+
onClick: onClick
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case 'NUM':
|
|
182
|
+
{
|
|
183
|
+
key = "page-".concat(page.num);
|
|
184
|
+
content = String(page.num);
|
|
185
|
+
Object.assign(props, {
|
|
186
|
+
href: hrefBuilder(page.num),
|
|
187
|
+
// We append "..." to the aria-label for pages that preceed a break because screen readers will
|
|
188
|
+
// change the tone the text is read in.
|
|
189
|
+
// This is a slightly nicer experience than skipping a bunch of numbers unexpectedly.
|
|
190
|
+
'aria-label': "Page ".concat(page.num).concat(page.precedesBreak ? '...' : ''),
|
|
191
|
+
'aria-current': page.selected ? 'page' : undefined,
|
|
192
|
+
onClick: onClick
|
|
193
|
+
});
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
case 'BREAK':
|
|
197
|
+
{
|
|
198
|
+
key = "page-".concat(page.num, "-break");
|
|
199
|
+
content = '…';
|
|
200
|
+
Object.assign(props, {
|
|
201
|
+
as: 'span',
|
|
202
|
+
role: 'presentation'
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
props: props,
|
|
208
|
+
key: key,
|
|
209
|
+
content: content
|
|
210
|
+
};
|
|
211
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/* stylelint-disable custom-property-pattern, selector-not-notation, no-descending-specificity */
|
|
2
|
+
.Page {
|
|
3
|
+
min-width: 32px; /* primer.control.medium.size */
|
|
4
|
+
height: 32px; /* primer.control.medium.size */
|
|
5
|
+
padding: var(--base-size-8) calc((var(--base-size-32) - var(--base-size-20)) / 2); /* primer.control.medium.paddingInline.condensed primer.control.medium.paddingBlock */
|
|
6
|
+
margin-right: var(--base-size-4);
|
|
7
|
+
font-style: normal;
|
|
8
|
+
/* stylelint-disable-next-line primer/typography */
|
|
9
|
+
line-height: 1;
|
|
10
|
+
color: var(--fgColor-default);
|
|
11
|
+
text-align: center;
|
|
12
|
+
text-decoration: none;
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
vertical-align: middle;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
user-select: none;
|
|
17
|
+
background-color: transparent;
|
|
18
|
+
border-radius: var(--borderRadius-medium);
|
|
19
|
+
transition: background-color 0.2s cubic-bezier(0.3, 0, 0.5, 1);
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.Page[rel='prev'] > svg,
|
|
26
|
+
.Page[rel='next'] > svg {
|
|
27
|
+
/* sizing with `em` so icons scale with inherited font-size */
|
|
28
|
+
height: 1em;
|
|
29
|
+
width: 1em;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.Page[rel='prev'] > svg {
|
|
33
|
+
margin-inline-end: var(--base-size-4);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.Page[rel='next'] > svg {
|
|
37
|
+
margin-inline-start: var(--base-size-4);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.Page:last-child {
|
|
41
|
+
margin-right: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.Page:hover,
|
|
45
|
+
.Page:focus {
|
|
46
|
+
text-decoration: none;
|
|
47
|
+
background-color: var(--control-transparent-bgColor-hover);
|
|
48
|
+
outline: 0;
|
|
49
|
+
transition-duration: 0.1s;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.Page:focus-visible {
|
|
53
|
+
outline: 2px solid var(--bgColor-accent-emphasis);
|
|
54
|
+
outline-offset: -2px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.Page:active {
|
|
58
|
+
border-color: var(--borderColor-muted);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.Page[rel='prev'],
|
|
62
|
+
.Page[rel='next'] {
|
|
63
|
+
color: var(--fgColor-accent);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.Page[aria-current],
|
|
67
|
+
.Page[aria-current]:hover {
|
|
68
|
+
color: var(--fgColor-onEmphasis);
|
|
69
|
+
background-color: var(--bgColor-accent-emphasis);
|
|
70
|
+
border-color: transparent;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.Page[aria-current]:focus-visible {
|
|
74
|
+
outline: 2px solid var(--bgColor-accent-emphasis);
|
|
75
|
+
outline-offset: -2px;
|
|
76
|
+
/* stylelint-disable-next-line primer/box-shadow */
|
|
77
|
+
box-shadow: inset 0 0 0 3px var(--fgColor-onEmphasis);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.Page[aria-hidden],
|
|
81
|
+
.Page[aria-hidden]:hover,
|
|
82
|
+
.Page[role='presentation'],
|
|
83
|
+
.Page[role='presentation']:hover {
|
|
84
|
+
color: var(--fgColor-disabled);
|
|
85
|
+
cursor: default;
|
|
86
|
+
background-color: transparent;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.PaginationContainer {
|
|
90
|
+
/* stylelint-disable-next-line primer/spacing */
|
|
91
|
+
margin-top: 20px;
|
|
92
|
+
/* stylelint-disable-next-line primer/spacing */
|
|
93
|
+
margin-bottom: 15px;
|
|
94
|
+
text-align: center;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.TablePaginationSteps {
|
|
98
|
+
display: inline-block;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@media screen and (--viewportRange-narrow) {
|
|
102
|
+
.TablePaginationSteps[data-hidden-viewport-ranges*='narrow'] > *:not(:first-child):not(:last-child) {
|
|
103
|
+
display: none;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.TablePaginationSteps[data-hidden-viewport-ranges*='narrow'] > *:first-child {
|
|
107
|
+
margin-inline-end: 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.TablePaginationSteps[data-hidden-viewport-ranges*='narrow'] > *:last-child {
|
|
111
|
+
margin-inline-start: 0;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@media screen and (--viewportRange-regular) {
|
|
116
|
+
.TablePaginationSteps[data-hidden-viewport-ranges*='regular'] > *:not(:first-child):not(:last-child) {
|
|
117
|
+
display: none;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.TablePaginationSteps[data-hidden-viewport-ranges*='regular'] > *:first-child {
|
|
121
|
+
margin-inline-end: 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.TablePaginationSteps[data-hidden-viewport-ranges*='regular'] > *:last-child {
|
|
125
|
+
margin-inline-start: 0;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@media screen and (--viewportRange-wide) {
|
|
130
|
+
.TablePaginationSteps[data-hidden-viewport-ranges*='wide'] > *:not(:first-child):not(:last-child) {
|
|
131
|
+
display: none;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.TablePaginationSteps[data-hidden-viewport-ranges*='wide'] > *:first-child {
|
|
135
|
+
margin-inline-end: 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.TablePaginationSteps[data-hidden-viewport-ranges*='wide'] > *:last-child {
|
|
139
|
+
margin-inline-start: 0;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Modern/Pagination/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Pagination", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _Pagination.Pagination;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _Pagination = require("./Pagination");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Modern/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAEzE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "useMedia", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _useMedia.useMedia;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "useRefObjectAsForwardedRef", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _useRefObjectAsForwardedRef.useRefObjectAsForwardedRef;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _useRefObjectAsForwardedRef = require("./useRefObjectAsForwardedRef");
|
|
19
|
+
var _useMedia = require("./useMedia");
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* `useMedia` will use the given `mediaQueryString` with `matchMedia` to
|
|
4
|
+
* determine if the document matches the media query string.
|
|
5
|
+
*
|
|
6
|
+
* If `MatchMedia` is used as an ancestor, `useMedia` will instead use the
|
|
7
|
+
* value of the media query string, if available
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* function Example() {
|
|
11
|
+
* const coarsePointer = useMedia('(pointer: coarse)');
|
|
12
|
+
* // ...
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export declare function useMedia(mediaQueryString: string, defaultState?: boolean): boolean;
|
|
16
|
+
type MediaQueryFeatures = Record<string, boolean | undefined>;
|
|
17
|
+
interface MatchMediaProps {
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
features?: MediaQueryFeatures;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Use `MatchMedia` to emulate media conditions by passing in feature
|
|
23
|
+
* queries to the `features` prop. If a component uses `useMedia` with the
|
|
24
|
+
* feature passed in to `MatchMedia` it will force its value to match what is
|
|
25
|
+
* provided to `MatchMedia`
|
|
26
|
+
*
|
|
27
|
+
* This should be used for development and documentation only in situations
|
|
28
|
+
* where devtools cannot emulate this feature
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* <MatchMedia features={{ "(pointer: coarse)": true}}>
|
|
32
|
+
* <Children />
|
|
33
|
+
* </MatchMedia>
|
|
34
|
+
*/
|
|
35
|
+
export declare function MatchMedia({ children, features }: MatchMediaProps): import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=useMedia.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMedia.d.ts","sourceRoot":"","sources":["../../../src/Modern/hooks/useMedia.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyD,MAAM,OAAO,CAAA;AAI7E;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,WAgExE;AAED,KAAK,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC,CAAA;AAO7D,UAAU,eAAe;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,QAAQ,CAAC,EAAE,kBAAkB,CAAA;CAC9B;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,QAA0B,EAAE,EAAE,eAAe,2CAGnF"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.MatchMedia = MatchMedia;
|
|
9
|
+
exports.useMedia = useMedia;
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _environment = require("../utils/environment");
|
|
13
|
+
var _warning = require("../utils/warning");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
+
/**
|
|
17
|
+
* `useMedia` will use the given `mediaQueryString` with `matchMedia` to
|
|
18
|
+
* determine if the document matches the media query string.
|
|
19
|
+
*
|
|
20
|
+
* If `MatchMedia` is used as an ancestor, `useMedia` will instead use the
|
|
21
|
+
* value of the media query string, if available
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* function Example() {
|
|
25
|
+
* const coarsePointer = useMedia('(pointer: coarse)');
|
|
26
|
+
* // ...
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
29
|
+
function useMedia(mediaQueryString, defaultState) {
|
|
30
|
+
var features = (0, _react.useContext)(MatchMediaContext);
|
|
31
|
+
var _useState = (0, _react.useState)(function () {
|
|
32
|
+
if (features[mediaQueryString] !== undefined) {
|
|
33
|
+
return features[mediaQueryString];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Prevent a React hydration mismatch when a default value is provided by not defaulting to window.matchMedia(query).matches.
|
|
37
|
+
if (defaultState !== undefined) {
|
|
38
|
+
return defaultState;
|
|
39
|
+
}
|
|
40
|
+
if (_environment.canUseDOM) {
|
|
41
|
+
return window.matchMedia(mediaQueryString).matches;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// A default value has not been provided, and you are rendering on the server, warn of a possible hydration mismatch when defaulting to false.
|
|
45
|
+
(0, _warning.warning)(true, '`useMedia` When server side rendering, defaultState should be defined to prevent a hydration mismatches.');
|
|
46
|
+
return false;
|
|
47
|
+
}),
|
|
48
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
49
|
+
matches = _useState2[0],
|
|
50
|
+
setMatches = _useState2[1];
|
|
51
|
+
if (features[mediaQueryString] !== undefined && matches !== features[mediaQueryString]) {
|
|
52
|
+
setMatches(features[mediaQueryString]);
|
|
53
|
+
}
|
|
54
|
+
(0, _react.useEffect)(function () {
|
|
55
|
+
// If `mediaQueryString` is present in features through `context` defer to
|
|
56
|
+
// the value present instead of checking with matchMedia
|
|
57
|
+
if (features[mediaQueryString] !== undefined) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
function listener(event) {
|
|
61
|
+
setMatches(event.matches);
|
|
62
|
+
}
|
|
63
|
+
var mediaQueryList = window.matchMedia(mediaQueryString);
|
|
64
|
+
|
|
65
|
+
// Support fallback to `addListener` for broader browser support
|
|
66
|
+
// @ts-ignore this is not present in Safari <14
|
|
67
|
+
|
|
68
|
+
if (mediaQueryList.addEventListener) {
|
|
69
|
+
mediaQueryList.addEventListener('change', listener);
|
|
70
|
+
} else {
|
|
71
|
+
mediaQueryList.addListener(listener);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Make sure the media query list is in sync with the matches state
|
|
75
|
+
|
|
76
|
+
setMatches(mediaQueryList.matches);
|
|
77
|
+
return function () {
|
|
78
|
+
// @ts-ignore this is not present in Safari <14
|
|
79
|
+
|
|
80
|
+
if (mediaQueryList.addEventListener) {
|
|
81
|
+
mediaQueryList.removeEventListener('change', listener);
|
|
82
|
+
} else {
|
|
83
|
+
mediaQueryList.removeListener(listener);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}, [features, mediaQueryString]);
|
|
87
|
+
return matches;
|
|
88
|
+
}
|
|
89
|
+
// Used to keep track of overrides to specific media query features, this should
|
|
90
|
+
// be used for development and demo purposes to emulate specific features if
|
|
91
|
+
// unavailable through devtools
|
|
92
|
+
var MatchMediaContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
93
|
+
var defaultFeatures = {};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Use `MatchMedia` to emulate media conditions by passing in feature
|
|
97
|
+
* queries to the `features` prop. If a component uses `useMedia` with the
|
|
98
|
+
* feature passed in to `MatchMedia` it will force its value to match what is
|
|
99
|
+
* provided to `MatchMedia`
|
|
100
|
+
*
|
|
101
|
+
* This should be used for development and documentation only in situations
|
|
102
|
+
* where devtools cannot emulate this feature
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* <MatchMedia features={{ "(pointer: coarse)": true}}>
|
|
106
|
+
* <Children />
|
|
107
|
+
* </MatchMedia>
|
|
108
|
+
*/
|
|
109
|
+
function MatchMedia(_ref) {
|
|
110
|
+
var children = _ref.children,
|
|
111
|
+
_ref$features = _ref.features,
|
|
112
|
+
features = _ref$features === void 0 ? defaultFeatures : _ref$features;
|
|
113
|
+
var value = useShallowObject(features);
|
|
114
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(MatchMediaContext.Provider, {
|
|
115
|
+
value: value,
|
|
116
|
+
children: children
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Utility hook to provide a stable identity for a "simple" object which
|
|
121
|
+
* contains only primitive values. This provides a `useMemo`-esque signature
|
|
122
|
+
* without dealing with shallow equality checks in the dependency array.
|
|
123
|
+
*
|
|
124
|
+
* Note (perf): this hook iterates through keys and values of the object if the
|
|
125
|
+
* shallow equality check is false each time the hook is called
|
|
126
|
+
*/
|
|
127
|
+
function useShallowObject(object) {
|
|
128
|
+
var _useState3 = (0, _react.useState)(object),
|
|
129
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
130
|
+
value = _useState4[0],
|
|
131
|
+
setValue = _useState4[1];
|
|
132
|
+
if (value !== object) {
|
|
133
|
+
var match = Object.keys(object).every(function (key) {
|
|
134
|
+
return object[key] === value[key];
|
|
135
|
+
});
|
|
136
|
+
if (!match) {
|
|
137
|
+
setValue(object);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ForwardedRef, RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Use a ref object as the imperative handle for a forwarded ref. This can be used to
|
|
4
|
+
* synchronize the ref object with the forwarded ref and allow local access the reference
|
|
5
|
+
* instance with `.current`.
|
|
6
|
+
*
|
|
7
|
+
* **NOTE**: The `refObject` should be passed to the underlying element, NOT the `forwardedRef`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useRefObjectAsForwardedRef<T>(forwardedRef: ForwardedRef<T>, refObject: RefObject<T | null>): void;
|
|
10
|
+
//# sourceMappingURL=useRefObjectAsForwardedRef.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRefObjectAsForwardedRef.d.ts","sourceRoot":"","sources":["../../../src/Modern/hooks/useRefObjectAsForwardedRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGpD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAEjH"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "useRefObjectAsForwardedRef",
|
|
3
|
+
"importPath": "@primer/react",
|
|
4
|
+
"stories": [],
|
|
5
|
+
"parameters": [
|
|
6
|
+
{
|
|
7
|
+
"name": "forwardedRef",
|
|
8
|
+
"type": "ForwardedRef<T>",
|
|
9
|
+
"required": true,
|
|
10
|
+
"description": "The forwarded ref to synchronize with the ref object."
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "refObject",
|
|
14
|
+
"type": "RefObject<T>",
|
|
15
|
+
"required": true,
|
|
16
|
+
"description": "The ref object to use as the imperative handle."
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"returns": {
|
|
20
|
+
"type": "void"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useRefObjectAsForwardedRef = useRefObjectAsForwardedRef;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/**
|
|
9
|
+
* Use a ref object as the imperative handle for a forwarded ref. This can be used to
|
|
10
|
+
* synchronize the ref object with the forwarded ref and allow local access the reference
|
|
11
|
+
* instance with `.current`.
|
|
12
|
+
*
|
|
13
|
+
* **NOTE**: The `refObject` should be passed to the underlying element, NOT the `forwardedRef`.
|
|
14
|
+
*/
|
|
15
|
+
function useRefObjectAsForwardedRef(forwardedRef, refObject) {
|
|
16
|
+
(0, _react.useImperativeHandle)(forwardedRef, function () {
|
|
17
|
+
return refObject.current;
|
|
18
|
+
});
|
|
19
|
+
}
|