@spscommerce/ds-react 5.25.0 → 5.26.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/lib/utils/Provide.d.ts +24 -0
- package/lib/utils/bindProps.d.ts +33 -0
- package/package.json +11 -11
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* This is the use case for Nested: wrapping JSX in a flat list of
|
|
4
|
+
* multiple React context providers instead of creating a pyramid of doom.
|
|
5
|
+
*
|
|
6
|
+
* bindProps (see bindProps.tsx in this same directory) was
|
|
7
|
+
* created to be used with this, so you can set props on the
|
|
8
|
+
* providers, including and especially `value` on the built-in
|
|
9
|
+
* context object's `.Provider` component.
|
|
10
|
+
*
|
|
11
|
+
* <Provide providers={[
|
|
12
|
+
* ProplessProviderFromALibrary,
|
|
13
|
+
* bindProps(MyReallyUsefulContext.Provider, { value: "foo" }),
|
|
14
|
+
* // ...etc
|
|
15
|
+
* ]}>
|
|
16
|
+
* (component tree that will have access to context from these providers)
|
|
17
|
+
* </Provide>
|
|
18
|
+
*/
|
|
19
|
+
declare type ProvideProps = React.HTMLProps<HTMLDivElement> & {
|
|
20
|
+
providers?: React.ElementType[];
|
|
21
|
+
};
|
|
22
|
+
export declare const Provide: React.FC<ProvideProps>;
|
|
23
|
+
export declare const SpsApp: React.FC<ProvideProps>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* takes in an ElementType (e.g. a React component) and
|
|
4
|
+
* returns a new version of that component where certain
|
|
5
|
+
* props are ALWAYS set to predefined values regardless of
|
|
6
|
+
* what is passed in.
|
|
7
|
+
*
|
|
8
|
+
* for example, consider the following component:
|
|
9
|
+
* const Foo: React.FC<{
|
|
10
|
+
* a: string;
|
|
11
|
+
* b: string;
|
|
12
|
+
* }> = function ({ a, b }) {
|
|
13
|
+
* return (
|
|
14
|
+
* <span>
|
|
15
|
+
* a is {a} and b is {b}
|
|
16
|
+
* </span>
|
|
17
|
+
* );
|
|
18
|
+
* };
|
|
19
|
+
*
|
|
20
|
+
* <Foo a="dog" b="cat"/> would produce <span>a is dog and b is cat</span>
|
|
21
|
+
*
|
|
22
|
+
* But if you bind the prop a...
|
|
23
|
+
* const FooWithBoundA = bindProps(Foo, { a: "parakeet" });
|
|
24
|
+
*
|
|
25
|
+
* then <FooWithBoundA a="dog" b="cat"/> will produce <span>a is parakeet and b is cat</span>
|
|
26
|
+
*
|
|
27
|
+
* The type of the props is the same, but prop a is always going to be overridden to its
|
|
28
|
+
* bound value.
|
|
29
|
+
*
|
|
30
|
+
* This was created to be used with <Provide> (see Provide.tsx in this same directory),
|
|
31
|
+
* but may have other use cases.
|
|
32
|
+
*/
|
|
33
|
+
export declare function bindProps<T extends React.ElementType>(E: T, boundProps: Partial<React.ComponentProps<T>>, deps?: unknown[]): React.FC<React.ComponentProps<T>>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spscommerce/ds-react",
|
|
3
3
|
"description": "SPS Design System React components",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.26.0",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/ds-react",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@react-stately/collections": "^3.3.3",
|
|
31
|
-
"@spscommerce/ds-colors": "5.
|
|
32
|
-
"@spscommerce/ds-illustrations": "5.
|
|
33
|
-
"@spscommerce/ds-shared": "5.
|
|
34
|
-
"@spscommerce/positioning": "5.
|
|
35
|
-
"@spscommerce/utils": "5.
|
|
31
|
+
"@spscommerce/ds-colors": "5.26.0",
|
|
32
|
+
"@spscommerce/ds-illustrations": "5.26.0",
|
|
33
|
+
"@spscommerce/ds-shared": "5.26.0",
|
|
34
|
+
"@spscommerce/positioning": "5.26.0",
|
|
35
|
+
"@spscommerce/utils": "5.26.0",
|
|
36
36
|
"moment": "^2.25.3",
|
|
37
37
|
"moment-timezone": "^0.5.28",
|
|
38
38
|
"react": "^16.9.0",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@react-stately/collections": "^3.3.3",
|
|
43
|
-
"@spscommerce/ds-colors": "5.
|
|
44
|
-
"@spscommerce/ds-illustrations": "5.
|
|
45
|
-
"@spscommerce/ds-shared": "5.
|
|
46
|
-
"@spscommerce/positioning": "5.
|
|
47
|
-
"@spscommerce/utils": "5.
|
|
43
|
+
"@spscommerce/ds-colors": "5.26.0",
|
|
44
|
+
"@spscommerce/ds-illustrations": "5.26.0",
|
|
45
|
+
"@spscommerce/ds-shared": "5.26.0",
|
|
46
|
+
"@spscommerce/positioning": "5.26.0",
|
|
47
|
+
"@spscommerce/utils": "5.26.0",
|
|
48
48
|
"@testing-library/react": "^9.3.2",
|
|
49
49
|
"@types/prop-types": "^15.7.1",
|
|
50
50
|
"@types/react": "^16.9.0",
|