@elliemae/ds-grid 3.70.0-next.60 → 3.70.0-next.62
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/cjs/Grid.js +13 -15
- package/dist/cjs/Grid.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js +1 -0
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/typescript-testing/typescript-grid-valid.js +1 -0
- package/dist/cjs/typescript-testing/typescript-grid-valid.js.map +2 -2
- package/dist/cjs/utils/resolveLayoutMode.js +62 -0
- package/dist/cjs/utils/resolveLayoutMode.js.map +7 -0
- package/dist/esm/Grid.js +13 -15
- package/dist/esm/Grid.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js +1 -0
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/typescript-testing/typescript-grid-valid.js +1 -0
- package/dist/esm/typescript-testing/typescript-grid-valid.js.map +2 -2
- package/dist/esm/utils/resolveLayoutMode.js +32 -0
- package/dist/esm/utils/resolveLayoutMode.js.map +7 -0
- package/dist/types/react-desc-prop-types.d.ts +1 -0
- package/dist/types/utils/resolveLayoutMode.d.ts +17 -0
- package/package.json +5 -5
package/dist/cjs/Grid.js
CHANGED
|
@@ -37,10 +37,12 @@ var React = __toESM(require("react"));
|
|
|
37
37
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
38
|
var import_react = __toESM(require("react"));
|
|
39
39
|
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
40
|
+
var import_ds_system = require("@elliemae/ds-system");
|
|
40
41
|
var import_react_desc_prop_types = require("./react-desc-prop-types.js");
|
|
41
42
|
var import_GridItem = require("./GridItem.js");
|
|
42
43
|
var import_useGrid = require("./config/useGrid.js");
|
|
43
44
|
var import_DSGridDefinitions = require("./DSGridDefinitions.js");
|
|
45
|
+
var import_resolveLayoutMode = require("./utils/resolveLayoutMode.js");
|
|
44
46
|
const Grid = import_react.default.forwardRef((props, ref) => {
|
|
45
47
|
const {
|
|
46
48
|
propsWithDefaults: {
|
|
@@ -56,6 +58,7 @@ const Grid = import_react.default.forwardRef((props, ref) => {
|
|
|
56
58
|
height,
|
|
57
59
|
innerRef,
|
|
58
60
|
span,
|
|
61
|
+
withLayoutMode,
|
|
59
62
|
...rest
|
|
60
63
|
},
|
|
61
64
|
globalProps,
|
|
@@ -63,24 +66,19 @@ const Grid = import_react.default.forwardRef((props, ref) => {
|
|
|
63
66
|
isSpanParent,
|
|
64
67
|
renderChildren
|
|
65
68
|
} = (0, import_useGrid.useGrid)(props);
|
|
69
|
+
const layoutMode = (0, import_ds_system.useGetLayoutMode)();
|
|
66
70
|
const correctSpan = (0, import_react.useMemo)(() => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return span;
|
|
71
|
-
}, [span]);
|
|
71
|
+
const backfilled = span && typeof span !== "number" && span.small && !span.xsmall ? { ...span, xsmall: span.small } : span;
|
|
72
|
+
return withLayoutMode ? (0, import_resolveLayoutMode.resolveByLayoutMode)(backfilled, layoutMode) : backfilled;
|
|
73
|
+
}, [span, withLayoutMode, layoutMode]);
|
|
72
74
|
const correctCols = (0, import_react.useMemo)(() => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return cols;
|
|
77
|
-
}, [cols]);
|
|
75
|
+
const backfilled = typeof cols === "object" && !Array.isArray(cols) && cols.small && !cols.xsmall ? { ...cols, xsmall: cols.small } : cols;
|
|
76
|
+
return withLayoutMode ? (0, import_resolveLayoutMode.resolveByLayoutMode)(backfilled, layoutMode) : backfilled;
|
|
77
|
+
}, [cols, withLayoutMode, layoutMode]);
|
|
78
78
|
const correctRows = (0, import_react.useMemo)(() => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return rows;
|
|
83
|
-
}, [rows]);
|
|
79
|
+
const backfilled = typeof rows === "object" && !Array.isArray(rows) && rows.small && !rows.xsmall ? { ...rows, xsmall: rows.small } : rows;
|
|
80
|
+
return withLayoutMode ? (0, import_resolveLayoutMode.resolveByLayoutMode)(backfilled, layoutMode) : backfilled;
|
|
81
|
+
}, [rows, withLayoutMode, layoutMode]);
|
|
84
82
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
85
83
|
import_GridItem.GridItem,
|
|
86
84
|
{
|
package/dist/cjs/Grid.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Grid.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useMemo } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport type { DSGridT } from './react-desc-prop-types.js';\nimport { DSCardHeaderPropTypesSchema } from './react-desc-prop-types.js';\nimport { GridItem } from './GridItem.js';\nimport { useGrid } from './config/useGrid.js';\nimport { DSGridName } from './DSGridDefinitions.js';\n\nconst Grid = React.forwardRef<HTMLDivElement, DSGridT.Props>((props, ref) => {\n const {\n propsWithDefaults: {\n withMaxWidthBreakpoints,\n alignItems,\n cols,\n children,\n rows,\n gutter,\n justify,\n wrap,\n width,\n height,\n innerRef,\n span,\n ...rest\n },\n globalProps,\n xstyledProps,\n isSpanParent,\n renderChildren,\n } = useGrid(props);\n\n // xsmall was added after the initial implementation, so we need to make sure it's always present\n // to avoid breaking changes.\n\n const correctSpan = useMemo(() => {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React, { useMemo } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { useGetLayoutMode } from '@elliemae/ds-system';\nimport type { DSGridT } from './react-desc-prop-types.js';\nimport { DSCardHeaderPropTypesSchema } from './react-desc-prop-types.js';\nimport { GridItem } from './GridItem.js';\nimport { useGrid } from './config/useGrid.js';\nimport { DSGridName } from './DSGridDefinitions.js';\nimport { resolveByLayoutMode, type LayoutMode } from './utils/resolveLayoutMode.js';\n\nconst Grid = React.forwardRef<HTMLDivElement, DSGridT.Props>((props, ref) => {\n const {\n propsWithDefaults: {\n withMaxWidthBreakpoints,\n alignItems,\n cols,\n children,\n rows,\n gutter,\n justify,\n wrap,\n width,\n height,\n innerRef,\n span,\n withLayoutMode,\n ...rest\n },\n globalProps,\n xstyledProps,\n isSpanParent,\n renderChildren,\n } = useGrid(props);\n\n // When withLayoutMode is opted into, the Grid resolves its responsive definitions from the\n // ancestor DSLayoutProvider's layoutMode instead of the viewport. resolveByLayoutMode is a\n // no-op when there is no layoutMode in context, so this stays safe outside a provider.\n const layoutMode = useGetLayoutMode() as LayoutMode | undefined;\n\n // xsmall was added after the initial implementation, so we need to make sure it's always present\n // to avoid breaking changes. The xsmall backfill runs first so layoutMode=\"xs\" can pick it up.\n\n const correctSpan = useMemo(() => {\n const backfilled =\n span && typeof span !== 'number' && span.small && !span.xsmall ? { ...span, xsmall: span.small } : span;\n return withLayoutMode ? resolveByLayoutMode(backfilled, layoutMode) : backfilled;\n }, [span, withLayoutMode, layoutMode]);\n\n const correctCols = useMemo(() => {\n const backfilled =\n typeof cols === 'object' && !Array.isArray(cols) && cols.small && !cols.xsmall\n ? { ...cols, xsmall: cols.small }\n : cols;\n return withLayoutMode ? resolveByLayoutMode(backfilled, layoutMode) : backfilled;\n }, [cols, withLayoutMode, layoutMode]);\n\n const correctRows = useMemo(() => {\n const backfilled =\n typeof rows === 'object' && !Array.isArray(rows) && rows.small && !rows.xsmall\n ? { ...rows, xsmall: rows.small }\n : rows;\n return withLayoutMode ? resolveByLayoutMode(backfilled, layoutMode) : backfilled;\n }, [rows, withLayoutMode, layoutMode]);\n\n return (\n <GridItem\n {...rest}\n {...globalProps}\n {...xstyledProps}\n span={correctSpan}\n alignItems={alignItems}\n cols={correctCols}\n gutter={gutter}\n isSpanParent={isSpanParent}\n justify={justify}\n rows={correctRows}\n wrap={wrap}\n childNumber={React.Children.count(children)}\n innerRef={innerRef ?? ref}\n w={width}\n h={height}\n withMaxWidthBreakpoints={withMaxWidthBreakpoints}\n >\n {renderChildren}\n </GridItem>\n );\n});\n\n// Since this component is using ForwardRef, we must provide a displayName to avoid 'undefined' name in propsTable.\nGrid.displayName = DSGridName;\nconst DSGridWithSchema = describe(Grid);\nDSGridWithSchema.propTypes = DSCardHeaderPropTypesSchema;\n\nexport default Grid;\nexport { DSGridWithSchema, Grid };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADiEnB;AAjEJ,mBAA+B;AAC/B,8BAAyB;AACzB,uBAAiC;AAEjC,mCAA4C;AAC5C,sBAAyB;AACzB,qBAAwB;AACxB,+BAA2B;AAC3B,+BAAqD;AAErD,MAAM,OAAO,aAAAA,QAAM,WAA0C,CAAC,OAAO,QAAQ;AAC3E,QAAM;AAAA,IACJ,mBAAmB;AAAA,MACjB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,wBAAQ,KAAK;AAKjB,QAAM,iBAAa,mCAAiB;AAKpC,QAAM,kBAAc,sBAAQ,MAAM;AAChC,UAAM,aACJ,QAAQ,OAAO,SAAS,YAAY,KAAK,SAAS,CAAC,KAAK,SAAS,EAAE,GAAG,MAAM,QAAQ,KAAK,MAAM,IAAI;AACrG,WAAO,qBAAiB,8CAAoB,YAAY,UAAU,IAAI;AAAA,EACxE,GAAG,CAAC,MAAM,gBAAgB,UAAU,CAAC;AAErC,QAAM,kBAAc,sBAAQ,MAAM;AAChC,UAAM,aACJ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,KAAK,KAAK,SAAS,CAAC,KAAK,SACpE,EAAE,GAAG,MAAM,QAAQ,KAAK,MAAM,IAC9B;AACN,WAAO,qBAAiB,8CAAoB,YAAY,UAAU,IAAI;AAAA,EACxE,GAAG,CAAC,MAAM,gBAAgB,UAAU,CAAC;AAErC,QAAM,kBAAc,sBAAQ,MAAM;AAChC,UAAM,aACJ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,KAAK,KAAK,SAAS,CAAC,KAAK,SACpE,EAAE,GAAG,MAAM,QAAQ,KAAK,MAAM,IAC9B;AACN,WAAO,qBAAiB,8CAAoB,YAAY,UAAU,IAAI;AAAA,EACxE,GAAG,CAAC,MAAM,gBAAgB,UAAU,CAAC;AAErC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACJ,MAAM;AAAA,MACN;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA,aAAa,aAAAA,QAAM,SAAS,MAAM,QAAQ;AAAA,MAC1C,UAAU,YAAY;AAAA,MACtB,GAAG;AAAA,MACH,GAAG;AAAA,MACH;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ,CAAC;AAGD,KAAK,cAAc;AACnB,MAAM,uBAAmB,kCAAS,IAAI;AACtC,iBAAiB,YAAY;AAE7B,IAAO,eAAQ;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -86,6 +86,7 @@ const DSGridPropTypes = {
|
|
|
86
86
|
innerRef: import_ds_props_helpers.PropTypes.oneOfType([import_ds_props_helpers.PropTypes.func, import_ds_props_helpers.PropTypes.object]).description("Ref to the grid"),
|
|
87
87
|
wrap: import_ds_props_helpers.PropTypes.oneOf(import_constants.wrap).description("Wrap type").defaultValue(import_constants.wrap[0]),
|
|
88
88
|
withMaxWidthBreakpoints: import_ds_props_helpers.PropTypes.bool.description("weather use max width").defaultValue(void 0),
|
|
89
|
+
withLayoutMode: import_ds_props_helpers.PropTypes.bool.description("Resolve responsive cols/rows/span from the ancestor DSLayoutProvider mode.").defaultValue(void 0),
|
|
89
90
|
height: import_ds_props_helpers.PropTypes.oneOfType([import_ds_props_helpers.PropTypes.number, import_ds_props_helpers.PropTypes.string]).description("Grid height."),
|
|
90
91
|
width: import_ds_props_helpers.PropTypes.oneOfType([import_ds_props_helpers.PropTypes.number, import_ds_props_helpers.PropTypes.string]).description("Grid width."),
|
|
91
92
|
backgroundColor: import_ds_props_helpers.PropTypes.string.description("Sets background color."),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react-desc-prop-types.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import type { WeakValidationMap } from 'react';\nimport type React from 'react';\nimport type { GlobalAttributesT, XstyledProps, DSPropTypesSchema } from '@elliemae/ds-props-helpers';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\nimport { alignItemsPlacement, justifyPlacement, wrap, boxShadow } from './utils/constants.js';\n\nexport declare namespace DSGridT {\n export type RowOrColsSyntaxSugar = string | number | (string | number)[];\n\n export interface RowColBreakpoints {\n xsmall?: RowOrColsSyntaxSugar[];\n small?: RowOrColsSyntaxSugar[];\n medium?: RowOrColsSyntaxSugar[];\n large?: RowOrColsSyntaxSugar[];\n }\n\n export type RowOrColsValidValues = RowOrColsSyntaxSugar | RowColBreakpoints;\n\n export interface SpanBreakpoints {\n xsmall?: number;\n small?: number;\n medium?: number;\n large?: number;\n }\n\n export type JustifyPlacement =\n | 'flex-start'\n | 'center'\n | 'flex-end'\n | 'space-between'\n | 'space-around'\n | 'space-evenly';\n export type AlignItemsPlacement = 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline' | 'space-between';\n export type Wrap = 'wrap' | 'nowrap' | 'wrap-reverse';\n export type BoxShadow = 'xs' | 's' | 'm' | 'l' | 'xl';\n\n export interface RequiredProps {}\n\n export interface DefaultProps {\n rows: RowOrColsValidValues;\n cols: RowOrColsValidValues;\n className: string;\n justify: JustifyPlacement;\n wrap: Wrap;\n span: number | SpanBreakpoints;\n justifyItems: string;\n }\n\n export interface OptionalProps {\n height?: string | number;\n width?: string | number;\n justifyContent?: JustifyPlacement;\n alignItems?: AlignItemsPlacement;\n alignContent?: AlignItemsPlacement;\n children?: React.ReactNode;\n withMaxWidthBreakpoints?: boolean;\n rowGap?: string | number;\n gutter?: string | number;\n innerRef?: React.MutableRefObject<HTMLDivElement | null> | React.RefCallback<HTMLDivElement>;\n }\n\n // Grid components override some of the global attributes,\n // components inheriting from Grid needs a way to exclude these attributes from GlobalAttributesT\n // in such scenario, they would do\n // Omit<\n // GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps\n // ^ their's namespace own DefaultProps | OptionalProps | ...\n // | keyof GridSpecificGlobalAttributes\n // ^ Grid's overrides\n // >\n // This way, the component will have all the global attributes except the ones that are overridden by Grid and by the component itself\n // in one line: Omit<GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps [ | ... ] | keyof GridSpecificGlobalAttributes>\n export type GridSpecificGlobalAttributes = Omit<\n GlobalAttributesT<HTMLDivElement>,\n keyof DefaultProps | keyof OptionalProps | keyof XstyledProps\n >;\n export type GridSpecificGlobalAttributesGeneric<ElementType = HTMLDivElement> = Omit<\n GlobalAttributesT<ElementType>,\n keyof DefaultProps | keyof OptionalProps | keyof XstyledProps\n >;\n\n export interface Props extends Partial<DefaultProps>, OptionalProps, GridSpecificGlobalAttributes, XstyledProps {}\n\n export interface InternalProps extends DefaultProps, OptionalProps, GridSpecificGlobalAttributes, XstyledProps {}\n\n export interface ItemProps {\n rows: RowOrColsValidValues;\n cols: RowOrColsValidValues;\n alignItems?: AlignItemsPlacement;\n alignContent?: AlignItemsPlacement;\n children: React.ReactNode;\n className?: string;\n justify: JustifyPlacement;\n gutter?: string | number;\n wrap: Wrap;\n childNumber: number;\n isSpanParent: boolean;\n span?: number | SpanBreakpoints;\n withMaxWidthBreakpoints?: boolean;\n }\n}\n\nexport const defaultProps: DSGridT.DefaultProps = {\n rows: [],\n cols: [],\n className: '',\n justify: 'flex-start',\n wrap: 'wrap',\n span: 1,\n justifyItems: 'normal',\n};\n\n// =============================================================================\n// PropTypes\n// =============================================================================\nconst rowColBreakpoints = PropTypes.shape({\n xsmall: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n small: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n medium: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n large: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n});\n\nconst spanBreakpoints = PropTypes.shape({\n xsmall: PropTypes.number,\n small: PropTypes.number,\n medium: PropTypes.number,\n large: PropTypes.number,\n});\n\nexport const DSGridPropTypes: DSPropTypesSchema<DSGridT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n rows: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n PropTypes.number,\n rowColBreakpoints,\n ])\n .description('Row layout cells')\n .defaultValue([]),\n cols: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n PropTypes.number,\n rowColBreakpoints,\n ])\n .description('Column layout cells')\n .defaultValue([]),\n span: PropTypes.oneOfType([PropTypes.number, spanBreakpoints]).description(\n 'Expands the grid element within columns.',\n ),\n alignItems: PropTypes.oneOf(alignItemsPlacement).description('flex-like align items prop'),\n children: PropTypes.node.description('Children node inside grid cell'),\n className: PropTypes.string.description('CSS class').defaultValue(''),\n justifyContent: PropTypes.oneOf(justifyPlacement)\n .description('flex-like justify prop')\n .defaultValue(justifyPlacement[0]),\n gutter: PropTypes.oneOfType([PropTypes.number, PropTypes.string])\n .description('Space between cells prop')\n .defaultValue(0),\n justify: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n justifyItems: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n alignContent: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n rowGap: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Ref to the grid'),\n wrap: PropTypes.oneOf(wrap).description('Wrap type').defaultValue(wrap[0]),\n withMaxWidthBreakpoints: PropTypes.bool.description('weather use max width').defaultValue(undefined),\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid height.'),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid width.'),\n backgroundColor: PropTypes.string.description('Sets background color.'),\n bg: PropTypes.string.description('Sets background color.'),\n boxShadow: PropTypes.oneOf(boxShadow).description('Sets background color.'),\n border: PropTypes.string.description('Sets border.'),\n borderRadius: PropTypes.string.description('Sets border radius.'),\n borderWidth: PropTypes.string.description('Sets border width.'),\n borderStyle: PropTypes.string.description('Sets border style.'),\n borderColor: PropTypes.string.description('Sets border color.'),\n borderTop: PropTypes.string.description('Sets top border.'),\n borderBottom: PropTypes.string.description('Sets bottom border.'),\n borderLeft: PropTypes.string.description('Sets left border.'),\n borderRight: PropTypes.string.description('Sets right border.'),\n borderTopWidth: PropTypes.string.description('Sets border top width.'),\n borderTopStyle: PropTypes.string.description('Sets border top style.'),\n borderTopColor: PropTypes.string.description('Sets border top color.'),\n borderBottomWidth: PropTypes.string.description('Sets border bottom width.'),\n borderBottomStyle: PropTypes.string.description('Sets border bottom style.'),\n borderBottomColor: PropTypes.string.description('Sets border bottom color.'),\n borderRightWidth: PropTypes.string.description('Sets border right width.'),\n borderRightStyle: PropTypes.string.description('Sets border right style.'),\n borderRightColor: PropTypes.string.description('Sets border right color.'),\n borderLeftWidth: PropTypes.string.description('Sets border left width.'),\n borderLeftStyle: PropTypes.string.description('Sets border left style.'),\n borderLeftColor: PropTypes.string.description('Sets border left color.'),\n};\n\nexport const DSCardHeaderPropTypesSchema = DSGridPropTypes as unknown as WeakValidationMap<DSGridT.Props>;\n\nexport const getGridProps = (props: unknown): Partial<DSGridT.Props> => {\n if (typeof props !== 'object' || props === null) return {};\n const innerProps = props as Record<string, unknown>;\n const innerGridPropTypes = props as Record<keyof DSGridT.Props, unknown>;\n const filteredProps: Partial<DSGridT.Props> = {};\n\n Object.keys(innerProps).forEach((key) => {\n const innerKey = key as keyof DSGridT.Props;\n if (innerGridPropTypes[innerKey] && innerProps[innerKey] !== undefined) {\n filteredProps[innerKey] = innerProps[innerKey];\n }\n });\n return filteredProps;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,8BAAuE;AACvE,uBAAuE;
|
|
4
|
+
"sourcesContent": ["import type { WeakValidationMap } from 'react';\nimport type React from 'react';\nimport type { GlobalAttributesT, XstyledProps, DSPropTypesSchema } from '@elliemae/ds-props-helpers';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\nimport { alignItemsPlacement, justifyPlacement, wrap, boxShadow } from './utils/constants.js';\n\nexport declare namespace DSGridT {\n export type RowOrColsSyntaxSugar = string | number | (string | number)[];\n\n export interface RowColBreakpoints {\n xsmall?: RowOrColsSyntaxSugar[];\n small?: RowOrColsSyntaxSugar[];\n medium?: RowOrColsSyntaxSugar[];\n large?: RowOrColsSyntaxSugar[];\n }\n\n export type RowOrColsValidValues = RowOrColsSyntaxSugar | RowColBreakpoints;\n\n export interface SpanBreakpoints {\n xsmall?: number;\n small?: number;\n medium?: number;\n large?: number;\n }\n\n export type JustifyPlacement =\n | 'flex-start'\n | 'center'\n | 'flex-end'\n | 'space-between'\n | 'space-around'\n | 'space-evenly';\n export type AlignItemsPlacement = 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline' | 'space-between';\n export type Wrap = 'wrap' | 'nowrap' | 'wrap-reverse';\n export type BoxShadow = 'xs' | 's' | 'm' | 'l' | 'xl';\n\n export interface RequiredProps {}\n\n export interface DefaultProps {\n rows: RowOrColsValidValues;\n cols: RowOrColsValidValues;\n className: string;\n justify: JustifyPlacement;\n wrap: Wrap;\n span: number | SpanBreakpoints;\n justifyItems: string;\n }\n\n export interface OptionalProps {\n height?: string | number;\n width?: string | number;\n justifyContent?: JustifyPlacement;\n alignItems?: AlignItemsPlacement;\n alignContent?: AlignItemsPlacement;\n children?: React.ReactNode;\n withMaxWidthBreakpoints?: boolean;\n withLayoutMode?: boolean;\n rowGap?: string | number;\n gutter?: string | number;\n innerRef?: React.MutableRefObject<HTMLDivElement | null> | React.RefCallback<HTMLDivElement>;\n }\n\n // Grid components override some of the global attributes,\n // components inheriting from Grid needs a way to exclude these attributes from GlobalAttributesT\n // in such scenario, they would do\n // Omit<\n // GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps\n // ^ their's namespace own DefaultProps | OptionalProps | ...\n // | keyof GridSpecificGlobalAttributes\n // ^ Grid's overrides\n // >\n // This way, the component will have all the global attributes except the ones that are overridden by Grid and by the component itself\n // in one line: Omit<GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps [ | ... ] | keyof GridSpecificGlobalAttributes>\n export type GridSpecificGlobalAttributes = Omit<\n GlobalAttributesT<HTMLDivElement>,\n keyof DefaultProps | keyof OptionalProps | keyof XstyledProps\n >;\n export type GridSpecificGlobalAttributesGeneric<ElementType = HTMLDivElement> = Omit<\n GlobalAttributesT<ElementType>,\n keyof DefaultProps | keyof OptionalProps | keyof XstyledProps\n >;\n\n export interface Props extends Partial<DefaultProps>, OptionalProps, GridSpecificGlobalAttributes, XstyledProps {}\n\n export interface InternalProps extends DefaultProps, OptionalProps, GridSpecificGlobalAttributes, XstyledProps {}\n\n export interface ItemProps {\n rows: RowOrColsValidValues;\n cols: RowOrColsValidValues;\n alignItems?: AlignItemsPlacement;\n alignContent?: AlignItemsPlacement;\n children: React.ReactNode;\n className?: string;\n justify: JustifyPlacement;\n gutter?: string | number;\n wrap: Wrap;\n childNumber: number;\n isSpanParent: boolean;\n span?: number | SpanBreakpoints;\n withMaxWidthBreakpoints?: boolean;\n }\n}\n\nexport const defaultProps: DSGridT.DefaultProps = {\n rows: [],\n cols: [],\n className: '',\n justify: 'flex-start',\n wrap: 'wrap',\n span: 1,\n justifyItems: 'normal',\n};\n\n// =============================================================================\n// PropTypes\n// =============================================================================\nconst rowColBreakpoints = PropTypes.shape({\n xsmall: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n small: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n medium: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n large: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n});\n\nconst spanBreakpoints = PropTypes.shape({\n xsmall: PropTypes.number,\n small: PropTypes.number,\n medium: PropTypes.number,\n large: PropTypes.number,\n});\n\nexport const DSGridPropTypes: DSPropTypesSchema<DSGridT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n rows: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n PropTypes.number,\n rowColBreakpoints,\n ])\n .description('Row layout cells')\n .defaultValue([]),\n cols: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n PropTypes.number,\n rowColBreakpoints,\n ])\n .description('Column layout cells')\n .defaultValue([]),\n span: PropTypes.oneOfType([PropTypes.number, spanBreakpoints]).description(\n 'Expands the grid element within columns.',\n ),\n alignItems: PropTypes.oneOf(alignItemsPlacement).description('flex-like align items prop'),\n children: PropTypes.node.description('Children node inside grid cell'),\n className: PropTypes.string.description('CSS class').defaultValue(''),\n justifyContent: PropTypes.oneOf(justifyPlacement)\n .description('flex-like justify prop')\n .defaultValue(justifyPlacement[0]),\n gutter: PropTypes.oneOfType([PropTypes.number, PropTypes.string])\n .description('Space between cells prop')\n .defaultValue(0),\n justify: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n justifyItems: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n alignContent: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n rowGap: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Ref to the grid'),\n wrap: PropTypes.oneOf(wrap).description('Wrap type').defaultValue(wrap[0]),\n withMaxWidthBreakpoints: PropTypes.bool.description('weather use max width').defaultValue(undefined),\n withLayoutMode: PropTypes.bool\n .description('Resolve responsive cols/rows/span from the ancestor DSLayoutProvider mode.')\n .defaultValue(undefined),\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid height.'),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid width.'),\n backgroundColor: PropTypes.string.description('Sets background color.'),\n bg: PropTypes.string.description('Sets background color.'),\n boxShadow: PropTypes.oneOf(boxShadow).description('Sets background color.'),\n border: PropTypes.string.description('Sets border.'),\n borderRadius: PropTypes.string.description('Sets border radius.'),\n borderWidth: PropTypes.string.description('Sets border width.'),\n borderStyle: PropTypes.string.description('Sets border style.'),\n borderColor: PropTypes.string.description('Sets border color.'),\n borderTop: PropTypes.string.description('Sets top border.'),\n borderBottom: PropTypes.string.description('Sets bottom border.'),\n borderLeft: PropTypes.string.description('Sets left border.'),\n borderRight: PropTypes.string.description('Sets right border.'),\n borderTopWidth: PropTypes.string.description('Sets border top width.'),\n borderTopStyle: PropTypes.string.description('Sets border top style.'),\n borderTopColor: PropTypes.string.description('Sets border top color.'),\n borderBottomWidth: PropTypes.string.description('Sets border bottom width.'),\n borderBottomStyle: PropTypes.string.description('Sets border bottom style.'),\n borderBottomColor: PropTypes.string.description('Sets border bottom color.'),\n borderRightWidth: PropTypes.string.description('Sets border right width.'),\n borderRightStyle: PropTypes.string.description('Sets border right style.'),\n borderRightColor: PropTypes.string.description('Sets border right color.'),\n borderLeftWidth: PropTypes.string.description('Sets border left width.'),\n borderLeftStyle: PropTypes.string.description('Sets border left style.'),\n borderLeftColor: PropTypes.string.description('Sets border left color.'),\n};\n\nexport const DSCardHeaderPropTypesSchema = DSGridPropTypes as unknown as WeakValidationMap<DSGridT.Props>;\n\nexport const getGridProps = (props: unknown): Partial<DSGridT.Props> => {\n if (typeof props !== 'object' || props === null) return {};\n const innerProps = props as Record<string, unknown>;\n const innerGridPropTypes = props as Record<keyof DSGridT.Props, unknown>;\n const filteredProps: Partial<DSGridT.Props> = {};\n\n Object.keys(innerProps).forEach((key) => {\n const innerKey = key as keyof DSGridT.Props;\n if (innerGridPropTypes[innerKey] && innerProps[innerKey] !== undefined) {\n filteredProps[innerKey] = innerProps[innerKey];\n }\n });\n return filteredProps;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,8BAAuE;AACvE,uBAAuE;AAmGhE,MAAM,eAAqC;AAAA,EAChD,MAAM,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,WAAW;AAAA,EACX,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,cAAc;AAChB;AAKA,MAAM,oBAAoB,kCAAU,MAAM;AAAA,EACxC,QAAQ,kCAAU,QAAQ,kCAAU,UAAU,CAAC,kC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B,QAAQ,KAAK,WAAW,QAAQ,MAAM,QAAW;AACtE,oBAAc,QAAQ,IAAI,WAAW,QAAQ;AAAA,IAC/C;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/typescript-grid-valid.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { Grid } from '../index.js';\nimport type { DSGridT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSGridT.Props;\ntype ComponentPropsInternals = DSGridT.InternalProps;\ntype ComponentPropsDefaultProps = DSGridT.DefaultProps;\ntype ComponentPropsOptionalProps = DSGridT.OptionalProps;\ntype ComponentPropsRequiredProps = DSGridT.RequiredProps;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {};\nconst testOptionalProps: ComponentPropsOptionalProps = {\n height: 0,\n width: 0,\n justifyContent: 'flex-start',\n alignItems: 'flex-start',\n children: <div>hey</div>,\n withMaxWidthBreakpoints: false,\n rowGap: 'xs',\n gutter: 'xs',\n};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n rows: [],\n cols: [],\n span: 2,\n justifyItems: 'flex-start',\n};\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n};\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n rows: [],\n cols: [],\n span: 2,\n justifyItems: 'flex-start',\n className: '',\n justify: 'flex-start',\n wrap: 'nowrap',\n};\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n};\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n cols: { small: ['1fr', '1fr', '1fr'], medium: ['5fr', '1fr', '1fr'], large: ['1fr', '4fr', '1fr'] },\n rows: { small: ['1fr', '1fr', '1fr'], medium: ['5fr', '1fr', '1fr'], large: ['1fr', '4fr', '1fr'] },\n span: { small: 2, medium: 3, large: 1 },\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n rows: [1, 2, 3],\n justifyContent: 'center',\n border: '1px solid black',\n} as ComponentPropsForApp;\n\nconst testDefinitionAsConst = {\n alignItems: 'center',\n gutter: 'xs',\n bg: 'brand-100',\n borderTopColor: 'neutral-100-a10',\n borderLeftColor: '#141414',\n borderRightColor: 'rgba(0,0,0,0.5)',\n borderBottomColor: 'rgb(0,0,0)',\n} as const;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <Grid {...testExplicitDefinition} />\n <Grid {...testInferedTypeCompatibility} />\n <Grid {...testDefinitionAsConst} />\n {/* works with inline values */}\n <Grid rows={[1, 2, 3]} justifyContent=\"center\" border=\"1px solid black\" />\n </>\n);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACiBX;AAhBZ,eAAqB;AAUrB,MAAM,oBAAiD,CAAC;AACxD,MAAM,oBAAiD;AAAA,EACrD,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,UAAU,4CAAC,SAAI,iBAAG;AAAA,EAClB,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mB;AACrB;AAEA,MAAM,wBAAwB,MAC5B,4EAEE;AAAA,8CAAC,iBAAM,GAAG,wBAAwB;AAAA,EAClC,4CAAC,iBAAM,GAAG,8BAA8B;AAAA,EACxC,4CAAC,iBAAM,GAAG,uBAAuB;AAAA,EAEjC,4CAAC,iBAAK,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,gBAAe,UAAS,QAAO,mBAAkB;AAAA,GAC1E;",
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { Grid } from '../index.js';\nimport type { DSGridT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSGridT.Props;\ntype ComponentPropsInternals = DSGridT.InternalProps;\ntype ComponentPropsDefaultProps = DSGridT.DefaultProps;\ntype ComponentPropsOptionalProps = DSGridT.OptionalProps;\ntype ComponentPropsRequiredProps = DSGridT.RequiredProps;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {};\nconst testOptionalProps: ComponentPropsOptionalProps = {\n height: 0,\n width: 0,\n justifyContent: 'flex-start',\n alignItems: 'flex-start',\n children: <div>hey</div>,\n withMaxWidthBreakpoints: false,\n withLayoutMode: true,\n rowGap: 'xs',\n gutter: 'xs',\n};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n rows: [],\n cols: [],\n span: 2,\n justifyItems: 'flex-start',\n};\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n};\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n rows: [],\n cols: [],\n span: 2,\n justifyItems: 'flex-start',\n className: '',\n justify: 'flex-start',\n wrap: 'nowrap',\n};\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n};\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n cols: { small: ['1fr', '1fr', '1fr'], medium: ['5fr', '1fr', '1fr'], large: ['1fr', '4fr', '1fr'] },\n rows: { small: ['1fr', '1fr', '1fr'], medium: ['5fr', '1fr', '1fr'], large: ['1fr', '4fr', '1fr'] },\n span: { small: 2, medium: 3, large: 1 },\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n rows: [1, 2, 3],\n justifyContent: 'center',\n border: '1px solid black',\n} as ComponentPropsForApp;\n\nconst testDefinitionAsConst = {\n alignItems: 'center',\n gutter: 'xs',\n bg: 'brand-100',\n borderTopColor: 'neutral-100-a10',\n borderLeftColor: '#141414',\n borderRightColor: 'rgba(0,0,0,0.5)',\n borderBottomColor: 'rgb(0,0,0)',\n} as const;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <Grid {...testExplicitDefinition} />\n <Grid {...testInferedTypeCompatibility} />\n <Grid {...testDefinitionAsConst} />\n {/* works with inline values */}\n <Grid rows={[1, 2, 3]} justifyContent=\"center\" border=\"1px solid black\" />\n </>\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACiBX;AAhBZ,eAAqB;AAUrB,MAAM,oBAAiD,CAAC;AACxD,MAAM,oBAAiD;AAAA,EACrD,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,UAAU,4CAAC,SAAI,iBAAG;AAAA,EAClB,yBAAyB;AAAA,EACzB,g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B;AACrB;AAEA,MAAM,wBAAwB,MAC5B,4EAEE;AAAA,8CAAC,iBAAM,GAAG,wBAAwB;AAAA,EAClC,4CAAC,iBAAM,GAAG,8BAA8B;AAAA,EACxC,4CAAC,iBAAM,GAAG,uBAAuB;AAAA,EAEjC,4CAAC,iBAAK,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,gBAAe,UAAS,QAAO,mBAAkB;AAAA,GAC1E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var resolveLayoutMode_exports = {};
|
|
30
|
+
__export(resolveLayoutMode_exports, {
|
|
31
|
+
BREAKPOINT_ORDER: () => BREAKPOINT_ORDER,
|
|
32
|
+
LAYOUT_MODE_TO_BREAKPOINT: () => LAYOUT_MODE_TO_BREAKPOINT,
|
|
33
|
+
resolveByLayoutMode: () => resolveByLayoutMode
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(resolveLayoutMode_exports);
|
|
36
|
+
var React = __toESM(require("react"));
|
|
37
|
+
const LAYOUT_MODE_TO_BREAKPOINT = {
|
|
38
|
+
xs: "xsmall",
|
|
39
|
+
s: "small",
|
|
40
|
+
m: "medium",
|
|
41
|
+
l: "large"
|
|
42
|
+
};
|
|
43
|
+
const BREAKPOINT_ORDER = ["xsmall", "small", "medium", "large"];
|
|
44
|
+
const isBreakpointObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
45
|
+
const pickForLayoutMode = (value, layoutMode) => {
|
|
46
|
+
const targetIndex = BREAKPOINT_ORDER.indexOf(LAYOUT_MODE_TO_BREAKPOINT[layoutMode]);
|
|
47
|
+
if (targetIndex < 0) return value;
|
|
48
|
+
for (let i = targetIndex; i >= 0; i -= 1) {
|
|
49
|
+
const candidate = value[BREAKPOINT_ORDER[i]];
|
|
50
|
+
if (candidate !== void 0) return candidate;
|
|
51
|
+
}
|
|
52
|
+
for (let i = targetIndex + 1; i < BREAKPOINT_ORDER.length; i += 1) {
|
|
53
|
+
const candidate = value[BREAKPOINT_ORDER[i]];
|
|
54
|
+
if (candidate !== void 0) return candidate;
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
};
|
|
58
|
+
function resolveByLayoutMode(value, layoutMode) {
|
|
59
|
+
if (!layoutMode || !isBreakpointObject(value)) return value;
|
|
60
|
+
return pickForLayoutMode(value, layoutMode);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=resolveLayoutMode.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/resolveLayoutMode.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import type { DSGridT } from '../react-desc-prop-types.js';\n\n// The layout modes exposed by DSLayoutProvider (injected into the styled-components theme\n// and read via useGetLayoutMode from @elliemae/ds-system). Kept as a local literal union so\n// ds-grid does not take a (type or runtime) dependency on ds-layout-provider.\nexport type LayoutMode = 'xs' | 's' | 'm' | 'l';\n\n// The breakpoint keys a Grid cols/rows/span definition may declare.\ntype BreakpointKey = keyof DSGridT.RowColBreakpoints;\n\n// Clean 4 -> 4 mapping between a LayoutProvider mode and the Grid breakpoint it selects.\nexport const LAYOUT_MODE_TO_BREAKPOINT: Record<LayoutMode, BreakpointKey> = {\n xs: 'xsmall',\n s: 'small',\n m: 'medium',\n l: 'large',\n};\n\n// Ordered smallest -> largest. Used for the partial-definition fallback below.\nexport const BREAKPOINT_ORDER: BreakpointKey[] = ['xsmall', 'small', 'medium', 'large'];\n\n// A breakpoint definition is an object that is not an array (arrays are the \"flat\" cols/rows\n// syntax and numbers/strings are scalar definitions - none of those are layoutMode-driven).\nconst isBreakpointObject = (value: unknown): value is Partial<Record<BreakpointKey, unknown>> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst pickForLayoutMode = (value: Partial<Record<BreakpointKey, unknown>>, layoutMode: LayoutMode): unknown => {\n const targetIndex = BREAKPOINT_ORDER.indexOf(LAYOUT_MODE_TO_BREAKPOINT[layoutMode]);\n // Unknown / unsupported mode -> leave the definition untouched.\n if (targetIndex < 0) return value;\n\n // Breakpoint objects may be partial (e.g. only { small, large } defined). We resolve to a\n // single predictable value: the exact key if present, otherwise the nearest DEFINED key\n // walking down toward xsmall, and only then the nearest one walking up toward large.\n for (let i = targetIndex; i >= 0; i -= 1) {\n const candidate = value[BREAKPOINT_ORDER[i]];\n if (candidate !== undefined) return candidate;\n }\n for (let i = targetIndex + 1; i < BREAKPOINT_ORDER.length; i += 1) {\n const candidate = value[BREAKPOINT_ORDER[i]];\n if (candidate !== undefined) return candidate;\n }\n // The object declared no usable breakpoint -> no-op.\n return value;\n};\n\n/**\n * Collapse a responsive cols/rows/span definition down to the single value selected by the\n * ancestor DSLayoutProvider's layoutMode, so the Grid lays out for the container it lives in\n * instead of the viewport.\n *\n * Only breakpoint OBJECTS are affected: arrays, numbers and strings pass through untouched, and\n * when there is no layoutMode in context we return the value as-is so the Grid keeps its\n * existing viewport (media-query) behavior. This is what makes the feature safe and opt-in.\n */\nexport function resolveByLayoutMode(\n value: DSGridT.RowOrColsValidValues,\n layoutMode: LayoutMode | undefined,\n): DSGridT.RowOrColsValidValues;\nexport function resolveByLayoutMode(\n value: number | DSGridT.SpanBreakpoints,\n layoutMode: LayoutMode | undefined,\n): number | DSGridT.SpanBreakpoints;\nexport function resolveByLayoutMode(value: unknown, layoutMode: LayoutMode | undefined): unknown {\n if (!layoutMode || !isBreakpointObject(value)) return value;\n return pickForLayoutMode(value, layoutMode);\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADWhB,MAAM,4BAA+D;AAAA,EAC1E,IAAI;AAAA,EACJ,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAGO,MAAM,mBAAoC,CAAC,UAAU,SAAS,UAAU,OAAO;AAItF,MAAM,qBAAqB,CAAC,UAC1B,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAM,oBAAoB,CAAC,OAAgD,eAAoC;AAC7G,QAAM,cAAc,iBAAiB,QAAQ,0BAA0B,UAAU,CAAC;AAElF,MAAI,cAAc,EAAG,QAAO;AAK5B,WAAS,IAAI,aAAa,KAAK,GAAG,KAAK,GAAG;AACxC,UAAM,YAAY,MAAM,iBAAiB,CAAC,CAAC;AAC3C,QAAI,cAAc,OAAW,QAAO;AAAA,EACtC;AACA,WAAS,IAAI,cAAc,GAAG,IAAI,iBAAiB,QAAQ,KAAK,GAAG;AACjE,UAAM,YAAY,MAAM,iBAAiB,CAAC,CAAC;AAC3C,QAAI,cAAc,OAAW,QAAO;AAAA,EACtC;AAEA,SAAO;AACT;AAmBO,SAAS,oBAAoB,OAAgB,YAA6C;AAC/F,MAAI,CAAC,cAAc,CAAC,mBAAmB,KAAK,EAAG,QAAO;AACtD,SAAO,kBAAkB,OAAO,UAAU;AAC5C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/Grid.js
CHANGED
|
@@ -2,10 +2,12 @@ import * as React from "react";
|
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import React2, { useMemo } from "react";
|
|
4
4
|
import { describe } from "@elliemae/ds-props-helpers";
|
|
5
|
+
import { useGetLayoutMode } from "@elliemae/ds-system";
|
|
5
6
|
import { DSCardHeaderPropTypesSchema } from "./react-desc-prop-types.js";
|
|
6
7
|
import { GridItem } from "./GridItem.js";
|
|
7
8
|
import { useGrid } from "./config/useGrid.js";
|
|
8
9
|
import { DSGridName } from "./DSGridDefinitions.js";
|
|
10
|
+
import { resolveByLayoutMode } from "./utils/resolveLayoutMode.js";
|
|
9
11
|
const Grid = React2.forwardRef((props, ref) => {
|
|
10
12
|
const {
|
|
11
13
|
propsWithDefaults: {
|
|
@@ -21,6 +23,7 @@ const Grid = React2.forwardRef((props, ref) => {
|
|
|
21
23
|
height,
|
|
22
24
|
innerRef,
|
|
23
25
|
span,
|
|
26
|
+
withLayoutMode,
|
|
24
27
|
...rest
|
|
25
28
|
},
|
|
26
29
|
globalProps,
|
|
@@ -28,24 +31,19 @@ const Grid = React2.forwardRef((props, ref) => {
|
|
|
28
31
|
isSpanParent,
|
|
29
32
|
renderChildren
|
|
30
33
|
} = useGrid(props);
|
|
34
|
+
const layoutMode = useGetLayoutMode();
|
|
31
35
|
const correctSpan = useMemo(() => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return span;
|
|
36
|
-
}, [span]);
|
|
36
|
+
const backfilled = span && typeof span !== "number" && span.small && !span.xsmall ? { ...span, xsmall: span.small } : span;
|
|
37
|
+
return withLayoutMode ? resolveByLayoutMode(backfilled, layoutMode) : backfilled;
|
|
38
|
+
}, [span, withLayoutMode, layoutMode]);
|
|
37
39
|
const correctCols = useMemo(() => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return cols;
|
|
42
|
-
}, [cols]);
|
|
40
|
+
const backfilled = typeof cols === "object" && !Array.isArray(cols) && cols.small && !cols.xsmall ? { ...cols, xsmall: cols.small } : cols;
|
|
41
|
+
return withLayoutMode ? resolveByLayoutMode(backfilled, layoutMode) : backfilled;
|
|
42
|
+
}, [cols, withLayoutMode, layoutMode]);
|
|
43
43
|
const correctRows = useMemo(() => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return rows;
|
|
48
|
-
}, [rows]);
|
|
44
|
+
const backfilled = typeof rows === "object" && !Array.isArray(rows) && rows.small && !rows.xsmall ? { ...rows, xsmall: rows.small } : rows;
|
|
45
|
+
return withLayoutMode ? resolveByLayoutMode(backfilled, layoutMode) : backfilled;
|
|
46
|
+
}, [rows, withLayoutMode, layoutMode]);
|
|
49
47
|
return /* @__PURE__ */ jsx(
|
|
50
48
|
GridItem,
|
|
51
49
|
{
|
package/dist/esm/Grid.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/Grid.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useMemo } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport type { DSGridT } from './react-desc-prop-types.js';\nimport { DSCardHeaderPropTypesSchema } from './react-desc-prop-types.js';\nimport { GridItem } from './GridItem.js';\nimport { useGrid } from './config/useGrid.js';\nimport { DSGridName } from './DSGridDefinitions.js';\n\nconst Grid = React.forwardRef<HTMLDivElement, DSGridT.Props>((props, ref) => {\n const {\n propsWithDefaults: {\n withMaxWidthBreakpoints,\n alignItems,\n cols,\n children,\n rows,\n gutter,\n justify,\n wrap,\n width,\n height,\n innerRef,\n span,\n ...rest\n },\n globalProps,\n xstyledProps,\n isSpanParent,\n renderChildren,\n } = useGrid(props);\n\n // xsmall was added after the initial implementation, so we need to make sure it's always present\n // to avoid breaking changes.\n\n const correctSpan = useMemo(() => {\n
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useMemo } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { useGetLayoutMode } from '@elliemae/ds-system';\nimport type { DSGridT } from './react-desc-prop-types.js';\nimport { DSCardHeaderPropTypesSchema } from './react-desc-prop-types.js';\nimport { GridItem } from './GridItem.js';\nimport { useGrid } from './config/useGrid.js';\nimport { DSGridName } from './DSGridDefinitions.js';\nimport { resolveByLayoutMode, type LayoutMode } from './utils/resolveLayoutMode.js';\n\nconst Grid = React.forwardRef<HTMLDivElement, DSGridT.Props>((props, ref) => {\n const {\n propsWithDefaults: {\n withMaxWidthBreakpoints,\n alignItems,\n cols,\n children,\n rows,\n gutter,\n justify,\n wrap,\n width,\n height,\n innerRef,\n span,\n withLayoutMode,\n ...rest\n },\n globalProps,\n xstyledProps,\n isSpanParent,\n renderChildren,\n } = useGrid(props);\n\n // When withLayoutMode is opted into, the Grid resolves its responsive definitions from the\n // ancestor DSLayoutProvider's layoutMode instead of the viewport. resolveByLayoutMode is a\n // no-op when there is no layoutMode in context, so this stays safe outside a provider.\n const layoutMode = useGetLayoutMode() as LayoutMode | undefined;\n\n // xsmall was added after the initial implementation, so we need to make sure it's always present\n // to avoid breaking changes. The xsmall backfill runs first so layoutMode=\"xs\" can pick it up.\n\n const correctSpan = useMemo(() => {\n const backfilled =\n span && typeof span !== 'number' && span.small && !span.xsmall ? { ...span, xsmall: span.small } : span;\n return withLayoutMode ? resolveByLayoutMode(backfilled, layoutMode) : backfilled;\n }, [span, withLayoutMode, layoutMode]);\n\n const correctCols = useMemo(() => {\n const backfilled =\n typeof cols === 'object' && !Array.isArray(cols) && cols.small && !cols.xsmall\n ? { ...cols, xsmall: cols.small }\n : cols;\n return withLayoutMode ? resolveByLayoutMode(backfilled, layoutMode) : backfilled;\n }, [cols, withLayoutMode, layoutMode]);\n\n const correctRows = useMemo(() => {\n const backfilled =\n typeof rows === 'object' && !Array.isArray(rows) && rows.small && !rows.xsmall\n ? { ...rows, xsmall: rows.small }\n : rows;\n return withLayoutMode ? resolveByLayoutMode(backfilled, layoutMode) : backfilled;\n }, [rows, withLayoutMode, layoutMode]);\n\n return (\n <GridItem\n {...rest}\n {...globalProps}\n {...xstyledProps}\n span={correctSpan}\n alignItems={alignItems}\n cols={correctCols}\n gutter={gutter}\n isSpanParent={isSpanParent}\n justify={justify}\n rows={correctRows}\n wrap={wrap}\n childNumber={React.Children.count(children)}\n innerRef={innerRef ?? ref}\n w={width}\n h={height}\n withMaxWidthBreakpoints={withMaxWidthBreakpoints}\n >\n {renderChildren}\n </GridItem>\n );\n});\n\n// Since this component is using ForwardRef, we must provide a displayName to avoid 'undefined' name in propsTable.\nGrid.displayName = DSGridName;\nconst DSGridWithSchema = describe(Grid);\nDSGridWithSchema.propTypes = DSCardHeaderPropTypesSchema;\n\nexport default Grid;\nexport { DSGridWithSchema, Grid };\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACiEnB;AAjEJ,OAAOA,UAAS,eAAe;AAC/B,SAAS,gBAAgB;AACzB,SAAS,w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gBAAgB,UAAU,CAAC;AAErC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACJ,MAAM;AAAA,MACN;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA,aAAaA,OAAM,SAAS,MAAM,QAAQ;AAAA,MAC1C,UAAU,YAAY;AAAA,MACtB,GAAG;AAAA,MACH,GAAG;AAAA,MACH;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ,CAAC;AAGD,KAAK,cAAc;AACnB,MAAM,mBAAmB,SAAS,IAAI;AACtC,iBAAiB,YAAY;AAE7B,IAAO,eAAQ;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -50,6 +50,7 @@ const DSGridPropTypes = {
|
|
|
50
50
|
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description("Ref to the grid"),
|
|
51
51
|
wrap: PropTypes.oneOf(wrap).description("Wrap type").defaultValue(wrap[0]),
|
|
52
52
|
withMaxWidthBreakpoints: PropTypes.bool.description("weather use max width").defaultValue(void 0),
|
|
53
|
+
withLayoutMode: PropTypes.bool.description("Resolve responsive cols/rows/span from the ancestor DSLayoutProvider mode.").defaultValue(void 0),
|
|
53
54
|
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description("Grid height."),
|
|
54
55
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description("Grid width."),
|
|
55
56
|
backgroundColor: PropTypes.string.description("Sets background color."),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { WeakValidationMap } from 'react';\nimport type React from 'react';\nimport type { GlobalAttributesT, XstyledProps, DSPropTypesSchema } from '@elliemae/ds-props-helpers';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\nimport { alignItemsPlacement, justifyPlacement, wrap, boxShadow } from './utils/constants.js';\n\nexport declare namespace DSGridT {\n export type RowOrColsSyntaxSugar = string | number | (string | number)[];\n\n export interface RowColBreakpoints {\n xsmall?: RowOrColsSyntaxSugar[];\n small?: RowOrColsSyntaxSugar[];\n medium?: RowOrColsSyntaxSugar[];\n large?: RowOrColsSyntaxSugar[];\n }\n\n export type RowOrColsValidValues = RowOrColsSyntaxSugar | RowColBreakpoints;\n\n export interface SpanBreakpoints {\n xsmall?: number;\n small?: number;\n medium?: number;\n large?: number;\n }\n\n export type JustifyPlacement =\n | 'flex-start'\n | 'center'\n | 'flex-end'\n | 'space-between'\n | 'space-around'\n | 'space-evenly';\n export type AlignItemsPlacement = 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline' | 'space-between';\n export type Wrap = 'wrap' | 'nowrap' | 'wrap-reverse';\n export type BoxShadow = 'xs' | 's' | 'm' | 'l' | 'xl';\n\n export interface RequiredProps {}\n\n export interface DefaultProps {\n rows: RowOrColsValidValues;\n cols: RowOrColsValidValues;\n className: string;\n justify: JustifyPlacement;\n wrap: Wrap;\n span: number | SpanBreakpoints;\n justifyItems: string;\n }\n\n export interface OptionalProps {\n height?: string | number;\n width?: string | number;\n justifyContent?: JustifyPlacement;\n alignItems?: AlignItemsPlacement;\n alignContent?: AlignItemsPlacement;\n children?: React.ReactNode;\n withMaxWidthBreakpoints?: boolean;\n rowGap?: string | number;\n gutter?: string | number;\n innerRef?: React.MutableRefObject<HTMLDivElement | null> | React.RefCallback<HTMLDivElement>;\n }\n\n // Grid components override some of the global attributes,\n // components inheriting from Grid needs a way to exclude these attributes from GlobalAttributesT\n // in such scenario, they would do\n // Omit<\n // GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps\n // ^ their's namespace own DefaultProps | OptionalProps | ...\n // | keyof GridSpecificGlobalAttributes\n // ^ Grid's overrides\n // >\n // This way, the component will have all the global attributes except the ones that are overridden by Grid and by the component itself\n // in one line: Omit<GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps [ | ... ] | keyof GridSpecificGlobalAttributes>\n export type GridSpecificGlobalAttributes = Omit<\n GlobalAttributesT<HTMLDivElement>,\n keyof DefaultProps | keyof OptionalProps | keyof XstyledProps\n >;\n export type GridSpecificGlobalAttributesGeneric<ElementType = HTMLDivElement> = Omit<\n GlobalAttributesT<ElementType>,\n keyof DefaultProps | keyof OptionalProps | keyof XstyledProps\n >;\n\n export interface Props extends Partial<DefaultProps>, OptionalProps, GridSpecificGlobalAttributes, XstyledProps {}\n\n export interface InternalProps extends DefaultProps, OptionalProps, GridSpecificGlobalAttributes, XstyledProps {}\n\n export interface ItemProps {\n rows: RowOrColsValidValues;\n cols: RowOrColsValidValues;\n alignItems?: AlignItemsPlacement;\n alignContent?: AlignItemsPlacement;\n children: React.ReactNode;\n className?: string;\n justify: JustifyPlacement;\n gutter?: string | number;\n wrap: Wrap;\n childNumber: number;\n isSpanParent: boolean;\n span?: number | SpanBreakpoints;\n withMaxWidthBreakpoints?: boolean;\n }\n}\n\nexport const defaultProps: DSGridT.DefaultProps = {\n rows: [],\n cols: [],\n className: '',\n justify: 'flex-start',\n wrap: 'wrap',\n span: 1,\n justifyItems: 'normal',\n};\n\n// =============================================================================\n// PropTypes\n// =============================================================================\nconst rowColBreakpoints = PropTypes.shape({\n xsmall: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n small: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n medium: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n large: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n});\n\nconst spanBreakpoints = PropTypes.shape({\n xsmall: PropTypes.number,\n small: PropTypes.number,\n medium: PropTypes.number,\n large: PropTypes.number,\n});\n\nexport const DSGridPropTypes: DSPropTypesSchema<DSGridT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n rows: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n PropTypes.number,\n rowColBreakpoints,\n ])\n .description('Row layout cells')\n .defaultValue([]),\n cols: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n PropTypes.number,\n rowColBreakpoints,\n ])\n .description('Column layout cells')\n .defaultValue([]),\n span: PropTypes.oneOfType([PropTypes.number, spanBreakpoints]).description(\n 'Expands the grid element within columns.',\n ),\n alignItems: PropTypes.oneOf(alignItemsPlacement).description('flex-like align items prop'),\n children: PropTypes.node.description('Children node inside grid cell'),\n className: PropTypes.string.description('CSS class').defaultValue(''),\n justifyContent: PropTypes.oneOf(justifyPlacement)\n .description('flex-like justify prop')\n .defaultValue(justifyPlacement[0]),\n gutter: PropTypes.oneOfType([PropTypes.number, PropTypes.string])\n .description('Space between cells prop')\n .defaultValue(0),\n justify: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n justifyItems: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n alignContent: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n rowGap: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Ref to the grid'),\n wrap: PropTypes.oneOf(wrap).description('Wrap type').defaultValue(wrap[0]),\n withMaxWidthBreakpoints: PropTypes.bool.description('weather use max width').defaultValue(undefined),\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid height.'),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid width.'),\n backgroundColor: PropTypes.string.description('Sets background color.'),\n bg: PropTypes.string.description('Sets background color.'),\n boxShadow: PropTypes.oneOf(boxShadow).description('Sets background color.'),\n border: PropTypes.string.description('Sets border.'),\n borderRadius: PropTypes.string.description('Sets border radius.'),\n borderWidth: PropTypes.string.description('Sets border width.'),\n borderStyle: PropTypes.string.description('Sets border style.'),\n borderColor: PropTypes.string.description('Sets border color.'),\n borderTop: PropTypes.string.description('Sets top border.'),\n borderBottom: PropTypes.string.description('Sets bottom border.'),\n borderLeft: PropTypes.string.description('Sets left border.'),\n borderRight: PropTypes.string.description('Sets right border.'),\n borderTopWidth: PropTypes.string.description('Sets border top width.'),\n borderTopStyle: PropTypes.string.description('Sets border top style.'),\n borderTopColor: PropTypes.string.description('Sets border top color.'),\n borderBottomWidth: PropTypes.string.description('Sets border bottom width.'),\n borderBottomStyle: PropTypes.string.description('Sets border bottom style.'),\n borderBottomColor: PropTypes.string.description('Sets border bottom color.'),\n borderRightWidth: PropTypes.string.description('Sets border right width.'),\n borderRightStyle: PropTypes.string.description('Sets border right style.'),\n borderRightColor: PropTypes.string.description('Sets border right color.'),\n borderLeftWidth: PropTypes.string.description('Sets border left width.'),\n borderLeftStyle: PropTypes.string.description('Sets border left style.'),\n borderLeftColor: PropTypes.string.description('Sets border left color.'),\n};\n\nexport const DSCardHeaderPropTypesSchema = DSGridPropTypes as unknown as WeakValidationMap<DSGridT.Props>;\n\nexport const getGridProps = (props: unknown): Partial<DSGridT.Props> => {\n if (typeof props !== 'object' || props === null) return {};\n const innerProps = props as Record<string, unknown>;\n const innerGridPropTypes = props as Record<keyof DSGridT.Props, unknown>;\n const filteredProps: Partial<DSGridT.Props> = {};\n\n Object.keys(innerProps).forEach((key) => {\n const innerKey = key as keyof DSGridT.Props;\n if (innerGridPropTypes[innerKey] && innerProps[innerKey] !== undefined) {\n filteredProps[innerKey] = innerProps[innerKey];\n }\n });\n return filteredProps;\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,WAAW,2BAA2B,wBAAwB;AACvE,SAAS,qBAAqB,kBAAkB,MAAM,iBAAiB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { WeakValidationMap } from 'react';\nimport type React from 'react';\nimport type { GlobalAttributesT, XstyledProps, DSPropTypesSchema } from '@elliemae/ds-props-helpers';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\nimport { alignItemsPlacement, justifyPlacement, wrap, boxShadow } from './utils/constants.js';\n\nexport declare namespace DSGridT {\n export type RowOrColsSyntaxSugar = string | number | (string | number)[];\n\n export interface RowColBreakpoints {\n xsmall?: RowOrColsSyntaxSugar[];\n small?: RowOrColsSyntaxSugar[];\n medium?: RowOrColsSyntaxSugar[];\n large?: RowOrColsSyntaxSugar[];\n }\n\n export type RowOrColsValidValues = RowOrColsSyntaxSugar | RowColBreakpoints;\n\n export interface SpanBreakpoints {\n xsmall?: number;\n small?: number;\n medium?: number;\n large?: number;\n }\n\n export type JustifyPlacement =\n | 'flex-start'\n | 'center'\n | 'flex-end'\n | 'space-between'\n | 'space-around'\n | 'space-evenly';\n export type AlignItemsPlacement = 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline' | 'space-between';\n export type Wrap = 'wrap' | 'nowrap' | 'wrap-reverse';\n export type BoxShadow = 'xs' | 's' | 'm' | 'l' | 'xl';\n\n export interface RequiredProps {}\n\n export interface DefaultProps {\n rows: RowOrColsValidValues;\n cols: RowOrColsValidValues;\n className: string;\n justify: JustifyPlacement;\n wrap: Wrap;\n span: number | SpanBreakpoints;\n justifyItems: string;\n }\n\n export interface OptionalProps {\n height?: string | number;\n width?: string | number;\n justifyContent?: JustifyPlacement;\n alignItems?: AlignItemsPlacement;\n alignContent?: AlignItemsPlacement;\n children?: React.ReactNode;\n withMaxWidthBreakpoints?: boolean;\n withLayoutMode?: boolean;\n rowGap?: string | number;\n gutter?: string | number;\n innerRef?: React.MutableRefObject<HTMLDivElement | null> | React.RefCallback<HTMLDivElement>;\n }\n\n // Grid components override some of the global attributes,\n // components inheriting from Grid needs a way to exclude these attributes from GlobalAttributesT\n // in such scenario, they would do\n // Omit<\n // GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps\n // ^ their's namespace own DefaultProps | OptionalProps | ...\n // | keyof GridSpecificGlobalAttributes\n // ^ Grid's overrides\n // >\n // This way, the component will have all the global attributes except the ones that are overridden by Grid and by the component itself\n // in one line: Omit<GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps [ | ... ] | keyof GridSpecificGlobalAttributes>\n export type GridSpecificGlobalAttributes = Omit<\n GlobalAttributesT<HTMLDivElement>,\n keyof DefaultProps | keyof OptionalProps | keyof XstyledProps\n >;\n export type GridSpecificGlobalAttributesGeneric<ElementType = HTMLDivElement> = Omit<\n GlobalAttributesT<ElementType>,\n keyof DefaultProps | keyof OptionalProps | keyof XstyledProps\n >;\n\n export interface Props extends Partial<DefaultProps>, OptionalProps, GridSpecificGlobalAttributes, XstyledProps {}\n\n export interface InternalProps extends DefaultProps, OptionalProps, GridSpecificGlobalAttributes, XstyledProps {}\n\n export interface ItemProps {\n rows: RowOrColsValidValues;\n cols: RowOrColsValidValues;\n alignItems?: AlignItemsPlacement;\n alignContent?: AlignItemsPlacement;\n children: React.ReactNode;\n className?: string;\n justify: JustifyPlacement;\n gutter?: string | number;\n wrap: Wrap;\n childNumber: number;\n isSpanParent: boolean;\n span?: number | SpanBreakpoints;\n withMaxWidthBreakpoints?: boolean;\n }\n}\n\nexport const defaultProps: DSGridT.DefaultProps = {\n rows: [],\n cols: [],\n className: '',\n justify: 'flex-start',\n wrap: 'wrap',\n span: 1,\n justifyItems: 'normal',\n};\n\n// =============================================================================\n// PropTypes\n// =============================================================================\nconst rowColBreakpoints = PropTypes.shape({\n xsmall: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n small: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n medium: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n large: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n});\n\nconst spanBreakpoints = PropTypes.shape({\n xsmall: PropTypes.number,\n small: PropTypes.number,\n medium: PropTypes.number,\n large: PropTypes.number,\n});\n\nexport const DSGridPropTypes: DSPropTypesSchema<DSGridT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n rows: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n PropTypes.number,\n rowColBreakpoints,\n ])\n .description('Row layout cells')\n .defaultValue([]),\n cols: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),\n PropTypes.number,\n rowColBreakpoints,\n ])\n .description('Column layout cells')\n .defaultValue([]),\n span: PropTypes.oneOfType([PropTypes.number, spanBreakpoints]).description(\n 'Expands the grid element within columns.',\n ),\n alignItems: PropTypes.oneOf(alignItemsPlacement).description('flex-like align items prop'),\n children: PropTypes.node.description('Children node inside grid cell'),\n className: PropTypes.string.description('CSS class').defaultValue(''),\n justifyContent: PropTypes.oneOf(justifyPlacement)\n .description('flex-like justify prop')\n .defaultValue(justifyPlacement[0]),\n gutter: PropTypes.oneOfType([PropTypes.number, PropTypes.string])\n .description('Space between cells prop')\n .defaultValue(0),\n justify: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n justifyItems: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n alignContent: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n rowGap: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Space between cells prop'),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Ref to the grid'),\n wrap: PropTypes.oneOf(wrap).description('Wrap type').defaultValue(wrap[0]),\n withMaxWidthBreakpoints: PropTypes.bool.description('weather use max width').defaultValue(undefined),\n withLayoutMode: PropTypes.bool\n .description('Resolve responsive cols/rows/span from the ancestor DSLayoutProvider mode.')\n .defaultValue(undefined),\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid height.'),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).description('Grid width.'),\n backgroundColor: PropTypes.string.description('Sets background color.'),\n bg: PropTypes.string.description('Sets background color.'),\n boxShadow: PropTypes.oneOf(boxShadow).description('Sets background color.'),\n border: PropTypes.string.description('Sets border.'),\n borderRadius: PropTypes.string.description('Sets border radius.'),\n borderWidth: PropTypes.string.description('Sets border width.'),\n borderStyle: PropTypes.string.description('Sets border style.'),\n borderColor: PropTypes.string.description('Sets border color.'),\n borderTop: PropTypes.string.description('Sets top border.'),\n borderBottom: PropTypes.string.description('Sets bottom border.'),\n borderLeft: PropTypes.string.description('Sets left border.'),\n borderRight: PropTypes.string.description('Sets right border.'),\n borderTopWidth: PropTypes.string.description('Sets border top width.'),\n borderTopStyle: PropTypes.string.description('Sets border top style.'),\n borderTopColor: PropTypes.string.description('Sets border top color.'),\n borderBottomWidth: PropTypes.string.description('Sets border bottom width.'),\n borderBottomStyle: PropTypes.string.description('Sets border bottom style.'),\n borderBottomColor: PropTypes.string.description('Sets border bottom color.'),\n borderRightWidth: PropTypes.string.description('Sets border right width.'),\n borderRightStyle: PropTypes.string.description('Sets border right style.'),\n borderRightColor: PropTypes.string.description('Sets border right color.'),\n borderLeftWidth: PropTypes.string.description('Sets border left width.'),\n borderLeftStyle: PropTypes.string.description('Sets border left style.'),\n borderLeftColor: PropTypes.string.description('Sets border left color.'),\n};\n\nexport const DSCardHeaderPropTypesSchema = DSGridPropTypes as unknown as WeakValidationMap<DSGridT.Props>;\n\nexport const getGridProps = (props: unknown): Partial<DSGridT.Props> => {\n if (typeof props !== 'object' || props === null) return {};\n const innerProps = props as Record<string, unknown>;\n const innerGridPropTypes = props as Record<keyof DSGridT.Props, unknown>;\n const filteredProps: Partial<DSGridT.Props> = {};\n\n Object.keys(innerProps).forEach((key) => {\n const innerKey = key as keyof DSGridT.Props;\n if (innerGridPropTypes[innerKey] && innerProps[innerKey] !== undefined) {\n filteredProps[innerKey] = innerProps[innerKey];\n }\n });\n return filteredProps;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,WAAW,2BAA2B,wBAAwB;AACvE,SAAS,qBAAqB,kBAAkB,MAAM,iBAAiB;AAmGhE,MAAM,eAAqC;AAAA,EAChD,MAAM,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,WAAW;AAAA,EACX,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,cAAc;AAChB;AAKA,MAAM,oBAAoB,UAAU,MAAM;AAAA,EACxC,QAAQ,UAAU,QAAQ,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC,CAAC;AAAA,EACnF,OAAO,UAAU,QAAQ,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC,CAAC;AAAA,EAClF,QAAQ,UAAU,QAAQ,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC,CAAC;AAAA,EACnF,OAAO,UAAU,QAAQ,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,kBAAkB,UAAU,MAAM;AAAA,EACtC,QAAQ,UAAU;AAAA,EAClB,OAAO,UAAU;AAAA,EACjB,QAAQ,UAAU;AAAA,EAClB,OAAO,UAAU;AACnB,CAAC;AAEM,MAAM,kBAAoD;AAAA,EAC/D,GAAG;AAAA,EACH,GAAG;AAAA,EACH,MAAM,UAAU,UAAU;AAAA,IACxB,UAAU,QAAQ,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC,CAAC;AAAA,IAC3E,UAAU;AAAA,IACV;AAAA,EACF,CAAC,EACE,YAAY,kBAAkB,EAC9B,aAAa,CAAC,CAAC;AAAA,EAClB,MAAM,UAAU,UAAU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AAU,OAAO,YAAY,yBAAyB;AAAA,EACvE,iBAAiB,UAAU,OAAO,YAAY,yBAAyB;AAAA,EACvE,iBAAiB,UAAU,OAAO,YAAY,yBAAyB;AACzE;AAEO,MAAM,8BAA8B;AAEpC,MAAM,eAAe,CAAC,UAA2C;AACtE,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO,CAAC;AACzD,QAAM,aAAa;AACnB,QAAM,qBAAqB;AAC3B,QAAM,gBAAwC,CAAC;AAE/C,SAAO,KAAK,UAAU,EAAE,QAAQ,CAAC,QAAQ;AACvC,UAAM,WAAW;AACjB,QAAI,mBAAmB,QAAQ,KAAK,WAAW,QAAQ,MAAM,QAAW;AACtE,oBAAc,QAAQ,IAAI,WAAW,QAAQ;AAAA,IAC/C;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/typescript-grid-valid.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { Grid } from '../index.js';\nimport type { DSGridT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSGridT.Props;\ntype ComponentPropsInternals = DSGridT.InternalProps;\ntype ComponentPropsDefaultProps = DSGridT.DefaultProps;\ntype ComponentPropsOptionalProps = DSGridT.OptionalProps;\ntype ComponentPropsRequiredProps = DSGridT.RequiredProps;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {};\nconst testOptionalProps: ComponentPropsOptionalProps = {\n height: 0,\n width: 0,\n justifyContent: 'flex-start',\n alignItems: 'flex-start',\n children: <div>hey</div>,\n withMaxWidthBreakpoints: false,\n rowGap: 'xs',\n gutter: 'xs',\n};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n rows: [],\n cols: [],\n span: 2,\n justifyItems: 'flex-start',\n};\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n};\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n rows: [],\n cols: [],\n span: 2,\n justifyItems: 'flex-start',\n className: '',\n justify: 'flex-start',\n wrap: 'nowrap',\n};\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n};\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n cols: { small: ['1fr', '1fr', '1fr'], medium: ['5fr', '1fr', '1fr'], large: ['1fr', '4fr', '1fr'] },\n rows: { small: ['1fr', '1fr', '1fr'], medium: ['5fr', '1fr', '1fr'], large: ['1fr', '4fr', '1fr'] },\n span: { small: 2, medium: 3, large: 1 },\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n rows: [1, 2, 3],\n justifyContent: 'center',\n border: '1px solid black',\n} as ComponentPropsForApp;\n\nconst testDefinitionAsConst = {\n alignItems: 'center',\n gutter: 'xs',\n bg: 'brand-100',\n borderTopColor: 'neutral-100-a10',\n borderLeftColor: '#141414',\n borderRightColor: 'rgba(0,0,0,0.5)',\n borderBottomColor: 'rgb(0,0,0)',\n} as const;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <Grid {...testExplicitDefinition} />\n <Grid {...testInferedTypeCompatibility} />\n <Grid {...testDefinitionAsConst} />\n {/* works with inline values */}\n <Grid rows={[1, 2, 3]} justifyContent=\"center\" border=\"1px solid black\" />\n </>\n);\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACiBX,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { Grid } from '../index.js';\nimport type { DSGridT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSGridT.Props;\ntype ComponentPropsInternals = DSGridT.InternalProps;\ntype ComponentPropsDefaultProps = DSGridT.DefaultProps;\ntype ComponentPropsOptionalProps = DSGridT.OptionalProps;\ntype ComponentPropsRequiredProps = DSGridT.RequiredProps;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {};\nconst testOptionalProps: ComponentPropsOptionalProps = {\n height: 0,\n width: 0,\n justifyContent: 'flex-start',\n alignItems: 'flex-start',\n children: <div>hey</div>,\n withMaxWidthBreakpoints: false,\n withLayoutMode: true,\n rowGap: 'xs',\n gutter: 'xs',\n};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n rows: [],\n cols: [],\n span: 2,\n justifyItems: 'flex-start',\n};\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n};\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n rows: [],\n cols: [],\n span: 2,\n justifyItems: 'flex-start',\n className: '',\n justify: 'flex-start',\n wrap: 'nowrap',\n};\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n};\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n cols: { small: ['1fr', '1fr', '1fr'], medium: ['5fr', '1fr', '1fr'], large: ['1fr', '4fr', '1fr'] },\n rows: { small: ['1fr', '1fr', '1fr'], medium: ['5fr', '1fr', '1fr'], large: ['1fr', '4fr', '1fr'] },\n span: { small: 2, medium: 3, large: 1 },\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n rows: [1, 2, 3],\n justifyContent: 'center',\n border: '1px solid black',\n} as ComponentPropsForApp;\n\nconst testDefinitionAsConst = {\n alignItems: 'center',\n gutter: 'xs',\n bg: 'brand-100',\n borderTopColor: 'neutral-100-a10',\n borderLeftColor: '#141414',\n borderRightColor: 'rgba(0,0,0,0.5)',\n borderBottomColor: 'rgb(0,0,0)',\n} as const;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <Grid {...testExplicitDefinition} />\n <Grid {...testInferedTypeCompatibility} />\n <Grid {...testDefinitionAsConst} />\n {/* works with inline values */}\n <Grid rows={[1, 2, 3]} justifyContent=\"center\" border=\"1px solid black\" />\n </>\n);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACiBX,SAuEV,UAvEU,KAuEV,YAvEU;AAhBZ,SAAS,YAAY;AAUrB,MAAM,oBAAiD,CAAC;AACxD,MAAM,oBAAiD;AAAA,EACrD,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,UAAU,oBAAC,SAAI,iBAAG;AAAA,EAClB,yBAAyB;AAAA,EACzB,gBAAgB;AAAA,EAChB,QAAQ;AAAA,EACR,QAAQ;AACV;AAIA,MAAM,sBAA2D;AAAA,EAC/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A,EAClC,oBAAC,QAAM,GAAG,8BAA8B;AAAA,EACxC,oBAAC,QAAM,GAAG,uBAAuB;AAAA,EAEjC,oBAAC,QAAK,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,gBAAe,UAAS,QAAO,mBAAkB;AAAA,GAC1E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const LAYOUT_MODE_TO_BREAKPOINT = {
|
|
3
|
+
xs: "xsmall",
|
|
4
|
+
s: "small",
|
|
5
|
+
m: "medium",
|
|
6
|
+
l: "large"
|
|
7
|
+
};
|
|
8
|
+
const BREAKPOINT_ORDER = ["xsmall", "small", "medium", "large"];
|
|
9
|
+
const isBreakpointObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
|
+
const pickForLayoutMode = (value, layoutMode) => {
|
|
11
|
+
const targetIndex = BREAKPOINT_ORDER.indexOf(LAYOUT_MODE_TO_BREAKPOINT[layoutMode]);
|
|
12
|
+
if (targetIndex < 0) return value;
|
|
13
|
+
for (let i = targetIndex; i >= 0; i -= 1) {
|
|
14
|
+
const candidate = value[BREAKPOINT_ORDER[i]];
|
|
15
|
+
if (candidate !== void 0) return candidate;
|
|
16
|
+
}
|
|
17
|
+
for (let i = targetIndex + 1; i < BREAKPOINT_ORDER.length; i += 1) {
|
|
18
|
+
const candidate = value[BREAKPOINT_ORDER[i]];
|
|
19
|
+
if (candidate !== void 0) return candidate;
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
function resolveByLayoutMode(value, layoutMode) {
|
|
24
|
+
if (!layoutMode || !isBreakpointObject(value)) return value;
|
|
25
|
+
return pickForLayoutMode(value, layoutMode);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
BREAKPOINT_ORDER,
|
|
29
|
+
LAYOUT_MODE_TO_BREAKPOINT,
|
|
30
|
+
resolveByLayoutMode
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=resolveLayoutMode.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/resolveLayoutMode.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { DSGridT } from '../react-desc-prop-types.js';\n\n// The layout modes exposed by DSLayoutProvider (injected into the styled-components theme\n// and read via useGetLayoutMode from @elliemae/ds-system). Kept as a local literal union so\n// ds-grid does not take a (type or runtime) dependency on ds-layout-provider.\nexport type LayoutMode = 'xs' | 's' | 'm' | 'l';\n\n// The breakpoint keys a Grid cols/rows/span definition may declare.\ntype BreakpointKey = keyof DSGridT.RowColBreakpoints;\n\n// Clean 4 -> 4 mapping between a LayoutProvider mode and the Grid breakpoint it selects.\nexport const LAYOUT_MODE_TO_BREAKPOINT: Record<LayoutMode, BreakpointKey> = {\n xs: 'xsmall',\n s: 'small',\n m: 'medium',\n l: 'large',\n};\n\n// Ordered smallest -> largest. Used for the partial-definition fallback below.\nexport const BREAKPOINT_ORDER: BreakpointKey[] = ['xsmall', 'small', 'medium', 'large'];\n\n// A breakpoint definition is an object that is not an array (arrays are the \"flat\" cols/rows\n// syntax and numbers/strings are scalar definitions - none of those are layoutMode-driven).\nconst isBreakpointObject = (value: unknown): value is Partial<Record<BreakpointKey, unknown>> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst pickForLayoutMode = (value: Partial<Record<BreakpointKey, unknown>>, layoutMode: LayoutMode): unknown => {\n const targetIndex = BREAKPOINT_ORDER.indexOf(LAYOUT_MODE_TO_BREAKPOINT[layoutMode]);\n // Unknown / unsupported mode -> leave the definition untouched.\n if (targetIndex < 0) return value;\n\n // Breakpoint objects may be partial (e.g. only { small, large } defined). We resolve to a\n // single predictable value: the exact key if present, otherwise the nearest DEFINED key\n // walking down toward xsmall, and only then the nearest one walking up toward large.\n for (let i = targetIndex; i >= 0; i -= 1) {\n const candidate = value[BREAKPOINT_ORDER[i]];\n if (candidate !== undefined) return candidate;\n }\n for (let i = targetIndex + 1; i < BREAKPOINT_ORDER.length; i += 1) {\n const candidate = value[BREAKPOINT_ORDER[i]];\n if (candidate !== undefined) return candidate;\n }\n // The object declared no usable breakpoint -> no-op.\n return value;\n};\n\n/**\n * Collapse a responsive cols/rows/span definition down to the single value selected by the\n * ancestor DSLayoutProvider's layoutMode, so the Grid lays out for the container it lives in\n * instead of the viewport.\n *\n * Only breakpoint OBJECTS are affected: arrays, numbers and strings pass through untouched, and\n * when there is no layoutMode in context we return the value as-is so the Grid keeps its\n * existing viewport (media-query) behavior. This is what makes the feature safe and opt-in.\n */\nexport function resolveByLayoutMode(\n value: DSGridT.RowOrColsValidValues,\n layoutMode: LayoutMode | undefined,\n): DSGridT.RowOrColsValidValues;\nexport function resolveByLayoutMode(\n value: number | DSGridT.SpanBreakpoints,\n layoutMode: LayoutMode | undefined,\n): number | DSGridT.SpanBreakpoints;\nexport function resolveByLayoutMode(value: unknown, layoutMode: LayoutMode | undefined): unknown {\n if (!layoutMode || !isBreakpointObject(value)) return value;\n return pickForLayoutMode(value, layoutMode);\n}\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACWhB,MAAM,4BAA+D;AAAA,EAC1E,IAAI;AAAA,EACJ,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAGO,MAAM,mBAAoC,CAAC,UAAU,SAAS,UAAU,OAAO;AAItF,MAAM,qBAAqB,CAAC,UAC1B,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAM,oBAAoB,CAAC,OAAgD,eAAoC;AAC7G,QAAM,cAAc,iBAAiB,QAAQ,0BAA0B,UAAU,CAAC;AAElF,MAAI,cAAc,EAAG,QAAO;AAK5B,WAAS,IAAI,aAAa,KAAK,GAAG,KAAK,GAAG;AACxC,UAAM,YAAY,MAAM,iBAAiB,CAAC,CAAC;AAC3C,QAAI,cAAc,OAAW,QAAO;AAAA,EACtC;AACA,WAAS,IAAI,cAAc,GAAG,IAAI,iBAAiB,QAAQ,KAAK,GAAG;AACjE,UAAM,YAAY,MAAM,iBAAiB,CAAC,CAAC;AAC3C,QAAI,cAAc,OAAW,QAAO;AAAA,EACtC;AAEA,SAAO;AACT;AAmBO,SAAS,oBAAoB,OAAgB,YAA6C;AAC/F,MAAI,CAAC,cAAc,CAAC,mBAAmB,KAAK,EAAG,QAAO;AACtD,SAAO,kBAAkB,OAAO,UAAU;AAC5C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -39,6 +39,7 @@ export declare namespace DSGridT {
|
|
|
39
39
|
alignContent?: AlignItemsPlacement;
|
|
40
40
|
children?: React.ReactNode;
|
|
41
41
|
withMaxWidthBreakpoints?: boolean;
|
|
42
|
+
withLayoutMode?: boolean;
|
|
42
43
|
rowGap?: string | number;
|
|
43
44
|
gutter?: string | number;
|
|
44
45
|
innerRef?: React.MutableRefObject<HTMLDivElement | null> | React.RefCallback<HTMLDivElement>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DSGridT } from '../react-desc-prop-types.js';
|
|
2
|
+
export type LayoutMode = 'xs' | 's' | 'm' | 'l';
|
|
3
|
+
type BreakpointKey = keyof DSGridT.RowColBreakpoints;
|
|
4
|
+
export declare const LAYOUT_MODE_TO_BREAKPOINT: Record<LayoutMode, BreakpointKey>;
|
|
5
|
+
export declare const BREAKPOINT_ORDER: BreakpointKey[];
|
|
6
|
+
/**
|
|
7
|
+
* Collapse a responsive cols/rows/span definition down to the single value selected by the
|
|
8
|
+
* ancestor DSLayoutProvider's layoutMode, so the Grid lays out for the container it lives in
|
|
9
|
+
* instead of the viewport.
|
|
10
|
+
*
|
|
11
|
+
* Only breakpoint OBJECTS are affected: arrays, numbers and strings pass through untouched, and
|
|
12
|
+
* when there is no layoutMode in context we return the value as-is so the Grid keeps its
|
|
13
|
+
* existing viewport (media-query) behavior. This is what makes the feature safe and opt-in.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveByLayoutMode(value: DSGridT.RowOrColsValidValues, layoutMode: LayoutMode | undefined): DSGridT.RowOrColsValidValues;
|
|
16
|
+
export declare function resolveByLayoutMode(value: number | DSGridT.SpanBreakpoints, layoutMode: LayoutMode | undefined): number | DSGridT.SpanBreakpoints;
|
|
17
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-grid",
|
|
3
|
-
"version": "3.70.0-next.
|
|
3
|
+
"version": "3.70.0-next.62",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Grid",
|
|
6
6
|
"files": [
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@xstyled/system": "~3.8.1",
|
|
40
|
-
"@elliemae/ds-props-helpers": "3.70.0-next.
|
|
41
|
-
"@elliemae/ds-system": "3.70.0-next.
|
|
40
|
+
"@elliemae/ds-props-helpers": "3.70.0-next.62",
|
|
41
|
+
"@elliemae/ds-system": "3.70.0-next.62"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@elliemae/pui-theme": "~2.13.0",
|
|
45
45
|
"jest": "^30.0.0",
|
|
46
46
|
"react-test-renderer": "^18.3.1",
|
|
47
47
|
"styled-components": "~5.3.11",
|
|
48
|
-
"@elliemae/ds-
|
|
49
|
-
"@elliemae/ds-
|
|
48
|
+
"@elliemae/ds-test-utils": "3.70.0-next.62",
|
|
49
|
+
"@elliemae/ds-monorepo-devops": "3.70.0-next.62"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@elliemae/pui-theme": "~2.13.0",
|