@papillonarts/components 0.35.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/Blankslate/__tests__/Blankslate.doc.md +57 -0
- package/build/Legacy/Breadcrumb/__tests__/Breadcrumb.doc.md +33 -0
- package/build/Legacy/Markdown/__tests__/Markdown.doc.md +3 -3
- package/build/Legacy/SyntaxHighlighter/__tests__/SyntaxHighlighter.doc.md +3 -3
- 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 +0 -1
- 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/Modern/Typing/index.d.js +0 -1
- package/build/Modern/global.d.js +0 -1
- /package/build/{Legacy/Typing → Typing}/index.d.js +0 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const viewportRanges: {
|
|
2
|
+
narrow: string;
|
|
3
|
+
regular: string;
|
|
4
|
+
wide: string;
|
|
5
|
+
};
|
|
6
|
+
export interface ResponsiveValue<TRegular, TNarrow = TRegular, TWide = TRegular> {
|
|
7
|
+
narrow?: TNarrow;
|
|
8
|
+
regular?: TRegular;
|
|
9
|
+
wide?: TWide;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Flattens all possible value types into single union type
|
|
13
|
+
* For example, if `T` is `'none' | 'line' | Responsive<'none' | 'line' | 'filled'>`,
|
|
14
|
+
* `FlattenResponsiveValue<T>` will be `'none' | 'line' | 'filled'`
|
|
15
|
+
*/
|
|
16
|
+
export type FlattenResponsiveValue<T> = (T extends ResponsiveValue<infer TRegular, infer TNarrow, infer TWide> ? TRegular | TNarrow | TWide : never) | Exclude<T, ResponsiveValue<any>>;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if the value is a responsive value.
|
|
19
|
+
* In other words, is it an object with viewport range keys?
|
|
20
|
+
*/
|
|
21
|
+
export declare function isResponsiveValue(value: any): value is ResponsiveValue<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Resolves responsive values based on the current viewport width.
|
|
24
|
+
* For example, if the current viewport width is narrow (less than 768px), the value of `{regular: 'foo', narrow: 'bar'}` will resolve to `'bar'`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const value = useResponsiveValue({regular: 'foo', narrow: 'bar'})
|
|
28
|
+
* console.log(value) // 'bar'
|
|
29
|
+
*/
|
|
30
|
+
export declare function useResponsiveValue<T, F>(value: T, fallback: F): FlattenResponsiveValue<T> | F;
|
|
31
|
+
//# sourceMappingURL=useResponsiveValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResponsiveValue.d.ts","sourceRoot":"","sources":["../../../src/Modern/hooks/useResponsiveValue.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,cAAc;;;;CAI1B,CAAA;AAED,MAAM,WAAW,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,EAAE,KAAK,GAAG,QAAQ;IAC7E,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,QAAQ,CAAA;IAClB,IAAI,CAAC,EAAE,KAAK,CAAA;CACb;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAChC,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,QAAQ,EAAE,MAAM,OAAO,EAAE,MAAM,KAAK,CAAC,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,CAAC,GAC5G,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAA;AAEpC;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,eAAe,CAAC,GAAG,CAAC,CAE3E;AAED;;;;;;;GAOG;AAEH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,GAAG,CAAC,CAuB7F"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.isResponsiveValue = isResponsiveValue;
|
|
8
|
+
exports.useResponsiveValue = useResponsiveValue;
|
|
9
|
+
exports.viewportRanges = void 0;
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
var _useMedia = require("./useMedia");
|
|
12
|
+
// This file contains utilities for working with responsive values.
|
|
13
|
+
|
|
14
|
+
// The viewport range values from @primer/primtives don't work in Chrome
|
|
15
|
+
// because they use `em` units inside `calc()` (e.g., calc(48em - 0.02px)).
|
|
16
|
+
// As a temporary workaround, we're hardcoding the viewport ranges in `px` units.
|
|
17
|
+
// TODO: Use viewport range tokens from @primer/primitives
|
|
18
|
+
var viewportRanges = exports.viewportRanges = {
|
|
19
|
+
narrow: '(max-width: calc(768px - 0.02px))',
|
|
20
|
+
// < 768px
|
|
21
|
+
regular: '(min-width: 768px)',
|
|
22
|
+
// >= 768px
|
|
23
|
+
wide: '(min-width: 1400px)' // >= 1400px
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Flattens all possible value types into single union type
|
|
28
|
+
* For example, if `T` is `'none' | 'line' | Responsive<'none' | 'line' | 'filled'>`,
|
|
29
|
+
* `FlattenResponsiveValue<T>` will be `'none' | 'line' | 'filled'`
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Checks if the value is a responsive value.
|
|
34
|
+
* In other words, is it an object with viewport range keys?
|
|
35
|
+
*/
|
|
36
|
+
function isResponsiveValue(value) {
|
|
37
|
+
return (0, _typeof2["default"])(value) === 'object' && Object.keys(value).some(function (key) {
|
|
38
|
+
return ['narrow', 'regular', 'wide'].includes(key);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Resolves responsive values based on the current viewport width.
|
|
44
|
+
* For example, if the current viewport width is narrow (less than 768px), the value of `{regular: 'foo', narrow: 'bar'}` will resolve to `'bar'`.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const value = useResponsiveValue({regular: 'foo', narrow: 'bar'})
|
|
48
|
+
* console.log(value) // 'bar'
|
|
49
|
+
*/
|
|
50
|
+
// TODO: Improve SSR support
|
|
51
|
+
function useResponsiveValue(value, fallback) {
|
|
52
|
+
// Check viewport size
|
|
53
|
+
// TODO: What is the performance cost of creating media query listeners in this hook?
|
|
54
|
+
var isNarrowViewport = (0, _useMedia.useMedia)(viewportRanges.narrow, false);
|
|
55
|
+
var isRegularViewport = (0, _useMedia.useMedia)(viewportRanges.regular, false);
|
|
56
|
+
var isWideViewport = (0, _useMedia.useMedia)(viewportRanges.wide, false);
|
|
57
|
+
if (isResponsiveValue(value)) {
|
|
58
|
+
// If we've reached this line, we know that value is a responsive value
|
|
59
|
+
var responsiveValue = value;
|
|
60
|
+
if (isNarrowViewport && 'narrow' in Object(responsiveValue)) {
|
|
61
|
+
return Object(responsiveValue).narrow;
|
|
62
|
+
} else if (isWideViewport && 'wide' in Object(responsiveValue)) {
|
|
63
|
+
return Object(responsiveValue).wide;
|
|
64
|
+
} else if (isRegularViewport && 'regular' in Object(responsiveValue)) {
|
|
65
|
+
return Object(responsiveValue).regular;
|
|
66
|
+
} else {
|
|
67
|
+
return fallback;
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
// If we've reached this line, we know that value is not a responsive value
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
}
|
package/build/Modern/index.d.ts
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
|
+
import '@papillonarts/css/build/primer/index.scss';
|
|
2
|
+
import { Pagination } from './Pagination';
|
|
1
3
|
export type { FlashProps } from './Flash';
|
|
4
|
+
export type { LinkProps } from './Link';
|
|
5
|
+
export type { PaginationProps } from './Pagination';
|
|
2
6
|
export declare const Modern: {
|
|
3
7
|
Flash: {
|
|
4
8
|
Flash: import("./utils/polymorphic").ForwardRefComponent<"div", import("./Flash").FlashProps>;
|
|
5
9
|
};
|
|
10
|
+
Link: {
|
|
11
|
+
Link: (<As extends import("react").ElementType = "a">(props: (import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & {
|
|
12
|
+
as?: "a";
|
|
13
|
+
hoverColor?: string;
|
|
14
|
+
muted?: boolean;
|
|
15
|
+
inline?: boolean;
|
|
16
|
+
} extends infer T ? T extends import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & {
|
|
17
|
+
as?: "a";
|
|
18
|
+
hoverColor?: string;
|
|
19
|
+
muted?: boolean;
|
|
20
|
+
inline?: boolean;
|
|
21
|
+
} ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
|
|
22
|
+
as?: As;
|
|
23
|
+
} & import("react").RefAttributes<unknown>) => React.ReactNode) & {
|
|
24
|
+
displayName: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
Pagination: {
|
|
28
|
+
Pagination: typeof Pagination;
|
|
29
|
+
};
|
|
6
30
|
};
|
|
7
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Modern/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Modern/index.ts"],"names":[],"mappings":"AAAA,OAAO,2CAA2C,CAAA;AAGlD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACvC,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;CAUlB,CAAA"}
|
package/build/Modern/index.js
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.Modern = void 0;
|
|
8
|
-
|
|
7
|
+
require("@papillonarts/css/build/primer/index.scss");
|
|
8
|
+
var _Flash = require("./Flash");
|
|
9
|
+
var _Link = require("./Link");
|
|
10
|
+
var _Pagination = require("./Pagination");
|
|
9
11
|
var Modern = exports.Modern = {
|
|
10
12
|
Flash: {
|
|
11
|
-
Flash: _Flash
|
|
13
|
+
Flash: _Flash.Flash
|
|
14
|
+
},
|
|
15
|
+
Link: {
|
|
16
|
+
Link: _Link.Link
|
|
17
|
+
},
|
|
18
|
+
Pagination: {
|
|
19
|
+
Pagination: _Pagination.Pagination
|
|
12
20
|
}
|
|
13
21
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/Modern/type.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACvC,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indicate whether current execution environment can access the DOM.
|
|
3
|
+
*
|
|
4
|
+
* @see https://github.com/facebook/fbjs/blob/4d1751311d3f67af2dcce2e40df8512a23c7b9c6/packages/fbjs/src/core/ExecutionEnvironment.js#L12
|
|
5
|
+
*/
|
|
6
|
+
export const canUseDOM: false | {
|
|
7
|
+
<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K];
|
|
8
|
+
<K extends keyof HTMLElementDeprecatedTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementDeprecatedTagNameMap[K];
|
|
9
|
+
(tagName: string, options?: ElementCreationOptions): HTMLElement;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../src/Modern/utils/environment.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;EAAiE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.canUseDOM = void 0;
|
|
7
|
+
var _window$document$crea, _window;
|
|
8
|
+
/**
|
|
9
|
+
* Indicate whether current execution environment can access the DOM.
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/facebook/fbjs/blob/4d1751311d3f67af2dcce2e40df8512a23c7b9c6/packages/fbjs/src/core/ExecutionEnvironment.js#L12
|
|
12
|
+
*/
|
|
13
|
+
var canUseDOM = exports.canUseDOM = (_window$document$crea = (_window = window) === null || _window === void 0 || (_window = _window.document) === null || _window === void 0 ? void 0 : _window.createElement) !== null && _window$document$crea !== void 0 ? _window$document$crea : false;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, ElementType } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Distributive Omit utility type that works correctly with union types
|
|
4
|
+
*/
|
|
5
|
+
type DistributiveOmit<T, TOmitted extends PropertyKey> = T extends unknown ? Omit<T, TOmitted> : never;
|
|
6
|
+
/**
|
|
7
|
+
* Fixed version of forwardRef that provides better type inference for polymorphic components
|
|
8
|
+
*/
|
|
9
|
+
type FixedForwardRef = <T, P = object>(render: (props: P, ref: React.Ref<T>) => React.ReactNode) => (props: P & React.RefAttributes<T>) => React.ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Cast forwardRef to the fixed version with better type inference
|
|
12
|
+
*/
|
|
13
|
+
export declare const fixedForwardRef: FixedForwardRef;
|
|
14
|
+
/**
|
|
15
|
+
* Simplified polymorphic props type that handles the common pattern of
|
|
16
|
+
* `DistributiveOmit<ComponentPropsWithRef<ElementType extends As ? DefaultElement : As>, 'as'>`
|
|
17
|
+
*/
|
|
18
|
+
export type PolymorphicProps<TAs extends ElementType, TDefaultElement extends ElementType = 'div', Props = object> = DistributiveOmit<ComponentPropsWithRef<ElementType extends TAs ? TDefaultElement : TAs> & Props, 'as'> & {
|
|
19
|
+
as?: TAs;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=modern-polymorphic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modern-polymorphic.d.ts","sourceRoot":"","sources":["../../../src/Modern/utils/modern-polymorphic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAE/D;;GAEG;AACH,KAAK,gBAAgB,CAAC,CAAC,EAAE,QAAQ,SAAS,WAAW,IAAI,CAAC,SAAS,OAAO,GAAG,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAA;AAEtG;;GAEG;AAGH,KAAK,eAAe,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,EACnC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,SAAS,KACrD,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,SAAS,CAAA;AAE3D;;GAEG;AACH,eAAO,MAAM,eAAe,EAAiB,eAAe,CAAA;AAE5D;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,GAAG,SAAS,WAAW,EAAE,eAAe,SAAS,WAAW,GAAG,KAAK,EAAE,KAAK,GAAG,MAAM,IAAI,gBAAgB,CACnI,qBAAqB,CAAC,WAAW,SAAS,GAAG,GAAG,eAAe,GAAG,GAAG,CAAC,GAAG,KAAK,EAC9E,IAAI,CACL,GAAG;IACF,EAAE,CAAC,EAAE,GAAG,CAAA;CACT,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fixedForwardRef = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
// Mostly taken from https://github.com/total-typescript/react-typescript-tutorial/blob/main/src/08-advanced-patterns/72-as-prop-with-forward-ref.solution.tsx
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Distributive Omit utility type that works correctly with union types
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Fixed version of forwardRef that provides better type inference for polymorphic components
|
|
16
|
+
*/
|
|
17
|
+
// TODO: figure out how to change this type so we can set displayName
|
|
18
|
+
// like this: `ComponentName.displayName = 'DisplayName' instead of using workarounds
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Cast forwardRef to the fixed version with better type inference
|
|
22
|
+
*/
|
|
23
|
+
var fixedForwardRef = exports.fixedForwardRef = _react.forwardRef;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Simplified polymorphic props type that handles the common pattern of
|
|
27
|
+
* `DistributiveOmit<ComponentPropsWithRef<ElementType extends As ? DefaultElement : As>, 'as'>`
|
|
28
|
+
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract a component's props
|
|
3
|
+
*
|
|
4
|
+
* Source: https://react-typescript-cheatsheet.netlify.app/docs/advanced/patterns_by_usecase#wrappingmirroring-a-component
|
|
5
|
+
*
|
|
6
|
+
* @example ComponentProps<typeof MyComponent>
|
|
7
|
+
*/
|
|
8
|
+
export type ComponentProps<T> = T extends React.ComponentType<React.PropsWithChildren<infer Props>> ? (Props extends object ? Props : never) : never;
|
|
9
|
+
//# sourceMappingURL=ComponentProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentProps.d.ts","sourceRoot":"","sources":["../../../../src/Modern/utils/types/ComponentProps.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAC1B,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,iBAAiB,CAAC,MAAM,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,SAAS,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC,GAAG,KAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Modern/utils/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _ComponentProps = require("./ComponentProps");
|
|
7
|
+
Object.keys(_ComponentProps).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _ComponentProps[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _ComponentProps[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _Slots = require("./Slots");
|
|
18
|
+
Object.keys(_Slots).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _Slots[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return _Slots[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warning.d.ts","sourceRoot":"","sources":["../../../src/Modern/utils/warning.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,IAAI,YAEmB,MAAM,SAGhB,CAAA;AAInB,QAAA,MAAM,OAAO,cAEqB,GAAG,UAAU,MAAM,WAAW,GAAG,EAAE,SASlD,CAAA;AAEnB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.warning = exports.warn = void 0;
|
|
7
|
+
function emptyFunction() {}
|
|
8
|
+
var warn = exports.warn = process.env.NODE_ENV !== 'production' ? function warn(message) {
|
|
9
|
+
console.warn('Warning:', message);
|
|
10
|
+
} : emptyFunction;
|
|
11
|
+
|
|
12
|
+
// Inspired by warning by fbjs
|
|
13
|
+
// @see https://github.com/facebook/fbjs/blob/main/packages/fbjs/src/__forks__/warning.js
|
|
14
|
+
var warning = exports.warning = process.env.NODE_ENV !== 'production' ? function warning(condition, format) {
|
|
15
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
16
|
+
args[_key - 2] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
if (condition) {
|
|
19
|
+
var index = 0;
|
|
20
|
+
var message = format.replace(/%s/g, function () {
|
|
21
|
+
return args[index++];
|
|
22
|
+
});
|
|
23
|
+
warn(message);
|
|
24
|
+
}
|
|
25
|
+
} : emptyFunction;
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@papillonarts/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "Papillon Arts Components",
|
|
5
5
|
"homepage": "https://github.com/papillonarts/papillonarts/tree/master/packages/components",
|
|
6
6
|
"repository": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"build-release": "npm run build"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@papillonarts/css": "^0.
|
|
30
|
-
"@papillonarts/library": "^0.
|
|
29
|
+
"@papillonarts/css": "^0.36.0",
|
|
30
|
+
"@papillonarts/library": "^0.36.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "8ef38bffed97c329ca6a1f5bacaa938528d256cc"
|
|
33
33
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/build/Modern/global.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
File without changes
|