@nodeblocks/frontend-how-to-use-block 0.3.2 → 0.4.1
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/dist/HowToUse.d.ts +11 -11
- package/dist/HowToUse.d.ts.map +1 -1
- package/dist/context.d.ts +2 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/lib.d.ts +41 -6
- package/dist/lib.d.ts.map +1 -1
- package/package.json +4 -1
package/dist/HowToUse.d.ts
CHANGED
|
@@ -6,11 +6,11 @@ import { BlocksOverride } from './lib';
|
|
|
6
6
|
declare const HowToUse: {
|
|
7
7
|
<CustomBlocks extends Record<string, ReactNode> = {}>({ className, children, sx, ...props }: Omit<StackProps, "children"> & {
|
|
8
8
|
children?: BlocksOverride<typeof defaultHowToUseBlocks, CustomBlocks>;
|
|
9
|
-
} & Required<Pick<HowToUseContextValue, "subtitle" | "headerContent" | "message" | "linkHref" | "linkContent">>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
} & Required<Pick<HowToUseContextValue, "subtitle" | "headerContent" | "message" | "linkHref" | "linkContent">> & Partial<Pick<HowToUseContextValue, "cardList">>): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
Header: ({ className, children, sx, ...props }: StackProps & Partial<Pick<HowToUseContextValue, "subtitle" | "headerContent">>) => import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
CardList: ({ children, className, sx, ...props }: StackProps & {
|
|
12
|
-
children
|
|
13
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
} & Partial<Pick<HowToUseContextValue, "cardList">>) => import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
Card: ({ children, className, icon: Icon, headerContent, sx, ...props }: CardProps & {
|
|
15
15
|
icon: SvgIconComponent;
|
|
16
16
|
headerContent: ReactNode;
|
|
@@ -19,17 +19,17 @@ declare const HowToUse: {
|
|
|
19
19
|
};
|
|
20
20
|
declare const defaultHowToUseBlocks: {
|
|
21
21
|
header: import("react").ReactElement<import("@mui/material").StackOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("@mui/material/OverridableComponent").CommonProps | keyof import("@mui/material").StackOwnProps> & {
|
|
22
|
-
component?: React.ElementType;
|
|
22
|
+
component?: React.ElementType | undefined;
|
|
23
23
|
} & Partial<Pick<HowToUseContextValue, "subtitle" | "headerContent">>, ({ className, children, sx, ...props }: StackProps & Partial<Pick<HowToUseContextValue, "subtitle" | "headerContent">>) => import("react/jsx-runtime").JSX.Element>;
|
|
24
24
|
cardList: import("react").ReactElement<import("@mui/material").StackOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("@mui/material/OverridableComponent").CommonProps | keyof import("@mui/material").StackOwnProps> & {
|
|
25
|
-
component?: React.ElementType;
|
|
25
|
+
component?: React.ElementType | undefined;
|
|
26
26
|
} & {
|
|
27
|
-
children
|
|
28
|
-
}, ({ children, className, sx, ...props }: StackProps & {
|
|
29
|
-
children
|
|
30
|
-
}) => import("react/jsx-runtime").JSX.Element>;
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
} & Partial<Pick<HowToUseContextValue, "cardList">>, ({ children, className, sx, ...props }: StackProps & {
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
} & Partial<Pick<HowToUseContextValue, "cardList">>) => import("react/jsx-runtime").JSX.Element>;
|
|
31
31
|
card: import("react").ReactElement<import("@mui/material").CardOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children" | "style" | "square" | "className" | "classes" | "elevation" | "sx" | "variant" | "raised"> & {
|
|
32
|
-
component?: React.ElementType;
|
|
32
|
+
component?: React.ElementType | undefined;
|
|
33
33
|
} & {
|
|
34
34
|
icon: SvgIconComponent;
|
|
35
35
|
headerContent: ReactNode;
|
|
@@ -38,7 +38,7 @@ declare const defaultHowToUseBlocks: {
|
|
|
38
38
|
headerContent: ReactNode;
|
|
39
39
|
}) => import("react/jsx-runtime").JSX.Element>;
|
|
40
40
|
footer: import("react").ReactElement<import("@mui/material").StackOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("@mui/material/OverridableComponent").CommonProps | keyof import("@mui/material").StackOwnProps> & {
|
|
41
|
-
component?: React.ElementType;
|
|
41
|
+
component?: React.ElementType | undefined;
|
|
42
42
|
} & Required<Pick<HowToUseContextValue, "message" | "linkHref" | "linkContent">>, ({ children, className, sx, ...props }: StackProps & Required<Pick<HowToUseContextValue, "message" | "linkHref" | "linkContent">>) => import("react/jsx-runtime").JSX.Element>;
|
|
43
43
|
};
|
|
44
44
|
export default HowToUse;
|
package/dist/HowToUse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HowToUse.d.ts","sourceRoot":"","sources":["../src/HowToUse.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAuB,SAAS,EAA0B,UAAU,EAAc,MAAM,eAAe,CAAC;AAC/G,OAAO,
|
|
1
|
+
{"version":3,"file":"HowToUse.d.ts","sourceRoot":"","sources":["../src/HowToUse.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAuB,SAAS,EAA0B,UAAU,EAAc,MAAM,eAAe,CAAC;AAC/G,OAAO,EAAsB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAA6D,MAAM,WAAW,CAAC;AAE5G,OAAO,EAAE,c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AE;;;8HAgHhE,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,UAAU,GAAG,aAAa,CAAC,CAAC;CA0J1F,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
export type HowToUseContextValue = {
|
|
3
|
+
cardList?: ReactNode[];
|
|
3
4
|
subtitle: ReactNode;
|
|
4
5
|
headerContent: ReactNode;
|
|
5
6
|
message: ReactNode;
|
|
6
7
|
linkHref: string;
|
|
7
8
|
linkContent: ReactNode;
|
|
8
9
|
};
|
|
9
|
-
export declare const keys: readonly ["subtitle", "headerContent", "message", "linkHref", "linkContent"];
|
|
10
|
+
export declare const keys: readonly ["cardList", "subtitle", "headerContent", "message", "linkHref", "linkContent"];
|
|
10
11
|
export declare const HowToUseProvider: ({ children, ...value }: HowToUseContextValue & {
|
|
11
12
|
children: ReactNode;
|
|
12
13
|
}) => import("react/jsx-runtime").JSX.Element;
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAc,MAAM,OAAO,CAAC;AAE7D,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,EAAE,SAAS,CAAC;IACzB,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,SAAS,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAc,MAAM,OAAO,CAAC;AAE7D,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,EAAE,SAAS,CAAC;IACzB,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,SAAS,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,IAAI,0FAOyB,CAAC;AAW3C,eAAO,MAAM,gBAAgB,GAAI,wBAG9B,oBAAoB,GAAG;IACxB,QAAQ,EAAE,SAAS,CAAC;CACrB,4CAEA,CAAC;AAEF,eAAO,MAAM,kBAAkB,4BAO9B,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("@mui/icons-material"),
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("@mui/icons-material"),t=require("@mui/material"),s=require("react");const n=["cardList","subtitle","headerContent","message","linkHref","linkContent"],o=s.createContext(void 0),i=({children:r,...t})=>e.jsx(o.Provider,{value:t,children:r}),a=()=>{const e=s.useContext(o);if(!e)throw new Error("useHowToUseContext must be used within a HowToUseProvider");return e};function c({blocksOverride:e,defaultBlocks:r,defaultBlockOrder:t,children:s}){if(void 0===e)return s({blocks:r,blockOrder:t});if("function"==typeof e){const{blocks:n,blockOrder:o}=e({defaultBlocks:r,defaultBlockOrder:t});return s({blocks:n,blockOrder:o})}return e}function l(e){return"[object Object]"===Object.prototype.toString.call(e)&&!s.isValidElement(e)}const d=new Set(["__proto__","prototype","constructor"]);function x(e,r){const t={...e};for(const e of Reflect.ownKeys(r)){if(d.has(e))continue;const s=t[e],n=r[e];l(s)&&l(n)?t[e]=x(s,n):t[e]=n}return t}function h(...e){return e.flat().filter(Boolean).join(" ")}function m(e,...r){const t={...e};for(const e of r)delete t[e];return t}function u(e,...r){const t={};for(const s of r)s in e&&(t[s]=e[s]);return t}const p=({className:r,children:o,sx:a=[],...l})=>e.jsx(i,{...u(l,...n),children:e.jsx(t.Stack,{spacing:{xs:5,sm:6},className:h("nbb-how-to-use",r),sx:[e=>({backgroundColor:e.palette.background.default}),...Array.isArray(a)?a:[a]],...m(l,...n),children:e.jsx(c,{defaultBlocks:f,defaultBlockOrder:Object.keys(f),blocksOverride:o,children:({blocks:{card:r,...t},blockOrder:n})=>e.jsx(e.Fragment,{children:n.filter(e=>e in t).map(r=>e.jsx(s.Fragment,{children:t[r]},String(r)))})})})}),f=(y={header:p.Header=({className:r,children:s,sx:o=[],...i})=>{const c=a(),{subtitle:l,headerContent:d}=x(c,i);return e.jsxs(t.Stack,{spacing:{xs:.5,sm:1},className:h("nbb-how-to-use-header",r),sx:[{textAlign:"center"},...Array.isArray(o)?o:[o]],...m(i,...n),children:[e.jsx(t.Typography,{variant:"h4",sx:{color:"primary.main",typography:{xs:"h6",sm:"h4"}},children:d||s}),e.jsx(t.Typography,{variant:"h1",component:"h1",sx:{fontSize:{xs:"h4.fontSize",sm:45}},children:l})]})},cardList:p.CardList=({children:o,className:i,sx:c=[],...l})=>{const{cardList:d=[]}=x(a(),l),u=o?s.Children.toArray(o):d;return e.jsx(t.Stack,{direction:{xs:"column",sm:"row"},spacing:0,className:h("nbb-how-to-use-card-list",i),sx:[{alignItems:{xs:"center",sm:"stretch"},justifyContent:"center"},...Array.isArray(c)?c:[c]],...m(l,...n),children:u.reduce((t,s,n)=>[...t,...n>0?[e.jsx(r.ArrowRight,{sx:{display:{xs:"none",sm:"initial"},fontSize:40,color:"primary.main",alignSelf:"center"}},`right-arrow-${n}`),e.jsx(r.ArrowDropDown,{sx:{display:{xs:"initial",sm:"none"},fontSize:40,color:"primary.main",alignSelf:"center"}},`down-arrow-${n}`)]:[],s],[])})},card:p.Card=({children:r,className:s,icon:n,headerContent:o,sx:i=[],...a})=>e.jsx(t.Card,{component:"article",elevation:0,className:h("nbb-how-to-use-card",s),sx:[{width:"100%",maxWidth:360},...Array.isArray(i)?i:[i]],...a,children:e.jsxs(t.CardContent,{component:t.Stack,spacing:2,sx:{py:{xs:2,sm:3},px:2.5,alignItems:{xs:"flex-start",sm:"unset"}},children:[e.jsxs(t.Stack,{direction:{xs:"row",sm:"column"},spacing:{xs:2,sm:1},sx:{alignItems:"center",justifyContent:"center",py:.5},children:[n&&e.jsx(n,{sx:{color:"primary.main",fontSize:{xs:24,sm:40}}}),e.jsx(t.Typography,{component:"h6",sx:{typography:{xs:"subtitle1",sm:"h4"},m:0},children:o})]}),e.jsx(t.Typography,{variant:"body1",sx:{textAlign:"left"},children:r})]})}),footer:p.Footer=({children:r,className:s,sx:o=[],...i})=>{const c=a(),{message:l,linkHref:d,linkContent:u}=x(c,i);return e.jsxs(t.Stack,{spacing:{xs:1.5,sm:2},className:h("nbb-how-to-use-footer",s),sx:[{alignItems:"center"},...Array.isArray(o)?o:[o]],...m(i,...n),children:[l&&e.jsx(t.Typography,{variant:"h6",sx:{typography:{xs:"subtitle2",sm:"h5"},color:"primary.main"},children:l}),e.jsx(t.Button,{href:d,rel:"noreferrer noopener",variant:"contained",size:"large",sx:{width:360,maxWidth:"100%",typography:{xs:"subtitle1",sm:"h5"},px:{sm:4}},children:u})]})}},Object.fromEntries(Object.entries(y).map(([e,r])=>[e,s.createElement(r,{key:e})])));var y;exports.HowToUse=p;
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as r,jsxs as
|
|
1
|
+
import{jsx as e,Fragment as r,jsxs as t}from"react/jsx-runtime";import{ArrowRight as n,ArrowDropDown as s}from"@mui/icons-material";import{Stack as o,Typography as i,Card as c,CardContent as a,Button as l}from"@mui/material";import d,{createContext as m,useContext as h,createElement as u,Fragment as f,Children as x}from"react";const p=["cardList","subtitle","headerContent","message","linkHref","linkContent"],y=m(void 0),b=({children:r,...t})=>e(y.Provider,{value:t,children:r}),g=()=>{const e=h(y);if(!e)throw new Error("useHowToUseContext must be used within a HowToUseProvider");return e};function k({blocksOverride:e,defaultBlocks:r,defaultBlockOrder:t,children:n}){if(void 0===e)return n({blocks:r,blockOrder:t});if("function"==typeof e){const{blocks:s,blockOrder:o}=e({defaultBlocks:r,defaultBlockOrder:t});return n({blocks:s,blockOrder:o})}return e}function w(e){return"[object Object]"===Object.prototype.toString.call(e)&&!d.isValidElement(e)}const v=new Set(["__proto__","prototype","constructor"]);function O(e,r){const t={...e};for(const e of Reflect.ownKeys(r)){if(v.has(e))continue;const n=t[e],s=r[e];w(n)&&w(s)?t[e]=O(n,s):t[e]=s}return t}function A(...e){return e.flat().filter(Boolean).join(" ")}function C(e,...r){const t={...e};for(const e of r)delete t[e];return t}function j(e,...r){const t={};for(const n of r)n in e&&(t[n]=e[n]);return t}const N=({className:t,children:n,sx:s=[],...i})=>e(b,{...j(i,...p),children:e(o,{spacing:{xs:5,sm:6},className:A("nbb-how-to-use",t),sx:[e=>({backgroundColor:e.palette.background.default}),...Array.isArray(s)?s:[s]],...C(i,...p),children:e(k,{defaultBlocks:S,defaultBlockOrder:Object.keys(S),blocksOverride:n,children:({blocks:{card:t,...n},blockOrder:s})=>e(r,{children:s.filter(e=>e in n).map(r=>e(f,{children:n[r]},String(r)))})})})}),S=(B={header:N.Header=({className:r,children:n,sx:s=[],...c})=>{const a=g(),{subtitle:l,headerContent:d}=O(a,c);return t(o,{spacing:{xs:.5,sm:1},className:A("nbb-how-to-use-header",r),sx:[{textAlign:"center"},...Array.isArray(s)?s:[s]],...C(c,...p),children:[e(i,{variant:"h4",sx:{color:"primary.main",typography:{xs:"h6",sm:"h4"}},children:d||n}),e(i,{variant:"h1",component:"h1",sx:{fontSize:{xs:"h4.fontSize",sm:45}},children:l})]})},cardList:N.CardList=({children:r,className:t,sx:i=[],...c})=>{const{cardList:a=[]}=O(g(),c),l=r?x.toArray(r):a;return e(o,{direction:{xs:"column",sm:"row"},spacing:0,className:A("nbb-how-to-use-card-list",t),sx:[{alignItems:{xs:"center",sm:"stretch"},justifyContent:"center"},...Array.isArray(i)?i:[i]],...C(c,...p),children:l.reduce((r,t,o)=>[...r,...o>0?[e(n,{sx:{display:{xs:"none",sm:"initial"},fontSize:40,color:"primary.main",alignSelf:"center"}},`right-arrow-${o}`),e(s,{sx:{display:{xs:"initial",sm:"none"},fontSize:40,color:"primary.main",alignSelf:"center"}},`down-arrow-${o}`)]:[],t],[])})},card:N.Card=({children:r,className:n,icon:s,headerContent:l,sx:d=[],...m})=>e(c,{component:"article",elevation:0,className:A("nbb-how-to-use-card",n),sx:[{width:"100%",maxWidth:360},...Array.isArray(d)?d:[d]],...m,children:t(a,{component:o,spacing:2,sx:{py:{xs:2,sm:3},px:2.5,alignItems:{xs:"flex-start",sm:"unset"}},children:[t(o,{direction:{xs:"row",sm:"column"},spacing:{xs:2,sm:1},sx:{alignItems:"center",justifyContent:"center",py:.5},children:[s&&e(s,{sx:{color:"primary.main",fontSize:{xs:24,sm:40}}}),e(i,{component:"h6",sx:{typography:{xs:"subtitle1",sm:"h4"},m:0},children:l})]}),e(i,{variant:"body1",sx:{textAlign:"left"},children:r})]})}),footer:N.Footer=({children:r,className:n,sx:s=[],...c})=>{const a=g(),{message:d,linkHref:m,linkContent:h}=O(a,c);return t(o,{spacing:{xs:1.5,sm:2},className:A("nbb-how-to-use-footer",n),sx:[{alignItems:"center"},...Array.isArray(s)?s:[s]],...C(c,...p),children:[d&&e(i,{variant:"h6",sx:{typography:{xs:"subtitle2",sm:"h5"},color:"primary.main"},children:d}),e(l,{href:m,rel:"noreferrer noopener",variant:"contained",size:"large",sx:{width:360,maxWidth:"100%",typography:{xs:"subtitle1",sm:"h5"},px:{sm:4}},children:h})]})}},Object.fromEntries(Object.entries(B).map(([e,r])=>[e,u(r,{key:e})])));var B;export{N as HowToUse};
|
package/dist/lib.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ComponentProps, FunctionComponent, ReactElement, ReactNode } from 'react';
|
|
1
|
+
import React, { ComponentProps, FunctionComponent, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { DistributedOmit } from 'type-fest';
|
|
2
3
|
/**
|
|
3
4
|
* The function to be passed into a block component as `children` to selectively override default blocks, or just a `ReactNode`.
|
|
4
5
|
*
|
|
@@ -71,13 +72,47 @@ export declare function BlocksOverrideComponent<DefaultBlocks extends Record<str
|
|
|
71
72
|
blocks: Partial<DefaultBlocks> & Partial<CustomBlocks>;
|
|
72
73
|
blockOrder: readonly (keyof DefaultBlocks | keyof CustomBlocks)[];
|
|
73
74
|
}) => ReactNode;
|
|
74
|
-
}): ReactNode;
|
|
75
|
-
type
|
|
76
|
-
|
|
75
|
+
}): React.ReactNode;
|
|
76
|
+
type IsOptionalKey<T, K extends keyof T> = {} extends Pick<T, K> ? true : false;
|
|
77
|
+
type MergeKeepingRequired<A extends Record<PropertyKey, any>, B extends Record<PropertyKey, any>> = DistributedOmit<A, keyof B> & DistributedOmit<B, keyof A> & {
|
|
78
|
+
[K in keyof A & keyof B as IsOptionalKey<A, K> extends true ? IsOptionalKey<B, K> extends true ? never : K : K]-?: IsOptionalKey<B, K> extends true ? A[K] | Required<B>[K] : B[K];
|
|
77
79
|
} & {
|
|
78
|
-
[K in
|
|
80
|
+
[K in keyof A & keyof B as IsOptionalKey<A, K> extends true ? IsOptionalKey<B, K> extends true ? K : never : never]?: A[K] | Required<B>[K];
|
|
79
81
|
};
|
|
80
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Shallow merges `target` and `source`, prioritizing `source`.
|
|
84
|
+
*
|
|
85
|
+
* ⚠️ Keeps keys from `target` that don't exist in `source`.
|
|
86
|
+
*/
|
|
87
|
+
export declare function merge<A extends Record<PropertyKey, any>, B extends Record<PropertyKey, any>>(target: A, source: B): MergeKeepingRequired<A, B>;
|
|
88
|
+
type PlainObject = Record<PropertyKey, unknown>;
|
|
89
|
+
type Simplify<T> = {
|
|
90
|
+
[K in keyof T]: T[K];
|
|
91
|
+
} & {};
|
|
92
|
+
type MergeDeepValueKeepingRequired<A, B> = [NonNullable<A>, NonNullable<B>] extends [PlainObject, PlainObject] ? MergeDeepKeepingRequired<Extract<NonNullable<A>, PlainObject>, Extract<NonNullable<B>, PlainObject>> : B;
|
|
93
|
+
type MergeValueAtKey<A extends PlainObject, B extends PlainObject, K extends keyof A | keyof B> = K extends keyof B ? K extends keyof A ? IsOptionalKey<B, K> extends true ? A[K] | MergeDeepValueKeepingRequired<A[K], Required<B>[K]> : MergeDeepValueKeepingRequired<A[K], B[K]> : B[K] : K extends keyof A ? A[K] : never;
|
|
94
|
+
/**
|
|
95
|
+
* This is the "readable" view:
|
|
96
|
+
* every possible key is present at least optionally,
|
|
97
|
+
* so generic indexing works.
|
|
98
|
+
*/
|
|
99
|
+
type MergeReadableView<A extends PlainObject, B extends PlainObject> = {
|
|
100
|
+
[K in keyof A | keyof B]?: MergeValueAtKey<A, B, K>;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* This is your original precise required/optional logic.
|
|
104
|
+
*/
|
|
105
|
+
type MergePrecise<A extends PlainObject, B extends PlainObject> = Omit<A, keyof B> & Omit<B, keyof A> & {
|
|
106
|
+
[K in keyof A & keyof B as IsOptionalKey<A, K> extends true ? IsOptionalKey<B, K> extends true ? never : K : K]-?: IsOptionalKey<B, K> extends true ? A[K] | MergeDeepValueKeepingRequired<A[K], Required<B>[K]> : MergeDeepValueKeepingRequired<A[K], B[K]>;
|
|
107
|
+
} & {
|
|
108
|
+
[K in keyof A & keyof B as IsOptionalKey<A, K> extends true ? IsOptionalKey<B, K> extends true ? K : never : never]?: A[K] | MergeDeepValueKeepingRequired<A[K], Required<B>[K]>;
|
|
109
|
+
};
|
|
110
|
+
type MergeDeepKeepingRequired<A extends PlainObject, B extends PlainObject> = Simplify<MergePrecise<A, B> & MergeReadableView<A, B>>;
|
|
111
|
+
/**
|
|
112
|
+
* Deep merges `target` and `source`, prioritizing `source`.
|
|
113
|
+
* Replaces arrays. Returns a new object.
|
|
114
|
+
*/
|
|
115
|
+
export declare function deepMerge<T extends PlainObject, U extends PlainObject>(target: T, source: U): MergeDeepKeepingRequired<T, U>;
|
|
81
116
|
type ClassName = string | ClassName[] | undefined | null;
|
|
82
117
|
/**
|
|
83
118
|
* Utility function to join class names together, ignoring undefined or nil values.
|
package/dist/lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAiB,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzG,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,cAAc,CAAC,aAAa,EAAE,YAAY,IAClD,CAAC,CAAC,EACA,aAAa,EACb,iBAAiB,GAClB,EAAE;IACD,aAAa,EAAE,aAAa,CAAC;IAC7B,iBAAiB,EAAE,SAAS,CAAC,MAAM,aAAa,CAAC,EAAE,CAAC;CACrD,KAAK;IACJ,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC;IAE9C,UAAU,EAAE,SAAS,CAAC,MAAM,aAAa,CAAC,EAAE,GAAG,SAAS,CAAC,MAAM,YAAY,CAAC,EAAE,CAAC;CAChF,CAAC,GACF,SAAS,CAAC;AAEd;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAClF,UAAU,EAAE,CAAC,GACZ;KACA,CAAC,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CA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AC,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAQzC;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAWnH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodeblocks/frontend-how-to-use-block",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"main": "./dist/index.cjs.js",
|
|
5
5
|
"module": "./dist/index.esm.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -42,5 +42,8 @@
|
|
|
42
42
|
"rollup-plugin-serve": "^1.1.1",
|
|
43
43
|
"tslib": "^2.8.1",
|
|
44
44
|
"typescript": "^5.7.2"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"type-fest": "^5.4.4"
|
|
45
48
|
}
|
|
46
49
|
}
|