Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "renderSwatchPickerGrid", {
enumerable: true,
get: function() {
return renderSwatchPickerGrid;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _ = require("../");
const renderSwatchPickerGrid = (props)=>{
const { items, columnCount, renderRow, renderSwatch } = props;
const _renderRow = renderRow || (({ children, rowId })=>/*#__PURE__*/ _react.createElement(_.SwatchPickerRow, {
key: rowId
}, children));
const _renderSwatch = renderSwatch || ((item)=>{
var _item_src;
return item.src ? /*#__PURE__*/ _react.createElement(_.ImageSwatch, {
key: item.value,
src: (_item_src = item.src) !== null && _item_src !== void 0 ? _item_src : '',
...item
}) : /*#__PURE__*/ _react.createElement(_.ColorSwatch, {
key: item.value,
color: item.color || '',
...item
});
});
const rowCount = Math.ceil(items.length / columnCount);
const rows = Array.from({
length: rowCount
}, (_, i)=>{
const start = i * columnCount;
const end = start + columnCount;
return items.slice(start, end);
});
return rows.map((row, index)=>_renderRow({
children: row.map(_renderSwatch),
rowId: index
}));
};
@@ -0,0 +1 @@
{"version":3,"sources":["../src/utils/renderUtils.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ColorSwatch, SwatchPickerRow, ImageSwatch } from '../';\nimport type { ColorSwatchProps, ImageSwatchProps } from '../';\n\nexport type SwatchProps = ImageSwatchProps | ColorSwatchProps;\n\nexport type SwatchPickerGridProps = {\n items: SwatchProps[];\n columnCount: number;\n renderRow?: (props: { children: JSX.Element[]; rowId: string | number }) => JSX.Element;\n renderSwatch?: (item: SwatchProps) => JSX.Element;\n};\n\nexport const renderSwatchPickerGrid = (props: SwatchPickerGridProps) => {\n const { items, columnCount, renderRow, renderSwatch } = props;\n const _renderRow = renderRow || (({ children, rowId }) => <SwatchPickerRow key={rowId}>{children}</SwatchPickerRow>);\n const _renderSwatch =\n renderSwatch ||\n ((item: SwatchProps) =>\n (item as ImageSwatchProps).src ? (\n <ImageSwatch key={item.value} src={(item as ImageSwatchProps).src ?? ''} {...item} />\n ) : (\n <ColorSwatch key={item.value} color={item.color || ''} {...item} />\n ));\n\n const rowCount = Math.ceil(items.length / columnCount);\n const rows = Array.from({ length: rowCount }, (_, i) => {\n const start = i * columnCount;\n const end = start + columnCount;\n return items.slice(start, end);\n });\n\n return rows.map((row, index) => _renderRow({ children: row.map(_renderSwatch), rowId: index }));\n};\n"],"names":["renderSwatchPickerGrid","props","items","columnCount","renderRow","renderSwatch","_renderRow","children","rowId","React","createElement","SwatchPickerRow","key","_renderSwatch","item","_item_src","src","ImageSwatch","value","ColorSwatch","color","rowCount","Math","ceil","length","rows","Array","from","_","i","start","end","slice","map","row","index"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAaaA;;;eAAAA;;;;iEAbU;kBACmC;AAYnD,MAAMA,yBAAyB,CAACC;IACrC,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAEC,SAAS,EAAEC,YAAY,EAAE,GAAGJ;IACxD,MAAMK,aAAaF,aAAc,CAAA,CAAC,EAAEG,QAAQ,EAAEC,KAAK,EAAE,GAAA,WAAA,GAAKC,OAAAC,aAAA,CAACC,iBAAAA,EAAAA;YAAgBC,KAAKJ;WAAQD,SAAAA;IACxF,MAAMM,gBACJR,gBACC,CAAA,CAACS;YAEqCC;eADrCD,KAA2BE,GAAG,GAAA,WAAA,GAC5BP,OAAAC,aAAA,CAACO,aAAAA,EAAAA;YAAYL,KAAKE,KAAKI,KAAK;YAAEF,KAAK,AAAAD,CAAAA,YAAAD,KAA2BE,GAAG,AAAHA,MAAG,QAA9BD,cAAA,KAAA,IAAAA,YAAkC;YAAK,GAAGD,IAAI;2BAEjFL,OAAAC,aAAA,CAACS,aAAAA,EAAAA;YAAYP,KAAKE,KAAKI,KAAK;YAAEE,OAAON,KAAKM,KAAK,IAAI;YAAK,GAAGN,IAAI;;IACjE,CAAA;IAEJ,MAAMO,WAAWC,KAAKC,IAAI,CAACrB,MAAMsB,MAAM,GAAGrB;IAC1C,MAAMsB,OAAOC,MAAMC,IAAI,CAAC;QAAEH,QAAQH;IAAS,GAAG,CAACO,GAAGC;QAChD,MAAMC,QAAQD,IAAI1B;QAClB,MAAM4B,MAAMD,QAAQ3B;QACpB,OAAOD,MAAM8B,KAAK,CAACF,OAAOC;IAC5B;IAEA,OAAON,KAAKQ,GAAG,CAAC,CAACC,KAAKC,QAAU7B,WAAW;YAAEC,UAAU2B,IAAID,GAAG,CAACpB;YAAgBL,OAAO2B;QAAM;AAC9F"}