@helsenorge/designsystem-react 14.9.2 → 14.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/BabyMobileMedium.js +1 -1
- package/lib/CHANGELOG.md +17 -0
- package/lib/Checkbox.js +25 -48
- package/lib/Checkbox.js.map +1 -1
- package/lib/Checkbox3.js +68 -0
- package/lib/Checkbox3.js.map +1 -0
- package/lib/CheckboxMarker.js +60 -0
- package/lib/CheckboxMarker.js.map +1 -0
- package/lib/ChildMedium.js +1 -1
- package/lib/EyeContactMedium.js +79 -0
- package/lib/EyeContactMedium.js.map +1 -0
- package/lib/FacialRecognitionFingerprintMedium.js +1 -1
- package/lib/FormGroup.js +5 -5
- package/lib/FormGroup.js.map +1 -1
- package/lib/GiveBabyFoodMedium.js +1 -1
- package/lib/Illustration.js +1 -1
- package/lib/IllustrationNames.js +4 -0
- package/lib/IllustrationNames.js.map +1 -1
- package/lib/LazyIllustration.js +5 -1
- package/lib/LazyIllustration.js.map +1 -1
- package/lib/Radio.js +73 -0
- package/lib/Radio.js.map +1 -0
- package/lib/RadioButton.js +95 -3
- package/lib/RadioButton.js.map +1 -1
- package/lib/RadioButton2.js +5 -0
- package/lib/RadioButton2.js.map +1 -0
- package/lib/RadioMarker.js +37 -0
- package/lib/RadioMarker.js.map +1 -0
- package/lib/ReadLettersMedium.js +1 -1
- package/lib/SkinToSkinMedium.js +106 -0
- package/lib/SkinToSkinMedium.js.map +1 -0
- package/lib/StorkMedium.js +1 -1
- package/lib/StrollerMedium.js +1 -1
- package/lib/Support2Medium.js +1 -1
- package/lib/TableBody.js +1 -1
- package/lib/TableHead.js +1 -1
- package/lib/TableRow.js +1 -1
- package/lib/ThinkingMedium.js +1 -1
- package/lib/VisualCheckbox.js +77 -0
- package/lib/VisualCheckbox.js.map +1 -0
- package/lib/VisualRadio.js +77 -0
- package/lib/VisualRadio.js.map +1 -0
- package/lib/components/Checkbox/CheckboxMarker/CheckboxMarker.d.ts +20 -0
- package/lib/components/Checkbox/CheckboxMarker/styles.module.scss +309 -0
- package/lib/components/Checkbox/CheckboxMarker/styles.module.scss.d.ts +25 -0
- package/lib/components/Checkbox/styles.module.scss +9 -269
- package/lib/components/Checkbox/styles.module.scss.d.ts +1 -17
- package/lib/components/Illustration/index.js +1 -1
- package/lib/components/Illustrations/BabyMobile.js +1 -1
- package/lib/components/Illustrations/Child.js +1 -1
- package/lib/components/Illustrations/Doctor.js +1 -1
- package/lib/components/Illustrations/EyeContact.d.ts +8 -0
- package/lib/components/Illustrations/EyeContact.js +16 -0
- package/lib/components/Illustrations/EyeContact.js.map +1 -0
- package/lib/components/Illustrations/EyeContactMedium.d.ts +3 -0
- package/lib/components/Illustrations/EyeContactMedium.js +2 -0
- package/lib/components/Illustrations/FacialRecognitionFingerprint.js +1 -1
- package/lib/components/Illustrations/GiveBabyFood.js +1 -1
- package/lib/components/Illustrations/HealthcarePersonnel.js +1 -1
- package/lib/components/Illustrations/IllustrationNames.d.ts +1 -1
- package/lib/components/Illustrations/ReadLetters.js +1 -1
- package/lib/components/Illustrations/SkinToSkin.d.ts +8 -0
- package/lib/components/Illustrations/SkinToSkin.js +16 -0
- package/lib/components/Illustrations/SkinToSkin.js.map +1 -0
- package/lib/components/Illustrations/SkinToSkinMedium.d.ts +3 -0
- package/lib/components/Illustrations/SkinToSkinMedium.js +2 -0
- package/lib/components/Illustrations/Stork.js +1 -1
- package/lib/components/Illustrations/Stroller.js +1 -1
- package/lib/components/Illustrations/Support2.js +1 -1
- package/lib/components/Illustrations/Thinking.js +1 -1
- package/lib/components/Panel/index.js +1 -1
- package/lib/components/PanelList/index.js +1 -1
- package/lib/components/RadioButton/RadioMarker/RadioMarker.d.ts +20 -0
- package/lib/components/RadioButton/RadioMarker/styles.module.scss +259 -0
- package/lib/components/RadioButton/RadioMarker/styles.module.scss.d.ts +24 -0
- package/lib/components/RadioButton/index.d.ts +0 -1
- package/lib/components/RadioButton/index.js +3 -3
- package/lib/components/RadioButton/styles.module.scss +11 -273
- package/lib/components/RadioButton/styles.module.scss.d.ts +1 -9
- package/lib/components/Table/index.js +1 -1
- package/lib/components/Validation/index.js +1 -1
- package/lib/components/VisualCheckboxCloud/Checkbox/Checkbox.d.ts +21 -0
- package/lib/components/VisualCheckboxCloud/Checkbox/index.d.ts +3 -0
- package/lib/components/VisualCheckboxCloud/Checkbox/index.js +5 -0
- package/lib/components/VisualCheckboxCloud/Checkbox/index.js.map +1 -0
- package/lib/components/VisualCheckboxCloud/Checkbox/styles.module.scss +10 -0
- package/lib/components/VisualCheckboxCloud/Checkbox/styles.module.scss.d.ts +15 -0
- package/lib/components/VisualCheckboxCloud/VisualCheckboxCloud.d.ts +29 -0
- package/lib/components/VisualCheckboxCloud/index.d.ts +3 -0
- package/lib/components/VisualCheckboxCloud/index.js +38 -0
- package/lib/components/VisualCheckboxCloud/index.js.map +1 -0
- package/lib/components/VisualCheckboxCloud/styles.module.scss +6 -0
- package/lib/components/VisualCheckboxCloud/styles.module.scss.d.ts +9 -0
- package/lib/components/VisualCheckboxGroup/VisualCheckbox/VisualCheckbox.d.ts +26 -0
- package/lib/components/VisualCheckboxGroup/VisualCheckbox/VisualContent.d.ts +10 -0
- package/lib/components/VisualCheckboxGroup/VisualCheckbox/index.d.ts +3 -0
- package/lib/components/VisualCheckboxGroup/VisualCheckbox/index.js +5 -0
- package/lib/components/VisualCheckboxGroup/VisualCheckbox/index.js.map +1 -0
- package/lib/components/VisualCheckboxGroup/VisualCheckbox/styles.module.scss +7 -0
- package/lib/components/VisualCheckboxGroup/VisualCheckbox/styles.module.scss.d.ts +18 -0
- package/lib/components/VisualCheckboxGroup/VisualCheckboxGroup.d.ts +33 -0
- package/lib/components/VisualCheckboxGroup/index.d.ts +3 -0
- package/lib/components/VisualCheckboxGroup/index.js +43 -0
- package/lib/components/VisualCheckboxGroup/index.js.map +1 -0
- package/lib/components/VisualCheckboxGroup/styles.module.scss +6 -0
- package/lib/components/VisualCheckboxGroup/styles.module.scss.d.ts +10 -0
- package/lib/components/VisualRadioCloud/Radio/Radio.d.ts +23 -0
- package/lib/components/VisualRadioCloud/Radio/index.d.ts +3 -0
- package/lib/components/VisualRadioCloud/Radio/index.js +5 -0
- package/lib/components/VisualRadioCloud/Radio/index.js.map +1 -0
- package/lib/components/VisualRadioCloud/Radio/styles.module.scss +7 -0
- package/lib/components/VisualRadioCloud/Radio/styles.module.scss.d.ts +15 -0
- package/lib/components/VisualRadioCloud/VisualRadioCloud.d.ts +39 -0
- package/lib/components/VisualRadioCloud/index.d.ts +3 -0
- package/lib/components/VisualRadioCloud/index.js +58 -0
- package/lib/components/VisualRadioCloud/index.js.map +1 -0
- package/lib/components/VisualRadioCloud/styles.module.scss +6 -0
- package/lib/components/VisualRadioCloud/styles.module.scss.d.ts +9 -0
- package/lib/components/VisualRadioGroup/VisualRadio/VisualContent.d.ts +10 -0
- package/lib/components/VisualRadioGroup/VisualRadio/VisualRadio.d.ts +26 -0
- package/lib/components/VisualRadioGroup/VisualRadio/index.d.ts +3 -0
- package/lib/components/VisualRadioGroup/VisualRadio/index.js +5 -0
- package/lib/components/VisualRadioGroup/VisualRadio/index.js.map +1 -0
- package/lib/components/VisualRadioGroup/VisualRadio/styles.module.scss +7 -0
- package/lib/components/VisualRadioGroup/VisualRadio/styles.module.scss.d.ts +18 -0
- package/lib/components/VisualRadioGroup/VisualRadioGroup.d.ts +39 -0
- package/lib/components/VisualRadioGroup/index.d.ts +3 -0
- package/lib/components/VisualRadioGroup/index.js +63 -0
- package/lib/components/VisualRadioGroup/index.js.map +1 -0
- package/lib/components/VisualRadioGroup/styles.module.scss +6 -0
- package/lib/components/VisualRadioGroup/styles.module.scss.d.ts +10 -0
- package/lib/scss/_visual-form.scss +345 -0
- package/lib/utils3.js +10 -98
- package/lib/utils3.js.map +1 -1
- package/lib/utils4.js +28 -11
- package/lib/utils4.js.map +1 -1
- package/lib/utils5.js +58 -28
- package/lib/utils5.js.map +1 -1
- package/package.json +115 -1
- package/scss/_visual-form.scss +345 -0
- package/lib/components/RadioButton/utils.d.ts +0 -2
- package/lib/utils6.js +0 -60
- package/lib/utils6.js.map +0 -1
package/lib/utils5.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils5.js","names":[],"sources":["../src/components/
|
|
1
|
+
{"version":3,"file":"utils5.js","names":["clone: Partial<T>"],"sources":["../src/components/Table/utils.ts"],"sourcesContent":["import React from 'react';\n\nimport type { ModeType } from './constants';\nimport type { BreakpointConfig } from './Table';\n\nimport { ResponsiveTableVariant } from './constants';\nimport { Breakpoint } from '../../hooks/useBreakpoint';\nimport { isTouchDevice } from '../../utils/device';\n\nimport styles from './styles.module.scss';\n\n/**\n * Sjekk om det skal brukes CSS for å bestemme responsivt utseende på dette breakpoint\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns true om breakpoint bruker CSS\n */\nconst configUsesCss = (config: BreakpointConfig): boolean =>\n config.variant === ResponsiveTableVariant.centeredoverflow || config.variant === ResponsiveTableVariant.block;\n\n/**\n * Lag klassenavn for CSS-config\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns CSS-klassenavn\n */\nconst mapConfigToClass = (config: BreakpointConfig): string =>\n config.variant === 'centeredoverflow' || config.variant === 'block' ? styles[`table--${config.variant}-${config.breakpoint}`] : '';\n\n/**\n * Sorter konfigurasjon etter breakpoints, fra største til minste\n * @param a Konfigurasjon for responsiv oppførsel\n * @param b Konfigurasjon for responsiv oppførsel\n * @returns Sortert liste\n */\nconst sortByBreakpointsDescending = (a: BreakpointConfig, b: BreakpointConfig): number =>\n Breakpoint[a.breakpoint] - Breakpoint[b.breakpoint];\n\n/**\n * Sjekk om en konfigurasjon skal brukes for nåværende breakpoint\n * @param a Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @returns true dersom config skal brukes for breakpointet\n */\nconst isValidForCurrentBreakpoint = (config: BreakpointConfig, breakpoint: Breakpoint): boolean =>\n Breakpoint[config.breakpoint] >= breakpoint;\n\n/**\n * Finn konfigurasjon for nåværende breakpoint\n * @param config Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @returns Konfigurasjon for responsiv oppførsel\n */\nconst getConfigForBreakpoint = (config: BreakpointConfig | BreakpointConfig[], breakpoint: Breakpoint): BreakpointConfig | undefined => {\n if (Array.isArray(config)) {\n config.sort(sortByBreakpointsDescending);\n\n return config.find(x => isValidForCurrentBreakpoint(x, breakpoint));\n } else if (config && isValidForCurrentBreakpoint(config, breakpoint)) {\n return config;\n }\n};\n\n/**\n * Finn konfigurasjon for nåværende breakpoint og tabellbredde\n * @param config Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @param tableWidth Bredde på tabell i px\n * @returns Konfigurasjon for responsiv oppførsel uten fallbackVariant\n */\nexport const getCurrentConfig = (\n config: BreakpointConfig | BreakpointConfig[],\n breakpoint: Breakpoint,\n tableWidth: number,\n windowWidth: number\n): Omit<BreakpointConfig, 'fallbackVariant'> | undefined => {\n const breakpointConfig = getConfigForBreakpoint(config, breakpoint);\n const canUseHorizontalScroll = isTouchDevice();\n const canUseCenteredOverflow = tableWidth <= windowWidth;\n\n if (!breakpointConfig) {\n return;\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow &&\n !canUseCenteredOverflow &&\n breakpointConfig.fallbackVariant === ResponsiveTableVariant.horizontalscroll\n ) {\n return {\n variant: canUseHorizontalScroll ? ResponsiveTableVariant.horizontalscroll : ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow &&\n !canUseCenteredOverflow &&\n breakpointConfig.fallbackVariant !== ResponsiveTableVariant.centeredoverflow\n ) {\n return {\n variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll &&\n !canUseHorizontalScroll &&\n breakpointConfig.fallbackVariant === ResponsiveTableVariant.centeredoverflow\n ) {\n return {\n variant: canUseCenteredOverflow ? ResponsiveTableVariant.centeredoverflow : ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll &&\n !canUseHorizontalScroll &&\n breakpointConfig.fallbackVariant !== ResponsiveTableVariant.horizontalscroll\n ) {\n return {\n variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n return breakpointConfig;\n};\n\n/**\n * Finn klassenavn for responsiv oppførsel\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns Klassenavn\n */\nexport const getBreakpointClass = (config?: BreakpointConfig): string | undefined =>\n config && configUsesCss(config) ? mapConfigToClass(config) : undefined;\n\n/**\n * Finn riktig posisjon for horisontal sentrering av tabell som skal vises \"centeredoverflow\"\n * @param parentWidth Bredde på element som tabellen ligger i\n * @param tableWidth Bredde på tabellen\n * @returns Styling som posisjonerer tabellen riktig\n */\nexport const getCenteredOverflowTableStyle = (parentWidth: number, tableWidth: number): React.CSSProperties | undefined => {\n if (parentWidth >= tableWidth) {\n return;\n }\n\n const COLUMN_GUTTER_WIDTH_PX = 8;\n\n return { left: `${(parentWidth - tableWidth) / 2 - COLUMN_GUTTER_WIDTH_PX}px` };\n};\n\n/**\n * Map children and inject the `mode` prop into element children, but never on React.Fragment.\n * If a Fragment is encountered, its children are mapped and updated, while the Fragment wrapper is preserved.\n */\nexport const mapChildrenWithMode = (children: React.ReactNode, mode: ModeType | undefined): React.ReactNode =>\n React.Children.map(children, child => {\n if (!React.isValidElement(child)) return child;\n if (child.type === React.Fragment) {\n const fragmentChildren = (child.props as { children?: React.ReactNode }).children;\n const mapped = React.Children.map(fragmentChildren, gc =>\n React.isValidElement<{ mode?: ModeType }>(gc) ? React.cloneElement(gc, { mode }) : gc\n );\n return React.cloneElement(child, undefined, mapped);\n }\n return React.cloneElement(child as React.ReactElement<{ mode?: ModeType }>, { mode });\n });\n\n/**\n * Create a shallow copy of an object with specific keys omitted.\n */\nexport const omitProps = <T extends Record<PropertyKey, unknown>>(obj: T, keys: Array<keyof T>): Partial<T> => {\n const clone: Partial<T> = { ...obj };\n for (const k of keys) {\n delete clone[k];\n }\n return clone;\n};\n"],"mappings":";;;;;AAgBA,IAAM,iBAAiB,WACrB,OAAO,YAAY,uBAAuB,oBAAoB,OAAO,YAAY,uBAAuB;AAO1G,IAAM,oBAAoB,WACxB,OAAO,YAAY,sBAAsB,OAAO,YAAY,UAAU,YAAO,UAAU,OAAO,QAAQ,GAAG,OAAO,gBAAgB;AAQlI,IAAM,+BAA+B,GAAqB,MACxD,WAAW,EAAE,cAAc,WAAW,EAAE;AAQ1C,IAAM,+BAA+B,QAA0B,eAC7D,WAAW,OAAO,eAAe;AAQnC,IAAM,0BAA0B,QAA+C,eAAyD;AACtI,KAAI,MAAM,QAAQ,OAAO,EAAE;AACzB,SAAO,KAAK,4BAA4B;AAExC,SAAO,OAAO,MAAK,MAAK,4BAA4B,GAAG,WAAW,CAAC;YAC1D,UAAU,4BAA4B,QAAQ,WAAW,CAClE,QAAO;;AAWX,MAAa,oBACX,QACA,YACA,YACA,gBAC0D;CAC1D,MAAM,mBAAmB,uBAAuB,QAAQ,WAAW;CACnE,MAAM,yBAAyB,eAAe;CAC9C,MAAM,yBAAyB,cAAc;AAE7C,KAAI,CAAC,iBACH;AAGF,KACE,iBAAiB,YAAY,uBAAuB,oBACpD,CAAC,0BACD,iBAAiB,oBAAoB,uBAAuB,iBAE5D,QAAO;EACL,SAAS,yBAAyB,uBAAuB,mBAAmB,uBAAuB;EACnG,YAAY,iBAAiB;EAC9B;AAGH,KACE,iBAAiB,YAAY,uBAAuB,oBACpD,CAAC,0BACD,iBAAiB,oBAAoB,uBAAuB,iBAE5D,QAAO;EACL,SAAS,iBAAiB,mBAAmB,uBAAuB;EACpE,YAAY,iBAAiB;EAC9B;AAGH,KACE,iBAAiB,YAAY,uBAAuB,oBACpD,CAAC,0BACD,iBAAiB,oBAAoB,uBAAuB,iBAE5D,QAAO;EACL,SAAS,yBAAyB,uBAAuB,mBAAmB,uBAAuB;EACnG,YAAY,iBAAiB;EAC9B;AAGH,KACE,iBAAiB,YAAY,uBAAuB,oBACpD,CAAC,0BACD,iBAAiB,oBAAoB,uBAAuB,iBAE5D,QAAO;EACL,SAAS,iBAAiB,mBAAmB,uBAAuB;EACpE,YAAY,iBAAiB;EAC9B;AAGH,QAAO;;AAQT,MAAa,sBAAsB,WACjC,UAAU,cAAc,OAAO,GAAG,iBAAiB,OAAO,GAAG,KAAA;AAQ/D,MAAa,iCAAiC,aAAqB,eAAwD;AACzH,KAAI,eAAe,WACjB;AAKF,QAAO,EAAE,MAAM,IAAI,cAAc,cAAc,IAFhB,EAE2C,KAAK;;AAOjF,MAAa,uBAAuB,UAA2B,SAC7D,MAAM,SAAS,IAAI,WAAU,UAAS;AACpC,KAAI,CAAC,MAAM,eAAe,MAAM,CAAE,QAAO;AACzC,KAAI,MAAM,SAAS,MAAM,UAAU;EACjC,MAAM,mBAAoB,MAAM,MAAyC;EACzE,MAAM,SAAS,MAAM,SAAS,IAAI,mBAAkB,OAClD,MAAM,eAAoC,GAAG,GAAG,MAAM,aAAa,IAAI,EAAE,MAAM,CAAC,GAAG,GACpF;AACD,SAAO,MAAM,aAAa,OAAO,KAAA,GAAW,OAAO;;AAErD,QAAO,MAAM,aAAa,OAAkD,EAAE,MAAM,CAAC;EACrF;AAKJ,MAAa,aAAqD,KAAQ,SAAqC;CAC7G,MAAMA,QAAoB,EAAE,GAAG,KAAK;AACpC,MAAK,MAAM,KAAK,KACd,QAAO,MAAM;AAEf,QAAO"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@helsenorge/designsystem-react",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "14.
|
|
5
|
+
"version": "14.11.0",
|
|
6
6
|
"description": "The official design system for Helsenorge built with React.",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -732,6 +732,120 @@
|
|
|
732
732
|
},
|
|
733
733
|
"./components/Validation/types": {
|
|
734
734
|
"types": "./lib/components/Validation/types.d.ts"
|
|
735
|
+
},
|
|
736
|
+
"./components/Avatar/constants": {
|
|
737
|
+
"types": "./lib/components/Avatar/constants.d.ts"
|
|
738
|
+
},
|
|
739
|
+
"./components/Chip/resourceHelper": {
|
|
740
|
+
"types": "./lib/components/Chip/resourceHelper.d.ts"
|
|
741
|
+
},
|
|
742
|
+
"./components/DropdownOld/constants": {
|
|
743
|
+
"types": "./lib/components/DropdownOld/constants.d.ts"
|
|
744
|
+
},
|
|
745
|
+
"./components/ElementHeader/utils": {
|
|
746
|
+
"types": "./lib/components/ElementHeader/utils.d.ts"
|
|
747
|
+
},
|
|
748
|
+
"./components/EmptyState/constants": {
|
|
749
|
+
"types": "./lib/components/EmptyState/constants.d.ts"
|
|
750
|
+
},
|
|
751
|
+
"./components/Expander/constants": {
|
|
752
|
+
"types": "./lib/components/Expander/constants.d.ts"
|
|
753
|
+
},
|
|
754
|
+
"./components/Filter/resourceHelper": {
|
|
755
|
+
"types": "./lib/components/Filter/resourceHelper.d.ts"
|
|
756
|
+
},
|
|
757
|
+
"./components/Filter/resourcesMock": {
|
|
758
|
+
"types": "./lib/components/Filter/resourcesMock.d.ts"
|
|
759
|
+
},
|
|
760
|
+
"./components/Filter/useFilter": {
|
|
761
|
+
"types": "./lib/components/Filter/useFilter.d.ts"
|
|
762
|
+
},
|
|
763
|
+
"./components/Filter/useFilterDrawer": {
|
|
764
|
+
"types": "./lib/components/Filter/useFilterDrawer.d.ts"
|
|
765
|
+
},
|
|
766
|
+
"./components/Filter/utils": {
|
|
767
|
+
"types": "./lib/components/Filter/utils.d.ts"
|
|
768
|
+
},
|
|
769
|
+
"./components/FormLayout/constants": {
|
|
770
|
+
"types": "./lib/components/FormLayout/constants.d.ts"
|
|
771
|
+
},
|
|
772
|
+
"./components/Icon/utils": {
|
|
773
|
+
"types": "./lib/components/Icon/utils.d.ts"
|
|
774
|
+
},
|
|
775
|
+
"./components/Input/constants": {
|
|
776
|
+
"types": "./lib/components/Input/constants.d.ts"
|
|
777
|
+
},
|
|
778
|
+
"./components/Input/resourceHelper": {
|
|
779
|
+
"types": "./lib/components/Input/resourceHelper.d.ts"
|
|
780
|
+
},
|
|
781
|
+
"./components/Label/utils": {
|
|
782
|
+
"types": "./lib/components/Label/utils.d.ts"
|
|
783
|
+
},
|
|
784
|
+
"./components/LinkList/resourceHelper": {
|
|
785
|
+
"types": "./lib/components/LinkList/resourceHelper.d.ts"
|
|
786
|
+
},
|
|
787
|
+
"./components/ListEditMode/constants": {
|
|
788
|
+
"types": "./lib/components/ListEditMode/constants.d.ts"
|
|
789
|
+
},
|
|
790
|
+
"./components/Loader/constants": {
|
|
791
|
+
"types": "./lib/components/Loader/constants.d.ts"
|
|
792
|
+
},
|
|
793
|
+
"./components/Modal/constants": {
|
|
794
|
+
"types": "./lib/components/Modal/constants.d.ts"
|
|
795
|
+
},
|
|
796
|
+
"./components/Panel/constants": {
|
|
797
|
+
"types": "./lib/components/Panel/constants.d.ts"
|
|
798
|
+
},
|
|
799
|
+
"./components/PanelList/utils": {
|
|
800
|
+
"types": "./lib/components/PanelList/utils.d.ts"
|
|
801
|
+
},
|
|
802
|
+
"./components/PopMenu/constants": {
|
|
803
|
+
"types": "./lib/components/PopMenu/constants.d.ts"
|
|
804
|
+
},
|
|
805
|
+
"./components/Progressbar/constants": {
|
|
806
|
+
"types": "./lib/components/Progressbar/constants.d.ts"
|
|
807
|
+
},
|
|
808
|
+
"./components/StatusDot/constants": {
|
|
809
|
+
"types": "./lib/components/StatusDot/constants.d.ts"
|
|
810
|
+
},
|
|
811
|
+
"./components/Table/constants": {
|
|
812
|
+
"types": "./lib/components/Table/constants.d.ts"
|
|
813
|
+
},
|
|
814
|
+
"./components/Tag/constants": {
|
|
815
|
+
"types": "./lib/components/Tag/constants.d.ts"
|
|
816
|
+
},
|
|
817
|
+
"./components/Textarea/resourceHelper": {
|
|
818
|
+
"types": "./lib/components/Textarea/resourceHelper.d.ts"
|
|
819
|
+
},
|
|
820
|
+
"./components/Title/utils": {
|
|
821
|
+
"types": "./lib/components/Title/utils.d.ts"
|
|
822
|
+
},
|
|
823
|
+
"./components/Toggle/constants": {
|
|
824
|
+
"types": "./lib/components/Toggle/constants.d.ts"
|
|
825
|
+
},
|
|
826
|
+
"./components/VisualCheckboxCloud/VisualCheckboxCloud": {
|
|
827
|
+
"types": "./lib/components/VisualCheckboxCloud/VisualCheckboxCloud.d.ts",
|
|
828
|
+
"import": "./lib/components/VisualCheckboxCloud/index.js",
|
|
829
|
+
"require": "./lib/components/VisualCheckboxCloud/index.js",
|
|
830
|
+
"default": "./lib/components/VisualCheckboxCloud/index.js"
|
|
831
|
+
},
|
|
832
|
+
"./components/VisualCheckboxGroup/VisualCheckboxGroup": {
|
|
833
|
+
"types": "./lib/components/VisualCheckboxGroup/VisualCheckboxGroup.d.ts",
|
|
834
|
+
"import": "./lib/components/VisualCheckboxGroup/index.js",
|
|
835
|
+
"require": "./lib/components/VisualCheckboxGroup/index.js",
|
|
836
|
+
"default": "./lib/components/VisualCheckboxGroup/index.js"
|
|
837
|
+
},
|
|
838
|
+
"./components/VisualRadioCloud/VisualRadioCloud": {
|
|
839
|
+
"types": "./lib/components/VisualRadioCloud/VisualRadioCloud.d.ts",
|
|
840
|
+
"import": "./lib/components/VisualRadioCloud/index.js",
|
|
841
|
+
"require": "./lib/components/VisualRadioCloud/index.js",
|
|
842
|
+
"default": "./lib/components/VisualRadioCloud/index.js"
|
|
843
|
+
},
|
|
844
|
+
"./components/VisualRadioGroup/VisualRadioGroup": {
|
|
845
|
+
"types": "./lib/components/VisualRadioGroup/VisualRadioGroup.d.ts",
|
|
846
|
+
"import": "./lib/components/VisualRadioGroup/index.js",
|
|
847
|
+
"require": "./lib/components/VisualRadioGroup/index.js",
|
|
848
|
+
"default": "./lib/components/VisualRadioGroup/index.js"
|
|
735
849
|
}
|
|
736
850
|
},
|
|
737
851
|
"scripts": {
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
@use 'breakpoints' as breakpoints;
|
|
3
|
+
@use 'font-mixins' as fonts;
|
|
4
|
+
|
|
5
|
+
// Wrapper layout shared by VisualCheckboxCloud and VisualRadioCloud
|
|
6
|
+
@mixin visual-form-cloud {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-flow: row wrap;
|
|
9
|
+
gap: var(--core-space-4xs) var(--core-space-xs);
|
|
10
|
+
|
|
11
|
+
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
12
|
+
gap: var(--core-space-m) var(--core-space-s);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Pill-style input shared by VisualCheckboxCloud/Checkbox and VisualRadioCloud/Radio
|
|
17
|
+
@mixin visual-form-pill(
|
|
18
|
+
$pill-padding-mobile: var(--core-space-3xs) var(--core-space-m),
|
|
19
|
+
$checked-pill-padding-md: var(--core-space-3xs) var(--core-space-m) var(--core-space-3xs) 1.25rem
|
|
20
|
+
) {
|
|
21
|
+
position: relative;
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
align-items: stretch;
|
|
24
|
+
min-height: 2.75rem;
|
|
25
|
+
padding: 0.313rem 0;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
|
|
28
|
+
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
29
|
+
padding: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&__input {
|
|
33
|
+
// Hides input while making sure screen reader outline wraps the entire component
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
position: absolute;
|
|
36
|
+
z-index: 0;
|
|
37
|
+
inset: 0;
|
|
38
|
+
width: 100%;
|
|
39
|
+
height: 100%;
|
|
40
|
+
outline: none;
|
|
41
|
+
appearance: none;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&__pill {
|
|
45
|
+
position: relative;
|
|
46
|
+
z-index: 1;
|
|
47
|
+
display: inline-flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
gap: var(--core-space-2xs);
|
|
50
|
+
box-sizing: border-box;
|
|
51
|
+
min-height: var(--core-space-l);
|
|
52
|
+
padding: $pill-padding-mobile;
|
|
53
|
+
border-radius: 100px;
|
|
54
|
+
background-color: var(--color-action-background-ondark);
|
|
55
|
+
border: 1px solid var(--color-action-border-onlight);
|
|
56
|
+
color: var(--color-base-text-onlight);
|
|
57
|
+
|
|
58
|
+
@include fonts.title6;
|
|
59
|
+
|
|
60
|
+
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
61
|
+
min-height: var(--core-space-xl);
|
|
62
|
+
padding: var(--core-space-3xs) var(--core-space-l);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:hover &__pill {
|
|
67
|
+
background-color: var(--color-action-background-ondark-hover);
|
|
68
|
+
border-color: var(--color-action-border-onlight-hover);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&:active &__pill {
|
|
72
|
+
background-color: var(--color-action-background-ondark-selected);
|
|
73
|
+
border-color: var(--color-action-border-onlight-hover);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&--checked &__pill {
|
|
77
|
+
background-color: var(--color-action-background-onlight);
|
|
78
|
+
color: var(--color-action-text-ondark);
|
|
79
|
+
border-color: var(--color-action-background-onlight);
|
|
80
|
+
padding: var(--core-space-3xs) var(--core-space-s);
|
|
81
|
+
|
|
82
|
+
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
83
|
+
padding: $checked-pill-padding-md;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&--checked:hover &__pill {
|
|
88
|
+
background-color: var(--color-action-graphics-onlight-hover);
|
|
89
|
+
border-color: var(--color-action-graphics-onlight-hover);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&--checked:active &__pill {
|
|
93
|
+
background-color: var(--color-action-background-onlight-active);
|
|
94
|
+
border-color: var(--color-action-background-onlight-active);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&--invalid &__pill {
|
|
98
|
+
background-color: var(--color-action-background-ondark);
|
|
99
|
+
border-color: var(--color-destructive-border-normal);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&--invalid:hover &__pill {
|
|
103
|
+
background-color: var(--color-destructive-background-normal);
|
|
104
|
+
border-color: var(--color-destructive-border-normal);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&--invalid:active &__pill {
|
|
108
|
+
background-color: var(--color-destructive-background-emphasized);
|
|
109
|
+
border-color: var(--color-destructive-border-normal);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&--invalid#{&}--checked &__pill {
|
|
113
|
+
background-color: var(--color-destructive-graphics-normal);
|
|
114
|
+
border-color: var(--color-destructive-graphics-normal);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&--invalid#{&}--checked:hover &__pill {
|
|
118
|
+
background-color: var(--color-destructive-graphics-hover);
|
|
119
|
+
border-color: var(--color-destructive-graphics-hover);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&--invalid#{&}--checked:active &__pill {
|
|
123
|
+
background-color: var(--color-destructive-graphics-emphasized-onlight);
|
|
124
|
+
border-color: var(--color-destructive-graphics-emphasized-onlight);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&__input:focus-visible + &__pill {
|
|
128
|
+
outline: 3px solid var(--color-action-border-onlight-focus);
|
|
129
|
+
border-color: var(--color-action-border-ondark);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&__icon {
|
|
133
|
+
display: inline-flex;
|
|
134
|
+
align-items: center;
|
|
135
|
+
justify-content: center;
|
|
136
|
+
|
|
137
|
+
svg {
|
|
138
|
+
fill: var(--color-action-graphics-ondark);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&__label {
|
|
143
|
+
text-box: trim-both cap alphabetic;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Grid layout shared by VisualCheckboxGroup and VisualRadioGroup.
|
|
148
|
+
@mixin visual-form-group {
|
|
149
|
+
display: grid;
|
|
150
|
+
grid-template-columns: repeat(auto-fit, minmax(8.75rem, 1fr));
|
|
151
|
+
gap: var(--core-space-xs);
|
|
152
|
+
|
|
153
|
+
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
154
|
+
gap: 0.75rem var(--core-space-xs, 0.75rem);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
&--variant-line {
|
|
158
|
+
grid-template-columns: 1fr;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Styling shared by VisualCheckbox and VisualRadio
|
|
163
|
+
@mixin visual-form-card {
|
|
164
|
+
display: flex;
|
|
165
|
+
position: relative;
|
|
166
|
+
cursor: pointer;
|
|
167
|
+
width: 100%;
|
|
168
|
+
|
|
169
|
+
&--variant-line {
|
|
170
|
+
flex-direction: row;
|
|
171
|
+
justify-content: flex-start;
|
|
172
|
+
align-items: center;
|
|
173
|
+
min-height: 6rem;
|
|
174
|
+
min-width: 15.125rem;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
&--variant-rectangle {
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
align-items: center;
|
|
180
|
+
min-height: 12.625rem;
|
|
181
|
+
min-width: 8.75rem;
|
|
182
|
+
height: 100%;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&__input {
|
|
186
|
+
// Hides input while making sure screen reader outline wraps the entire component
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
position: absolute;
|
|
189
|
+
z-index: 0;
|
|
190
|
+
inset: 0;
|
|
191
|
+
width: 100%;
|
|
192
|
+
height: 100%;
|
|
193
|
+
outline: none;
|
|
194
|
+
appearance: none;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
&__frame {
|
|
198
|
+
position: relative;
|
|
199
|
+
width: 100%;
|
|
200
|
+
z-index: 1;
|
|
201
|
+
display: inline-flex;
|
|
202
|
+
border-radius: 4px;
|
|
203
|
+
background: var(--color-action-background-ondark);
|
|
204
|
+
border: 2px solid var(--color-action-border-onlight);
|
|
205
|
+
color: var(--color-base-text-onlight);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
&--variant-line &__frame {
|
|
209
|
+
margin-left: -2.87rem;
|
|
210
|
+
gap: var(--core-space-2xs);
|
|
211
|
+
flex-direction: row;
|
|
212
|
+
justify-content: flex-end;
|
|
213
|
+
align-items: center;
|
|
214
|
+
min-height: 4.63rem;
|
|
215
|
+
min-width: 12.25rem;
|
|
216
|
+
padding: var(--core-space-s) var(--core-space-m) var(--core-space-s) var(--core-space-2xl);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
&--variant-rectangle &__frame {
|
|
220
|
+
margin-top: -4.37rem;
|
|
221
|
+
flex: 1;
|
|
222
|
+
gap: var(--core-space-xs);
|
|
223
|
+
flex-direction: column;
|
|
224
|
+
align-items: center;
|
|
225
|
+
justify-content: flex-end;
|
|
226
|
+
text-align: center;
|
|
227
|
+
min-width: 8.75rem;
|
|
228
|
+
min-height: 10.25rem;
|
|
229
|
+
padding: var(--core-space-3xl) var(--core-space-xs) var(--core-space-m) var(--core-space-xs);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
&__visual-content {
|
|
233
|
+
position: relative;
|
|
234
|
+
z-index: 2;
|
|
235
|
+
display: inline-flex;
|
|
236
|
+
align-items: center;
|
|
237
|
+
justify-content: center;
|
|
238
|
+
overflow: hidden;
|
|
239
|
+
border-radius: 100%;
|
|
240
|
+
background: var(--color-action-background-ondark);
|
|
241
|
+
border: 2px solid var(--color-action-border-ondark);
|
|
242
|
+
|
|
243
|
+
> * {
|
|
244
|
+
width: 100%;
|
|
245
|
+
height: 100%;
|
|
246
|
+
object-fit: cover;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
&--variant-line &__visual-content {
|
|
251
|
+
min-width: var(--core-space-4xl);
|
|
252
|
+
min-height: var(--core-space-4xl);
|
|
253
|
+
|
|
254
|
+
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
255
|
+
min-width: var(--core-space-5xl);
|
|
256
|
+
min-height: var(--core-space-5xl);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
&--variant-rectangle &__visual-content {
|
|
261
|
+
flex-shrink: 0;
|
|
262
|
+
width: calc(100% - 2rem);
|
|
263
|
+
min-width: 6.75rem;
|
|
264
|
+
max-width: 13rem;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
&--checked &__frame {
|
|
268
|
+
background: var(--color-action-background-onlight);
|
|
269
|
+
color: var(--color-action-text-ondark);
|
|
270
|
+
border-color: var(--color-action-background-onlight);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
&--invalid &__frame {
|
|
274
|
+
background: var(--color-action-background-ondark);
|
|
275
|
+
border-color: var(--core-color-cherry-500);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
&:hover &__frame {
|
|
279
|
+
background: var(--core-color-neutral-50);
|
|
280
|
+
border-color: var(--color-action-border-onlight-hover);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
&:active &__frame {
|
|
284
|
+
background: var(--core-color-neutral-100);
|
|
285
|
+
border-color: var(--color-action-border-onlight-hover);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
&--checked:hover &__frame {
|
|
289
|
+
background: var(--color-action-background-onlight-hover);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
&--checked:active &__frame {
|
|
293
|
+
background: var(--color-action-background-onlight-active);
|
|
294
|
+
border-color: var(--color-action-background-onlight-active);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
&--invalid:hover &__frame {
|
|
298
|
+
background: var(--core-color-cherry-50);
|
|
299
|
+
border-color: var(--core-color-cherry-500);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
&--invalid:active &__frame {
|
|
303
|
+
background: var(--core-color-cherry-100);
|
|
304
|
+
border-color: var(--core-color-cherry-500);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
&--invalid#{&}--checked &__frame {
|
|
308
|
+
background: var(--core-color-cherry-50);
|
|
309
|
+
color: var(--color-base-text-onlight);
|
|
310
|
+
border-color: var(--core-color-cherry-500);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
&--invalid#{&}--checked:hover &__frame {
|
|
314
|
+
background: var(--core-color-cherry-100);
|
|
315
|
+
border-color: var(--core-color-cherry-500);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
&--invalid#{&}--checked:active &__frame {
|
|
319
|
+
background: var(--core-color-cherry-200);
|
|
320
|
+
border-color: var(--core-color-cherry-500);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
&__input:focus-visible + &__frame {
|
|
324
|
+
outline: 4px solid var(--color-action-border-onlight-focus);
|
|
325
|
+
border-color: var(--color-action-border-ondark);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
&__icon {
|
|
329
|
+
display: inline-flex;
|
|
330
|
+
align-items: center;
|
|
331
|
+
justify-content: center;
|
|
332
|
+
|
|
333
|
+
svg {
|
|
334
|
+
fill: var(--color-action-graphics-ondark);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
&__label {
|
|
339
|
+
flex: 1;
|
|
340
|
+
min-width: 0;
|
|
341
|
+
overflow-wrap: anywhere;
|
|
342
|
+
|
|
343
|
+
@include fonts.label-subdued;
|
|
344
|
+
}
|
|
345
|
+
}
|
package/lib/utils6.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { t as Breakpoint } from "./useBreakpoint.js";
|
|
2
|
-
import { r as ResponsiveTableVariant } from "./constants3.js";
|
|
3
|
-
import { t as isTouchDevice } from "./device.js";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import tableStyles from "./components/Table/styles.module.scss";
|
|
6
|
-
var configUsesCss = (config) => config.variant === ResponsiveTableVariant.centeredoverflow || config.variant === ResponsiveTableVariant.block;
|
|
7
|
-
var mapConfigToClass = (config) => config.variant === "centeredoverflow" || config.variant === "block" ? tableStyles[`table--${config.variant}-${config.breakpoint}`] : "";
|
|
8
|
-
var sortByBreakpointsDescending = (a, b) => Breakpoint[a.breakpoint] - Breakpoint[b.breakpoint];
|
|
9
|
-
var isValidForCurrentBreakpoint = (config, breakpoint) => Breakpoint[config.breakpoint] >= breakpoint;
|
|
10
|
-
var getConfigForBreakpoint = (config, breakpoint) => {
|
|
11
|
-
if (Array.isArray(config)) {
|
|
12
|
-
config.sort(sortByBreakpointsDescending);
|
|
13
|
-
return config.find((x) => isValidForCurrentBreakpoint(x, breakpoint));
|
|
14
|
-
} else if (config && isValidForCurrentBreakpoint(config, breakpoint)) return config;
|
|
15
|
-
};
|
|
16
|
-
const getCurrentConfig = (config, breakpoint, tableWidth, windowWidth) => {
|
|
17
|
-
const breakpointConfig = getConfigForBreakpoint(config, breakpoint);
|
|
18
|
-
const canUseHorizontalScroll = isTouchDevice();
|
|
19
|
-
const canUseCenteredOverflow = tableWidth <= windowWidth;
|
|
20
|
-
if (!breakpointConfig) return;
|
|
21
|
-
if (breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow && !canUseCenteredOverflow && breakpointConfig.fallbackVariant === ResponsiveTableVariant.horizontalscroll) return {
|
|
22
|
-
variant: canUseHorizontalScroll ? ResponsiveTableVariant.horizontalscroll : ResponsiveTableVariant.none,
|
|
23
|
-
breakpoint: breakpointConfig.breakpoint
|
|
24
|
-
};
|
|
25
|
-
if (breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow && !canUseCenteredOverflow && breakpointConfig.fallbackVariant !== ResponsiveTableVariant.centeredoverflow) return {
|
|
26
|
-
variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,
|
|
27
|
-
breakpoint: breakpointConfig.breakpoint
|
|
28
|
-
};
|
|
29
|
-
if (breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll && !canUseHorizontalScroll && breakpointConfig.fallbackVariant === ResponsiveTableVariant.centeredoverflow) return {
|
|
30
|
-
variant: canUseCenteredOverflow ? ResponsiveTableVariant.centeredoverflow : ResponsiveTableVariant.none,
|
|
31
|
-
breakpoint: breakpointConfig.breakpoint
|
|
32
|
-
};
|
|
33
|
-
if (breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll && !canUseHorizontalScroll && breakpointConfig.fallbackVariant !== ResponsiveTableVariant.horizontalscroll) return {
|
|
34
|
-
variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,
|
|
35
|
-
breakpoint: breakpointConfig.breakpoint
|
|
36
|
-
};
|
|
37
|
-
return breakpointConfig;
|
|
38
|
-
};
|
|
39
|
-
const getBreakpointClass = (config) => config && configUsesCss(config) ? mapConfigToClass(config) : void 0;
|
|
40
|
-
const getCenteredOverflowTableStyle = (parentWidth, tableWidth) => {
|
|
41
|
-
if (parentWidth >= tableWidth) return;
|
|
42
|
-
return { left: `${(parentWidth - tableWidth) / 2 - 8}px` };
|
|
43
|
-
};
|
|
44
|
-
const mapChildrenWithMode = (children, mode) => React.Children.map(children, (child) => {
|
|
45
|
-
if (!React.isValidElement(child)) return child;
|
|
46
|
-
if (child.type === React.Fragment) {
|
|
47
|
-
const fragmentChildren = child.props.children;
|
|
48
|
-
const mapped = React.Children.map(fragmentChildren, (gc) => React.isValidElement(gc) ? React.cloneElement(gc, { mode }) : gc);
|
|
49
|
-
return React.cloneElement(child, void 0, mapped);
|
|
50
|
-
}
|
|
51
|
-
return React.cloneElement(child, { mode });
|
|
52
|
-
});
|
|
53
|
-
const omitProps = (obj, keys) => {
|
|
54
|
-
const clone = { ...obj };
|
|
55
|
-
for (const k of keys) delete clone[k];
|
|
56
|
-
return clone;
|
|
57
|
-
};
|
|
58
|
-
export { omitProps as a, mapChildrenWithMode as i, getCenteredOverflowTableStyle as n, getCurrentConfig as r, getBreakpointClass as t };
|
|
59
|
-
|
|
60
|
-
//# sourceMappingURL=utils6.js.map
|
package/lib/utils6.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils6.js","names":["clone: Partial<T>"],"sources":["../src/components/Table/utils.ts"],"sourcesContent":["import React from 'react';\n\nimport type { ModeType } from './constants';\nimport type { BreakpointConfig } from './Table';\n\nimport { ResponsiveTableVariant } from './constants';\nimport { Breakpoint } from '../../hooks/useBreakpoint';\nimport { isTouchDevice } from '../../utils/device';\n\nimport styles from './styles.module.scss';\n\n/**\n * Sjekk om det skal brukes CSS for å bestemme responsivt utseende på dette breakpoint\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns true om breakpoint bruker CSS\n */\nconst configUsesCss = (config: BreakpointConfig): boolean =>\n config.variant === ResponsiveTableVariant.centeredoverflow || config.variant === ResponsiveTableVariant.block;\n\n/**\n * Lag klassenavn for CSS-config\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns CSS-klassenavn\n */\nconst mapConfigToClass = (config: BreakpointConfig): string =>\n config.variant === 'centeredoverflow' || config.variant === 'block' ? styles[`table--${config.variant}-${config.breakpoint}`] : '';\n\n/**\n * Sorter konfigurasjon etter breakpoints, fra største til minste\n * @param a Konfigurasjon for responsiv oppførsel\n * @param b Konfigurasjon for responsiv oppførsel\n * @returns Sortert liste\n */\nconst sortByBreakpointsDescending = (a: BreakpointConfig, b: BreakpointConfig): number =>\n Breakpoint[a.breakpoint] - Breakpoint[b.breakpoint];\n\n/**\n * Sjekk om en konfigurasjon skal brukes for nåværende breakpoint\n * @param a Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @returns true dersom config skal brukes for breakpointet\n */\nconst isValidForCurrentBreakpoint = (config: BreakpointConfig, breakpoint: Breakpoint): boolean =>\n Breakpoint[config.breakpoint] >= breakpoint;\n\n/**\n * Finn konfigurasjon for nåværende breakpoint\n * @param config Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @returns Konfigurasjon for responsiv oppførsel\n */\nconst getConfigForBreakpoint = (config: BreakpointConfig | BreakpointConfig[], breakpoint: Breakpoint): BreakpointConfig | undefined => {\n if (Array.isArray(config)) {\n config.sort(sortByBreakpointsDescending);\n\n return config.find(x => isValidForCurrentBreakpoint(x, breakpoint));\n } else if (config && isValidForCurrentBreakpoint(config, breakpoint)) {\n return config;\n }\n};\n\n/**\n * Finn konfigurasjon for nåværende breakpoint og tabellbredde\n * @param config Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @param tableWidth Bredde på tabell i px\n * @returns Konfigurasjon for responsiv oppførsel uten fallbackVariant\n */\nexport const getCurrentConfig = (\n config: BreakpointConfig | BreakpointConfig[],\n breakpoint: Breakpoint,\n tableWidth: number,\n windowWidth: number\n): Omit<BreakpointConfig, 'fallbackVariant'> | undefined => {\n const breakpointConfig = getConfigForBreakpoint(config, breakpoint);\n const canUseHorizontalScroll = isTouchDevice();\n const canUseCenteredOverflow = tableWidth <= windowWidth;\n\n if (!breakpointConfig) {\n return;\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow &&\n !canUseCenteredOverflow &&\n breakpointConfig.fallbackVariant === ResponsiveTableVariant.horizontalscroll\n ) {\n return {\n variant: canUseHorizontalScroll ? ResponsiveTableVariant.horizontalscroll : ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow &&\n !canUseCenteredOverflow &&\n breakpointConfig.fallbackVariant !== ResponsiveTableVariant.centeredoverflow\n ) {\n return {\n variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll &&\n !canUseHorizontalScroll &&\n breakpointConfig.fallbackVariant === ResponsiveTableVariant.centeredoverflow\n ) {\n return {\n variant: canUseCenteredOverflow ? ResponsiveTableVariant.centeredoverflow : ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll &&\n !canUseHorizontalScroll &&\n breakpointConfig.fallbackVariant !== ResponsiveTableVariant.horizontalscroll\n ) {\n return {\n variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n return breakpointConfig;\n};\n\n/**\n * Finn klassenavn for responsiv oppførsel\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns Klassenavn\n */\nexport const getBreakpointClass = (config?: BreakpointConfig): string | undefined =>\n config && configUsesCss(config) ? mapConfigToClass(config) : undefined;\n\n/**\n * Finn riktig posisjon for horisontal sentrering av tabell som skal vises \"centeredoverflow\"\n * @param parentWidth Bredde på element som tabellen ligger i\n * @param tableWidth Bredde på tabellen\n * @returns Styling som posisjonerer tabellen riktig\n */\nexport const getCenteredOverflowTableStyle = (parentWidth: number, tableWidth: number): React.CSSProperties | undefined => {\n if (parentWidth >= tableWidth) {\n return;\n }\n\n const COLUMN_GUTTER_WIDTH_PX = 8;\n\n return { left: `${(parentWidth - tableWidth) / 2 - COLUMN_GUTTER_WIDTH_PX}px` };\n};\n\n/**\n * Map children and inject the `mode` prop into element children, but never on React.Fragment.\n * If a Fragment is encountered, its children are mapped and updated, while the Fragment wrapper is preserved.\n */\nexport const mapChildrenWithMode = (children: React.ReactNode, mode: ModeType | undefined): React.ReactNode =>\n React.Children.map(children, child => {\n if (!React.isValidElement(child)) return child;\n if (child.type === React.Fragment) {\n const fragmentChildren = (child.props as { children?: React.ReactNode }).children;\n const mapped = React.Children.map(fragmentChildren, gc =>\n React.isValidElement<{ mode?: ModeType }>(gc) ? React.cloneElement(gc, { mode }) : gc\n );\n return React.cloneElement(child, undefined, mapped);\n }\n return React.cloneElement(child as React.ReactElement<{ mode?: ModeType }>, { mode });\n });\n\n/**\n * Create a shallow copy of an object with specific keys omitted.\n */\nexport const omitProps = <T extends Record<PropertyKey, unknown>>(obj: T, keys: Array<keyof T>): Partial<T> => {\n const clone: Partial<T> = { ...obj };\n for (const k of keys) {\n delete clone[k];\n }\n return clone;\n};\n"],"mappings":";;;;;AAgBA,IAAM,iBAAiB,WACrB,OAAO,YAAY,uBAAuB,oBAAoB,OAAO,YAAY,uBAAuB;AAO1G,IAAM,oBAAoB,WACxB,OAAO,YAAY,sBAAsB,OAAO,YAAY,UAAU,YAAO,UAAU,OAAO,QAAQ,GAAG,OAAO,gBAAgB;AAQlI,IAAM,+BAA+B,GAAqB,MACxD,WAAW,EAAE,cAAc,WAAW,EAAE;AAQ1C,IAAM,+BAA+B,QAA0B,eAC7D,WAAW,OAAO,eAAe;AAQnC,IAAM,0BAA0B,QAA+C,eAAyD;AACtI,KAAI,MAAM,QAAQ,OAAO,EAAE;AACzB,SAAO,KAAK,4BAA4B;AAExC,SAAO,OAAO,MAAK,MAAK,4BAA4B,GAAG,WAAW,CAAC;YAC1D,UAAU,4BAA4B,QAAQ,WAAW,CAClE,QAAO;;AAWX,MAAa,oBACX,QACA,YACA,YACA,gBAC0D;CAC1D,MAAM,mBAAmB,uBAAuB,QAAQ,WAAW;CACnE,MAAM,yBAAyB,eAAe;CAC9C,MAAM,yBAAyB,cAAc;AAE7C,KAAI,CAAC,iBACH;AAGF,KACE,iBAAiB,YAAY,uBAAuB,oBACpD,CAAC,0BACD,iBAAiB,oBAAoB,uBAAuB,iBAE5D,QAAO;EACL,SAAS,yBAAyB,uBAAuB,mBAAmB,uBAAuB;EACnG,YAAY,iBAAiB;EAC9B;AAGH,KACE,iBAAiB,YAAY,uBAAuB,oBACpD,CAAC,0BACD,iBAAiB,oBAAoB,uBAAuB,iBAE5D,QAAO;EACL,SAAS,iBAAiB,mBAAmB,uBAAuB;EACpE,YAAY,iBAAiB;EAC9B;AAGH,KACE,iBAAiB,YAAY,uBAAuB,oBACpD,CAAC,0BACD,iBAAiB,oBAAoB,uBAAuB,iBAE5D,QAAO;EACL,SAAS,yBAAyB,uBAAuB,mBAAmB,uBAAuB;EACnG,YAAY,iBAAiB;EAC9B;AAGH,KACE,iBAAiB,YAAY,uBAAuB,oBACpD,CAAC,0BACD,iBAAiB,oBAAoB,uBAAuB,iBAE5D,QAAO;EACL,SAAS,iBAAiB,mBAAmB,uBAAuB;EACpE,YAAY,iBAAiB;EAC9B;AAGH,QAAO;;AAQT,MAAa,sBAAsB,WACjC,UAAU,cAAc,OAAO,GAAG,iBAAiB,OAAO,GAAG,KAAA;AAQ/D,MAAa,iCAAiC,aAAqB,eAAwD;AACzH,KAAI,eAAe,WACjB;AAKF,QAAO,EAAE,MAAM,IAAI,cAAc,cAAc,IAFhB,EAE2C,KAAK;;AAOjF,MAAa,uBAAuB,UAA2B,SAC7D,MAAM,SAAS,IAAI,WAAU,UAAS;AACpC,KAAI,CAAC,MAAM,eAAe,MAAM,CAAE,QAAO;AACzC,KAAI,MAAM,SAAS,MAAM,UAAU;EACjC,MAAM,mBAAoB,MAAM,MAAyC;EACzE,MAAM,SAAS,MAAM,SAAS,IAAI,mBAAkB,OAClD,MAAM,eAAoC,GAAG,GAAG,MAAM,aAAa,IAAI,EAAE,MAAM,CAAC,GAAG,GACpF;AACD,SAAO,MAAM,aAAa,OAAO,KAAA,GAAW,OAAO;;AAErD,QAAO,MAAM,aAAa,OAAkD,EAAE,MAAM,CAAC;EACrF;AAKJ,MAAa,aAAqD,KAAQ,SAAqC;CAC7G,MAAMA,QAAoB,EAAE,GAAG,KAAK;AACpC,MAAK,MAAM,KAAK,KACd,QAAO,MAAM;AAEf,QAAO"}
|