@snokam/ui 7.6.0 → 7.6.2
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/CHANGELOG.md +10 -0
- package/dist/components/layout/container/blobs.d.ts +6 -0
- package/dist/components/layout/container/blobs.d.ts.map +1 -0
- package/dist/components/layout/container/blobs.js +12 -0
- package/dist/components/layout/container/blobs.js.map +1 -0
- package/dist/components/layout/container/index.d.ts.map +1 -1
- package/dist/components/layout/container/index.js +2 -8
- package/dist/components/layout/container/index.js.map +1 -1
- package/dist/components/layout/container/styled.d.ts +8 -0
- package/dist/components/layout/container/styled.d.ts.map +1 -1
- package/dist/components/layout/container/styled.js +15 -1
- package/dist/components/layout/container/styled.js.map +1 -1
- package/dist/components/portable-text/PortableText.Code.js +1 -1
- package/dist/components/portable-text/PortableText.Code.js.map +1 -1
- package/dist/components/portable-text/utils/rename-sanity-fields.d.ts +1 -5
- package/dist/components/portable-text/utils/rename-sanity-fields.d.ts.map +1 -1
- package/dist/components/portable-text/utils/rename-sanity-fields.js +11 -31
- package/dist/components/portable-text/utils/rename-sanity-fields.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [7.6.2](https://github.com/snokam/components/compare/%40snokam%2Fui%407.6.1...%40snokam%2Fui%407.6.2) (2026-11-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @snokam/ui
|
|
9
|
+
|
|
10
|
+
## [7.6.1](https://github.com/snokam/components/compare/%40snokam%2Fui%407.6.0...%40snokam%2Fui%407.6.1) (2026-11-10)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **ui:** bands inherit the theme instead of guessing it in js ([#3459](https://github.com/snokam/components/issues/3459)) ([b9b19cb](https://github.com/snokam/components/commit/b9b19cb7c088ecaa995be38259eb6be57a670d1d))
|
|
15
|
+
|
|
6
16
|
# [7.6.0](https://github.com/snokam/components/compare/%40snokam%2Fui%407.3.4...%40snokam%2Fui%407.6.0) (2026-11-10)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blobs.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/container/blobs.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,wBAAgB,KAAK,CAAC,EACpB,IAAI,EACJ,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,+BAcA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import Styled from "./styled";
|
|
4
|
+
import { LayoutTheme } from "../types";
|
|
5
|
+
import { AnimatedBlobs, BlobTheme } from "@snokam/ui/animated-blobs";
|
|
6
|
+
export function Blobs({ tone, elements, }) {
|
|
7
|
+
if (tone === LayoutTheme.Dark) {
|
|
8
|
+
return _jsx(AnimatedBlobs, { theme: BlobTheme.Dark, maxElements: elements });
|
|
9
|
+
}
|
|
10
|
+
return (_jsxs(_Fragment, { children: [_jsx(Styled.LightOnly, { children: _jsx(AnimatedBlobs, { theme: BlobTheme.Light, maxElements: elements }) }), _jsx(Styled.DarkOnly, { children: _jsx(AnimatedBlobs, { theme: BlobTheme.Dark, maxElements: elements }) })] }));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=blobs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blobs.js","sourceRoot":"","sources":["../../../../src/components/layout/container/blobs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,UAAU,KAAK,CAAC,EACpB,IAAI,EACJ,QAAQ,GAIT;IACC,IAAI,IAAI,KAAK,WAAW,CAAC,IAAI,EAAE,CAAC;QAC9B,OAAO,KAAC,aAAa,IAAC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,GAAI,CAAC;IACzE,CAAC;IACD,OAAO,CACL,8BACE,KAAC,MAAM,CAAC,SAAS,cACf,KAAC,aAAa,IAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,GAAI,GAC/C,EACnB,KAAC,MAAM,CAAC,QAAQ,cACd,KAAC,aAAa,IAAC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,GAAI,GAC/C,IACjB,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/container/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAwC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/container/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAwC,MAAM,UAAU,CAAC;AAIhF,QAAA,MAAM,SAAS,GAAI,0EAQhB,cAAc,gCA4BhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -3,15 +3,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import Styled from "./styled";
|
|
4
4
|
import { Position, LayoutTheme, AnimationType } from "../types";
|
|
5
5
|
import Transition from "./transitions";
|
|
6
|
-
import {
|
|
7
|
-
import { useColorScheme } from "@snokam/ui/theme/admin";
|
|
8
|
-
const themeToBlobTheme = {
|
|
9
|
-
[LayoutTheme.Dark]: BlobTheme.Dark,
|
|
10
|
-
[LayoutTheme.Light]: BlobTheme.Light,
|
|
11
|
-
};
|
|
6
|
+
import { Blobs } from "./blobs";
|
|
12
7
|
const Container = ({ children, as = "div", theme = LayoutTheme.Dark, transitions, animation, popover, ...restOfProps }) => {
|
|
13
|
-
|
|
14
|
-
return (_jsxs(Styled.Container, { as: as, "$tone": theme, animation: animation, ...restOfProps, children: [animation?.type === AnimationType.Blobs && (_jsx(AnimatedBlobs, { theme: themeToBlobTheme[effective], maxElements: animation.elements })), children, transitions?.top && (_jsx(Transition, { theme: theme, transition: transitions.top, position: Position.Top })), transitions?.bottom && (_jsx(Transition, { theme: theme, transition: transitions.bottom, position: Position.Bottom }))] }));
|
|
8
|
+
return (_jsxs(Styled.Container, { as: as, "$tone": theme, animation: animation, ...restOfProps, children: [animation?.type === AnimationType.Blobs && (_jsx(Blobs, { tone: theme, elements: animation.elements })), children, transitions?.top && (_jsx(Transition, { theme: theme, transition: transitions.top, position: Position.Top })), transitions?.bottom && (_jsx(Transition, { theme: theme, transition: transitions.bottom, position: Position.Bottom }))] }));
|
|
15
9
|
};
|
|
16
10
|
export default Container;
|
|
17
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/layout/container/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAkB,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/layout/container/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAkB,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,SAAS,GAAG,CAAC,EACjB,QAAQ,EACR,EAAE,GAAG,KAAK,EACV,KAAK,GAAG,WAAW,CAAC,IAAI,EACxB,WAAW,EACX,SAAS,EACT,OAAO,EACP,GAAG,WAAW,EACC,EAAE,EAAE;IACnB,OAAO,CACL,MAAC,MAAM,CAAC,SAAS,IACf,EAAE,EAAE,EAAE,WACC,KAAK,EACZ,SAAS,EAAE,SAAS,KAChB,WAAW,aAEd,SAAS,EAAE,IAAI,KAAK,aAAa,CAAC,KAAK,IAAI,CAC1C,KAAC,KAAK,IAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,QAAQ,GAAI,CACrD,EACA,QAAQ,EACR,WAAW,EAAE,GAAG,IAAI,CACnB,KAAC,UAAU,IACT,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,WAAW,CAAC,GAAG,EAC3B,QAAQ,EAAE,QAAQ,CAAC,GAAG,GACtB,CACH,EACA,WAAW,EAAE,MAAM,IAAI,CACtB,KAAC,UAAU,IACT,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,WAAW,CAAC,MAAM,EAC9B,QAAQ,EAAE,QAAQ,CAAC,MAAM,GACzB,CACH,IACgB,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -11,6 +11,14 @@ declare const _default: {
|
|
|
11
11
|
theme?: import("@emotion/react").Theme;
|
|
12
12
|
as?: React.ElementType;
|
|
13
13
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
14
|
+
LightOnly: import("@emotion/styled").StyledComponent<{
|
|
15
|
+
theme?: import("@emotion/react").Theme;
|
|
16
|
+
as?: React.ElementType;
|
|
17
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
18
|
+
DarkOnly: import("@emotion/styled").StyledComponent<{
|
|
19
|
+
theme?: import("@emotion/react").Theme;
|
|
20
|
+
as?: React.ElementType;
|
|
21
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
14
22
|
};
|
|
15
23
|
export default _default;
|
|
16
24
|
//# sourceMappingURL=styled.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/container/styled.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;;;;;;eAG/C,WAAW;oBACN,eAAe
|
|
1
|
+
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/container/styled.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;;;;;;eAG/C,WAAW;oBACN,eAAe;;;;;;;;;;;;;;;AAkD7B,wBAA4D"}
|
|
@@ -32,5 +32,19 @@ const Container = styled.div `
|
|
|
32
32
|
`}
|
|
33
33
|
`;
|
|
34
34
|
const Children = styled.div ``;
|
|
35
|
-
|
|
35
|
+
const LightOnly = styled.div `
|
|
36
|
+
display: contents;
|
|
37
|
+
|
|
38
|
+
[data-theme="dark"] & {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
const DarkOnly = styled.div `
|
|
43
|
+
display: none;
|
|
44
|
+
|
|
45
|
+
[data-theme="dark"] & {
|
|
46
|
+
display: contents;
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
export default { Container, Children, LightOnly, DarkOnly };
|
|
36
50
|
//# sourceMappingURL=styled.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","sourceRoot":"","sources":["../../../../src/components/layout/container/styled.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAmB,MAAM,UAAU,CAAC;AAExD,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAG1B;;;;;;;;;IASE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACd,KAAK,KAAK,WAAW,CAAC,IAAI;IACxB,CAAC,CAAC,GAAG,CAAA;;;;;;;;SAQF;IACH,CAAC,CAAC,GAAG,CAAA;;;;;;;;SAQF;CACR,CAAC;AAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAE9B,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"styled.js","sourceRoot":"","sources":["../../../../src/components/layout/container/styled.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAmB,MAAM,UAAU,CAAC;AAExD,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAG1B;;;;;;;;;IASE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACd,KAAK,KAAK,WAAW,CAAC,IAAI;IACxB,CAAC,CAAC,GAAG,CAAA;;;;;;;;SAQF;IACH,CAAC,CAAC,GAAG,CAAA;;;;;;;;SAQF;CACR,CAAC;AAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAE9B,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;CAM3B,CAAC;AAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;CAM1B,CAAC;AAEF,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -25,7 +25,7 @@ const normalizeLanguage = (lang) => {
|
|
|
25
25
|
return LANGUAGE_MAP[lang.toLowerCase()] ?? lang.toLowerCase();
|
|
26
26
|
};
|
|
27
27
|
const CodeBlock = ({ value }) => {
|
|
28
|
-
return (_jsx(Highlight, { prism: Prism, code: value?.code, language: normalizeLanguage(value?.language), theme: themes.okaidia, children: ({ style, tokens, getLineProps, getTokenProps }) => (_jsx(Styled.Code, { style: style, children: tokens.map((line, i) => (_jsx(Styled.Line, { ...getLineProps({ line
|
|
28
|
+
return (_jsx(Highlight, { prism: Prism, code: value?.code, language: normalizeLanguage(value?.language), theme: themes.okaidia, children: ({ style, tokens, getLineProps, getTokenProps }) => (_jsx(Styled.Code, { style: style, children: tokens.map((line, i) => (_jsx(Styled.Line, { ...getLineProps({ line }), children: line.map((token, key) => (_jsx("span", { ...getTokenProps({ token }) }, key))) }, i))) })) }));
|
|
29
29
|
};
|
|
30
30
|
export default CodeBlock;
|
|
31
31
|
//# sourceMappingURL=PortableText.Code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PortableText.Code.js","sourceRoot":"","sources":["../../../src/components/portable-text/PortableText.Code.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEhE,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC;AAChE,OAAO,CAAC,iCAAiC,CAAC,CAAC;AAC3C,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,MAAM,YAAY,GAA2B;IAC3C,EAAE,EAAE,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,YAC5C,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CACxB,kBAAoB,aAAa,CAAC,EAAE,KAAK,EAAE,CAAC,IAAjC,GAAG,CAAkC,CACjD,CAAC,IAHc,CAAC,CAIL,CACf,CAAC,GACU,CACf,GACS,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
export type RenameSanityFields<T> = T extends Array<infer U> ? RenameSanityFields<U>[] : T extends object ? {
|
|
2
|
-
[K in keyof T as K extends string ? K extends `_${infer _Rest}` ? K extends `_${infer First}${infer Other}` ? `sanity${Capitalize<First>}${Other}` : never : K : K]: RenameSanityFields<T[K]>;
|
|
3
|
-
} : T;
|
|
4
1
|
export type ReverseSanityFields<T> = T extends Array<infer U> ? ReverseSanityFields<U>[] : T extends object ? {
|
|
5
2
|
[K in keyof T as K extends string ? K extends `sanity${infer First}${infer Other}` ? `_${Uncapitalize<First>}${Other}` : K : K]: ReverseSanityFields<T[K]>;
|
|
6
3
|
} : T;
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function reverseSanityFields<T>(obj: T, removeType?: boolean): ReverseSanityFields<T>;
|
|
4
|
+
export declare function reverseSanityFields<T>(obj: T): ReverseSanityFields<T>;
|
|
9
5
|
//# sourceMappingURL=rename-sanity-fields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rename-sanity-fields.d.ts","sourceRoot":"","sources":["../../../../src/components/portable-text/utils/rename-sanity-fields.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"rename-sanity-fields.d.ts","sourceRoot":"","sources":["../../../../src/components/portable-text/utils/rename-sanity-fields.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAC/B,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACpB,mBAAmB,CAAC,CAAC,CAAC,EAAE,GACxB,CAAC,SAAS,MAAM,GACd;KAEI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,GAC5B,CAAC,SAAS,SAAS,MAAM,KAAK,GAAG,MAAM,KAAK,EAAE,GAC5C,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,GACjC,CAAC,GACH,CAAC,GACJ,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC7B,GACD,CAAC,CAAC;AAEV,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAerE"}
|
|
@@ -1,36 +1,16 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function reverseSanityFields(obj) {
|
|
2
2
|
if (Array.isArray(obj)) {
|
|
3
|
-
return obj.map((item) =>
|
|
3
|
+
return obj.map((item) => reverseSanityFields(item));
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return { ...transformedObject, _type: typeValue };
|
|
5
|
+
if (!obj || typeof obj !== "object")
|
|
6
|
+
return obj;
|
|
7
|
+
const renamed = {};
|
|
8
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
9
|
+
const name = key.startsWith("sanity")
|
|
10
|
+
? `_${key.charAt(6).toLowerCase()}${key.slice(7)}`
|
|
11
|
+
: key;
|
|
12
|
+
renamed[name] = reverseSanityFields(value);
|
|
14
13
|
}
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
export function reverseSanityFields(obj, removeType = false) {
|
|
18
|
-
if (Array.isArray(obj)) {
|
|
19
|
-
return obj.map((item) => reverseSanityFields(item, removeType));
|
|
20
|
-
}
|
|
21
|
-
else if (obj && typeof obj === "object") {
|
|
22
|
-
const transformedObject = Object.entries(obj).reduce((acc, [key, value]) => {
|
|
23
|
-
const newKey = key.startsWith("sanity")
|
|
24
|
-
? `_${key.slice(6).charAt(0).toLowerCase()}${key.slice(7)}`
|
|
25
|
-
: key;
|
|
26
|
-
if (removeType && newKey === "_type") {
|
|
27
|
-
return acc;
|
|
28
|
-
}
|
|
29
|
-
acc[newKey] = reverseSanityFields(value, removeType);
|
|
30
|
-
return acc;
|
|
31
|
-
}, {});
|
|
32
|
-
return transformedObject;
|
|
33
|
-
}
|
|
34
|
-
return obj;
|
|
14
|
+
return renamed;
|
|
35
15
|
}
|
|
36
16
|
//# sourceMappingURL=rename-sanity-fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rename-sanity-fields.js","sourceRoot":"","sources":["../../../../src/components/portable-text/utils/rename-sanity-fields.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rename-sanity-fields.js","sourceRoot":"","sources":["../../../../src/components/portable-text/utils/rename-sanity-fields.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,mBAAmB,CAAI,GAAM;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACtB,mBAAmB,CAAC,IAAI,CAAC,CACA,CAAC;IAC9B,CAAC;IACD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAA6B,CAAC;IAC1E,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC;YACnC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YAClD,CAAC,CAAC,GAAG,CAAC;QACR,OAAO,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,OAAiC,CAAC;AAC3C,CAAC"}
|
package/package.json
CHANGED