pixel-react 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.yarn/install-state.gz +0 -0
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelectTypes.d.ts +2 -0
- package/lib/components/MultiSelect/dropdownTypes.d.ts +2 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.esm.js +502 -2317
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +502 -2318
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/compareArrays/compareArrays.d.ts +11 -0
- package/lib/utils/compareArrays/compareArrays.stories.d.ts +6 -0
- package/lib/utils/compareObjects/compareObjects.d.ts +2 -0
- package/lib/utils/compareObjects/compareObjects.stories.d.ts +6 -0
- package/lib/utils/debounce/debounce.d.ts +6 -0
- package/lib/utils/debounce/debounce.stories.d.ts +6 -0
- package/lib/utils/find/findAndInsert.d.ts +7 -0
- package/lib/utils/find/findAndInsert.stories.d.ts +7 -0
- package/lib/utils/throttle/throttle.d.ts +6 -0
- package/lib/utils/throttle/throttle.stories.d.ts +6 -0
- package/package.json +3 -1
- package/rollup.config.mjs +7 -5
- package/src/assets/icons/filter.svg +5 -0
- package/src/components/Icon/iconList.ts +2 -0
- package/src/components/MultiSelect/Dropdown.scss +27 -16
- package/src/components/MultiSelect/Dropdown.tsx +51 -28
- package/src/components/MultiSelect/MultiSelect.stories.tsx +9 -5
- package/src/components/MultiSelect/MultiSelect.tsx +4 -0
- package/src/components/MultiSelect/MultiSelectTypes.ts +2 -0
- package/src/components/MultiSelect/dropdownTypes.ts +2 -0
- package/src/index.ts +1 -4
- package/src/utils/checkEmpty/checkEmpty.stories.tsx +1 -1
- package/src/utils/checkEmpty/checkEmpty.ts +21 -7
- package/src/utils/compareArrays/compareArrays.stories.tsx +62 -0
- package/src/utils/compareArrays/compareArrays.ts +31 -0
- package/src/utils/compareObjects/compareObjects.stories.tsx +51 -0
- package/src/utils/compareObjects/compareObjects.ts +53 -0
- package/src/utils/debounce/debounce.stories.tsx +81 -0
- package/src/utils/debounce/debounce.ts +28 -0
- package/src/utils/find/findAndInsert.stories.tsx +119 -0
- package/src/utils/find/findAndInsert.ts +49 -0
- package/src/utils/throttle/throttle.stories.tsx +100 -0
- package/src/utils/throttle/throttle.ts +33 -0
- package/vite.config.js +1 -17
package/lib/tsconfig.tsbuildinfo
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"root":["../src/index.ts","../src/styleguide/colorpalette/colorpalette.stories.tsx","../src/styleguide/colorpalette/colorpalette.tsx","../src/styleguide/colorpalette/colorpalettelist.ts","../src/styleguide/colorpalette/index.ts","../src/styleguide/colorpalette/types.ts","../src/styleguide/typography/typography.stories.tsx","../src/styleguide/typography/typography.tsx","../src/styleguide/typography/typographylist.ts","../src/styleguide/typography/types.ts","../src/assets/utils/functionutils.ts","../src/components/accordion/accordion.stories.tsx","../src/components/accordion/accordion.tsx","../src/components/accordion/index.ts","../src/components/accordion/types.ts","../src/components/addresourcebutton/addbutton.stories.tsx","../src/components/addresourcebutton/addbutton.tsx","../src/components/addresourcebutton/index.ts","../src/components/addresourcebutton/type.ts","../src/components/addresourcebutton/arrowsbutton/arrowsbutton.tsx","../src/components/button/button.stories.tsx","../src/components/button/button.tsx","../src/components/button/index.ts","../src/components/button/types.ts","../src/components/charts/donutchart/donutchart.stories.tsx","../src/components/charts/donutchart/donutchart.tsx","../src/components/charts/donutchart/index.ts","../src/components/charts/donutchart/type.ts","../src/components/charts/radialchart/radialchart.stories.tsx","../src/components/charts/radialchart/radialchart.tsx","../src/components/charts/radialchart/index.ts","../src/components/charts/radialchart/types.ts","../src/components/checkbox/checkbox.stories.tsx","../src/components/checkbox/checkbox.tsx","../src/components/checkbox/index.ts","../src/components/checkbox/types.ts","../src/components/chip/chip.stories.tsx","../src/components/chip/chip.tsx","../src/components/chip/index.ts","../src/components/chip/types.ts","../src/components/drawer/drawer.stories.tsx","../src/components/drawer/drawer.tsx","../src/components/drawer/types.ts","../src/components/drawer/index.ts","../src/components/expandablemenu/expandablemenu.stories.tsx","../src/components/expandablemenu/expandablemenu.tsx","../src/components/expandablemenu/index.ts","../src/components/expandablemenu/types.ts","../src/components/filedropzone/dropzone.tsx","../src/components/filedropzone/filedropzone.stories.tsx","../src/components/filedropzone/filedropzone.tsx","../src/components/filedropzone/filepreview.tsx","../src/components/filedropzone/index.ts","../src/components/filedropzone/types.ts","../src/components/form/form.stories.tsx","../src/components/form/form.tsx","../src/components/form/index.ts","../src/components/form/types.ts","../src/components/gridlayout/gridlayout.stories.tsx","../src/components/gridlayout/gridlayout.tsx","../src/components/gridlayout/index.ts","../src/components/gridlayout/types.ts","../src/components/highlighttext/highlighttext.stories.tsx","../src/components/highlighttext/highlighttext.tsx","../src/components/highlighttext/index.ts","../src/components/highlighttext/types.ts","../src/components/icon/icon.stories.tsx","../src/components/icon/icon.tsx","../src/components/icon/iconlist.ts","../src/components/icon/index.ts","../src/components/icon/types.ts","../src/components/input/input.stories.tsx","../src/components/input/input.tsx","../src/components/input/index.ts","../src/components/input/types.ts","../src/components/inputwithdropdown/inputwithdropdown.stories.tsx","../src/components/inputwithdropdown/inputwithdropdown.tsx","../src/components/inputwithdropdown/index.ts","../src/components/inputwithdropdown/types.ts","../src/components/lazyload/lazyload.stories.tsx","../src/components/lazyload/lazyload.ts","../src/components/lazyload/lazyloading.tsx","../src/components/lazyload/index.ts","../src/components/menuoption/menuoption.stories.tsx","../src/components/menuoption/menuoption.tsx","../src/components/menuoption/index.ts","../src/components/menuoption/types.ts","../src/components/minimodal/minimodal.stories.tsx","../src/components/minimodal/minimodal.tsx","../src/components/minimodal/index.ts","../src/components/minimodal/types.ts","../src/components/multiselect/dropdown.tsx","../src/components/multiselect/multiselect.stories.tsx","../src/components/multiselect/multiselect.tsx","../src/components/multiselect/multiselecttypes.ts","../src/components/multiselect/dropdowntypes.ts","../src/components/multiselect/index.ts","../src/components/radiobutton/radiobutton.stories.tsx","../src/components/radiobutton/radiobutton.tsx","../src/components/radiobutton/index.ts","../src/components/radiobutton/radiobuttontypes.tsx","../src/components/radiogroup/radiogroup.stories.tsx","../src/components/radiogroup/radiogroup.tsx","../src/components/radiogroup/index.ts","../src/components/radiogroup/radiogrouptypes.tsx","../src/components/search/search.stories.tsx","../src/components/search/search.tsx","../src/components/search/index.ts","../src/components/search/types.ts","../src/components/select/select.stories.tsx","../src/components/select/select.tsx","../src/components/select/index.ts","../src/components/select/types.ts","../src/components/select/components/dropdown/dropdown.tsx","../src/components/select/components/dropdown/dropdowntypes.ts","../src/components/table/table.stories.tsx","../src/components/table/table.tsx","../src/components/table/types.ts","../src/components/table/index.ts","../src/components/tabletree/tabletree.stories.tsx","../src/components/tabletree/tabletree.tsx","../src/components/tabletree/data.ts","../src/components/tabletree/index.ts","../src/components/tabs/tabs.stories.tsx","../src/components/tabs/tabs.tsx","../src/components/tabs/index.ts","../src/components/tabs/types.ts","../src/components/textarea/textarea.stories.tsx","../src/components/textarea/textarea.tsx","../src/components/textarea/types.ts","../src/components/textarea/index.tsx","../src/components/themeprovider/themeprovider.tsx","../src/components/themeprovider/index.ts","../src/components/themeprovider/types.ts","../src/components/toast/toast.stories.tsx","../src/components/toast/toast.tsx","../src/components/toast/index.ts","../src/components/toast/types.ts","../src/components/toggle/toggle.stories.tsx","../src/components/toggle/toggle.tsx","../src/components/toggle/index.ts","../src/components/toggle/types.ts","../src/components/tooltip/tooltip.stories.tsx","../src/components/tooltip/tooltip.tsx","../src/components/tooltip/index.ts","../src/components/tooltip/types.ts","../src/components/typography/typography.stories.tsx","../src/components/typography/typography.tsx","../src/components/typography/index.ts","../src/components/typography/types.ts","../src/hooks/useclickoutside.tsx","../src/hooks/usefiledropzone.tsx","../src/hooks/useportalposition.tsx","../src/hooks/usetheme.tsx","../src/hooks/keyboardevents/useesckeyevent.tsx","../src/utils/tablecell/tablecell.ts","../src/utils/checkempty/checkempty.stories.tsx","../src/utils/checkempty/checkempty.ts","../src/utils/ffid/ffid.stories.tsx","../src/utils/ffid/ffid.ts","../src/utils/getextension/getextension.stories.tsx","../src/utils/getextension/getextension.ts","../src/utils/truncatetext/truncatetext.stories.tsx","../src/utils/truncatetext/truncatetext.ts"],"version":"5.6.
|
1
|
+
{"root":["../src/index.ts","../src/styleguide/colorpalette/colorpalette.stories.tsx","../src/styleguide/colorpalette/colorpalette.tsx","../src/styleguide/colorpalette/colorpalettelist.ts","../src/styleguide/colorpalette/index.ts","../src/styleguide/colorpalette/types.ts","../src/styleguide/typography/typography.stories.tsx","../src/styleguide/typography/typography.tsx","../src/styleguide/typography/typographylist.ts","../src/styleguide/typography/types.ts","../src/assets/utils/functionutils.ts","../src/components/accordion/accordion.stories.tsx","../src/components/accordion/accordion.tsx","../src/components/accordion/index.ts","../src/components/accordion/types.ts","../src/components/addresourcebutton/addbutton.stories.tsx","../src/components/addresourcebutton/addbutton.tsx","../src/components/addresourcebutton/index.ts","../src/components/addresourcebutton/type.ts","../src/components/addresourcebutton/arrowsbutton/arrowsbutton.tsx","../src/components/button/button.stories.tsx","../src/components/button/button.tsx","../src/components/button/index.ts","../src/components/button/types.ts","../src/components/charts/donutchart/donutchart.stories.tsx","../src/components/charts/donutchart/donutchart.tsx","../src/components/charts/donutchart/index.ts","../src/components/charts/donutchart/type.ts","../src/components/charts/radialchart/radialchart.stories.tsx","../src/components/charts/radialchart/radialchart.tsx","../src/components/charts/radialchart/index.ts","../src/components/charts/radialchart/types.ts","../src/components/checkbox/checkbox.stories.tsx","../src/components/checkbox/checkbox.tsx","../src/components/checkbox/index.ts","../src/components/checkbox/types.ts","../src/components/chip/chip.stories.tsx","../src/components/chip/chip.tsx","../src/components/chip/index.ts","../src/components/chip/types.ts","../src/components/drawer/drawer.stories.tsx","../src/components/drawer/drawer.tsx","../src/components/drawer/types.ts","../src/components/drawer/index.ts","../src/components/expandablemenu/expandablemenu.stories.tsx","../src/components/expandablemenu/expandablemenu.tsx","../src/components/expandablemenu/index.ts","../src/components/expandablemenu/types.ts","../src/components/filedropzone/dropzone.tsx","../src/components/filedropzone/filedropzone.stories.tsx","../src/components/filedropzone/filedropzone.tsx","../src/components/filedropzone/filepreview.tsx","../src/components/filedropzone/index.ts","../src/components/filedropzone/types.ts","../src/components/form/form.stories.tsx","../src/components/form/form.tsx","../src/components/form/index.ts","../src/components/form/types.ts","../src/components/gridlayout/gridlayout.stories.tsx","../src/components/gridlayout/gridlayout.tsx","../src/components/gridlayout/index.ts","../src/components/gridlayout/types.ts","../src/components/highlighttext/highlighttext.stories.tsx","../src/components/highlighttext/highlighttext.tsx","../src/components/highlighttext/index.ts","../src/components/highlighttext/types.ts","../src/components/icon/icon.stories.tsx","../src/components/icon/icon.tsx","../src/components/icon/iconlist.ts","../src/components/icon/index.ts","../src/components/icon/types.ts","../src/components/input/input.stories.tsx","../src/components/input/input.tsx","../src/components/input/index.ts","../src/components/input/types.ts","../src/components/inputwithdropdown/inputwithdropdown.stories.tsx","../src/components/inputwithdropdown/inputwithdropdown.tsx","../src/components/inputwithdropdown/index.ts","../src/components/inputwithdropdown/types.ts","../src/components/lazyload/lazyload.stories.tsx","../src/components/lazyload/lazyload.ts","../src/components/lazyload/lazyloading.tsx","../src/components/lazyload/index.ts","../src/components/menuoption/menuoption.stories.tsx","../src/components/menuoption/menuoption.tsx","../src/components/menuoption/index.ts","../src/components/menuoption/types.ts","../src/components/minimodal/minimodal.stories.tsx","../src/components/minimodal/minimodal.tsx","../src/components/minimodal/index.ts","../src/components/minimodal/types.ts","../src/components/multiselect/dropdown.tsx","../src/components/multiselect/multiselect.stories.tsx","../src/components/multiselect/multiselect.tsx","../src/components/multiselect/multiselecttypes.ts","../src/components/multiselect/dropdowntypes.ts","../src/components/multiselect/index.ts","../src/components/radiobutton/radiobutton.stories.tsx","../src/components/radiobutton/radiobutton.tsx","../src/components/radiobutton/index.ts","../src/components/radiobutton/radiobuttontypes.tsx","../src/components/radiogroup/radiogroup.stories.tsx","../src/components/radiogroup/radiogroup.tsx","../src/components/radiogroup/index.ts","../src/components/radiogroup/radiogrouptypes.tsx","../src/components/search/search.stories.tsx","../src/components/search/search.tsx","../src/components/search/index.ts","../src/components/search/types.ts","../src/components/select/select.stories.tsx","../src/components/select/select.tsx","../src/components/select/index.ts","../src/components/select/types.ts","../src/components/select/components/dropdown/dropdown.tsx","../src/components/select/components/dropdown/dropdowntypes.ts","../src/components/table/table.stories.tsx","../src/components/table/table.tsx","../src/components/table/types.ts","../src/components/table/index.ts","../src/components/tabletree/tabletree.stories.tsx","../src/components/tabletree/tabletree.tsx","../src/components/tabletree/data.ts","../src/components/tabletree/index.ts","../src/components/tabs/tabs.stories.tsx","../src/components/tabs/tabs.tsx","../src/components/tabs/index.ts","../src/components/tabs/types.ts","../src/components/textarea/textarea.stories.tsx","../src/components/textarea/textarea.tsx","../src/components/textarea/types.ts","../src/components/textarea/index.tsx","../src/components/themeprovider/themeprovider.tsx","../src/components/themeprovider/index.ts","../src/components/themeprovider/types.ts","../src/components/toast/toast.stories.tsx","../src/components/toast/toast.tsx","../src/components/toast/index.ts","../src/components/toast/types.ts","../src/components/toggle/toggle.stories.tsx","../src/components/toggle/toggle.tsx","../src/components/toggle/index.ts","../src/components/toggle/types.ts","../src/components/tooltip/tooltip.stories.tsx","../src/components/tooltip/tooltip.tsx","../src/components/tooltip/index.ts","../src/components/tooltip/types.ts","../src/components/typography/typography.stories.tsx","../src/components/typography/typography.tsx","../src/components/typography/index.ts","../src/components/typography/types.ts","../src/hooks/useclickoutside.tsx","../src/hooks/usefiledropzone.tsx","../src/hooks/useportalposition.tsx","../src/hooks/usetheme.tsx","../src/hooks/keyboardevents/useesckeyevent.tsx","../src/utils/tablecell/tablecell.ts","../src/utils/checkempty/checkempty.stories.tsx","../src/utils/checkempty/checkempty.ts","../src/utils/comparearrays/comparearrays.stories.tsx","../src/utils/comparearrays/comparearrays.ts","../src/utils/compareobjects/compareobjects.stories.tsx","../src/utils/compareobjects/compareobjects.ts","../src/utils/debounce/debounce.stories.tsx","../src/utils/debounce/debounce.ts","../src/utils/ffid/ffid.stories.tsx","../src/utils/ffid/ffid.ts","../src/utils/find/findandinsert.stories.tsx","../src/utils/find/findandinsert.ts","../src/utils/getextension/getextension.stories.tsx","../src/utils/getextension/getextension.ts","../src/utils/throttle/throttle.stories.tsx","../src/utils/throttle/throttle.ts","../src/utils/truncatetext/truncatetext.stories.tsx","../src/utils/truncatetext/truncatetext.ts"],"version":"5.6.3"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export type AnyObject = Record<string, unknown>;
|
2
|
+
/**
|
3
|
+
* Compare two arrays for equality.
|
4
|
+
* This function checks if both arrays contain the same elements in the same order,
|
5
|
+
* including nested structures.
|
6
|
+
*
|
7
|
+
* @param arr1 - The first array to compare.
|
8
|
+
* @param arr2 - The second array to compare.
|
9
|
+
* @returns - A boolean indicating if the arrays are equal.
|
10
|
+
*/
|
11
|
+
export declare const compareArrays: (arr1: unknown[], arr2: unknown[]) => boolean;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
declare const _default: {
|
2
|
+
title: string;
|
3
|
+
component: (obj1: import("./compareObjects").AnyObject | null, obj2: import("./compareObjects").AnyObject | null) => boolean;
|
4
|
+
};
|
5
|
+
export default _default;
|
6
|
+
export declare const Default: () => import("react/jsx-runtime").JSX.Element;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export type AnyObject = {
|
2
|
+
id: number;
|
3
|
+
[key: string]: any;
|
4
|
+
};
|
5
|
+
export declare function findAndInsert<T extends AnyObject>(data: T[], key: keyof T, targetId: number, newEntry: T, insertPosition: 'above' | 'below' | 'replace', childrenKey?: string): {
|
6
|
+
updatedArray: T[];
|
7
|
+
} | null;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "pixel-react",
|
3
3
|
"description": "Great for pixel-perfect, design-focused components in React",
|
4
|
-
"version": "1.0.
|
4
|
+
"version": "1.0.2",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"module": "lib/index.esm.js",
|
7
7
|
"types": "lib/index.d.ts",
|
@@ -10,7 +10,9 @@
|
|
10
10
|
},
|
11
11
|
"license": "MIT",
|
12
12
|
"devDependencies": {
|
13
|
+
"@babel/preset-react": "^7.25.9",
|
13
14
|
"@chromatic-com/storybook": "^2.0.2",
|
15
|
+
"@rollup/plugin-babel": "^6.0.4",
|
14
16
|
"@rollup/plugin-commonjs": "^25.0.7",
|
15
17
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
16
18
|
"@rollup/plugin-typescript": "^11.1.6",
|
package/rollup.config.mjs
CHANGED
@@ -4,12 +4,10 @@ import commonjs from '@rollup/plugin-commonjs';
|
|
4
4
|
import typescript from '@rollup/plugin-typescript';
|
5
5
|
import postcss from 'rollup-plugin-postcss';
|
6
6
|
import dts from 'rollup-plugin-dts';
|
7
|
-
import
|
7
|
+
import { babel } from '@rollup/plugin-babel'; // Import Babel plugin
|
8
8
|
import svgrPlugin from 'vite-plugin-svgr';
|
9
9
|
import { createRequire } from 'node:module';
|
10
10
|
|
11
|
-
// This is required to read package.json file when
|
12
|
-
// using Native ES modules in Node.js
|
13
11
|
const requireFile = createRequire(import.meta.url);
|
14
12
|
const packageJson = requireFile('./package.json');
|
15
13
|
|
@@ -34,11 +32,15 @@ export default [
|
|
34
32
|
peerDepsExternal(),
|
35
33
|
resolve(),
|
36
34
|
commonjs(),
|
37
|
-
typescript(),
|
35
|
+
typescript(),
|
38
36
|
postcss({
|
39
37
|
extensions: ['.scss'],
|
40
38
|
}),
|
41
|
-
|
39
|
+
babel({
|
40
|
+
presets: ['@babel/preset-react'],
|
41
|
+
babelHelpers: 'bundled',
|
42
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
43
|
+
}), // Use Babel to handle JSX instead of Vite React
|
42
44
|
svgrPlugin({
|
43
45
|
svgrOptions: {
|
44
46
|
icon: true,
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<svg width="16" height="15" viewBox="0 0 16 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<path
|
3
|
+
d="M12.7145 0.400147H2.8385C2.43037 0.399936 2.03133 0.520731 1.69184 0.747262C1.35234 0.973792 1.08763 1.29589 0.931152 1.67284C0.774679 2.04979 0.733473 2.46466 0.812743 2.86503C0.892012 3.26539 1.0882 3.63326 1.3765 3.92215L5.6195 8.16515V13.1001C5.62058 13.3566 5.69752 13.6071 5.84062 13.82C5.98373 14.0328 6.18661 14.1986 6.42373 14.2964C6.66085 14.3943 6.9216 14.4197 7.17317 14.3697C7.42475 14.3196 7.65589 14.1963 7.8375 14.0151L9.4565 12.4001C9.60732 12.2508 9.7269 12.0728 9.80828 11.8768C9.88965 11.6807 9.9312 11.4704 9.9305 11.2581V8.15815L14.1765 3.91615C14.3675 3.72539 14.5189 3.4987 14.6219 3.24914C14.7249 2.99959 14.7774 2.73211 14.7765 2.46215C14.7754 1.91559 14.5579 1.39173 14.1714 1.00526C13.7849 0.618789 13.2611 0.401204 12.7145 0.400147ZM13.4095 3.15715L9.1715 7.40015C9.07035 7.50015 8.99014 7.61931 8.93554 7.75065C8.88094 7.882 8.85305 8.02291 8.8535 8.16515V11.2651C8.85142 11.4076 8.79572 11.544 8.6975 11.6471L7.0815 13.2641C7.04817 13.2903 7.00843 13.307 6.96643 13.3126C6.92444 13.3182 6.88171 13.3124 6.8427 13.2959C6.8037 13.2793 6.76984 13.2526 6.74466 13.2186C6.71947 13.1845 6.70388 13.1443 6.6995 13.1021V8.16515C6.69983 8.02382 6.67186 7.88385 6.61724 7.75349C6.56263 7.62314 6.48247 7.50504 6.3815 7.40615L2.1445 3.15715C2.00588 3.01997 1.91124 2.84462 1.87265 2.65346C1.83406 2.46229 1.85326 2.26396 1.92782 2.08375C2.00237 1.90354 2.12889 1.7496 2.29126 1.64157C2.45362 1.53354 2.64448 1.4763 2.8395 1.47715H12.7145C12.9095 1.4763 13.1004 1.53354 13.2627 1.64157C13.4251 1.7496 13.5516 1.90354 13.6262 2.08375C13.7007 2.26396 13.7199 2.46229 13.6814 2.65346C13.6428 2.84462 13.5481 3.01997 13.4095 3.15715Z"
|
4
|
+
fill="currentColor" stroke="currentColor" stroke-width="0.5" />
|
5
|
+
</svg>
|
@@ -28,6 +28,7 @@ import CheckMarkIcon from '../../assets/icons/check_mark.svg?react';
|
|
28
28
|
import WrongMarkIcon from '../../assets/icons/wrong_mark.svg?react';
|
29
29
|
import Tick from '../../assets/Icons/tick_icon.svg?react';
|
30
30
|
import Search from '../../assets/icons/search.svg?react';
|
31
|
+
import Filter from '../../assets/icons/filter.svg?react';
|
31
32
|
|
32
33
|
//icons
|
33
34
|
Components['delete'] = DeleteIcon;
|
@@ -58,5 +59,6 @@ Components['wrong_mark'] = WrongMarkIcon;
|
|
58
59
|
Components['tick'] = Tick;
|
59
60
|
Components['arrow_right'] = ArrowRight;
|
60
61
|
Components['search'] = Search;
|
62
|
+
Components['filter'] = Filter;
|
61
63
|
|
62
64
|
export default Components;
|
@@ -10,25 +10,27 @@
|
|
10
10
|
box-sizing: border-box;
|
11
11
|
margin-block: 4px;
|
12
12
|
max-height: 160px;
|
13
|
-
overflow-y: auto; // Change from scroll to auto to avoid arrow buttons
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
.ff-multiselect-options-wrapper {
|
15
|
+
max-height: 128px;
|
16
|
+
overflow-y: auto;
|
17
|
+
&::-webkit-scrollbar {
|
18
|
+
width: 4px;
|
19
|
+
height: 40px;
|
20
|
+
border-radius: 12px 0px 0px 0px;
|
21
|
+
background: var(--description-text);
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
&-track {
|
24
|
+
background: var(--ff-select-scroll-track-bg);
|
25
|
+
}
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
&-thumb {
|
28
|
+
background: var(--ff-select-scroll-thumb-color);
|
29
|
+
border-radius: 10px;
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
&:hover {
|
32
|
+
background: var(--ff-select-scroll-thumb-hover);
|
33
|
+
}
|
32
34
|
}
|
33
35
|
}
|
34
36
|
}
|
@@ -53,7 +55,7 @@
|
|
53
55
|
|
54
56
|
.dropdown-option-label {
|
55
57
|
@extend .fontMd;
|
56
|
-
color: var(--
|
58
|
+
color: var(--ff-select-text-color);
|
57
59
|
}
|
58
60
|
&:hover {
|
59
61
|
background-color: var(--hover-color);
|
@@ -63,4 +65,13 @@
|
|
63
65
|
&:focus {
|
64
66
|
outline: none;
|
65
67
|
}
|
68
|
+
.select-button-container {
|
69
|
+
box-sizing: border-box;
|
70
|
+
width: 100%;
|
71
|
+
border-top: 1px solid var(--slider-table-color);
|
72
|
+
height: 30px;
|
73
|
+
display: flex;
|
74
|
+
justify-content: center;
|
75
|
+
align-items: center;
|
76
|
+
}
|
66
77
|
}
|
@@ -1,9 +1,10 @@
|
|
1
|
-
import { forwardRef, useContext } from 'react';
|
1
|
+
import { forwardRef, useContext, useMemo } from 'react';
|
2
2
|
import { dropdownDefaultCSSData, DropdownProps } from './dropdownTypes';
|
3
3
|
|
4
4
|
import './Dropdown.scss';
|
5
5
|
import { ThemeContext } from '../ThemeProvider/ThemeProvider';
|
6
6
|
import classNames from 'classnames';
|
7
|
+
import Button from '../Button';
|
7
8
|
|
8
9
|
const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
|
9
10
|
(
|
@@ -13,6 +14,8 @@ const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
|
|
13
14
|
searchedKeyword = '',
|
14
15
|
dropdownPosition = {},
|
15
16
|
zIndex,
|
17
|
+
withSelectButton,
|
18
|
+
onSelect,
|
16
19
|
},
|
17
20
|
ref
|
18
21
|
) => {
|
@@ -23,19 +26,29 @@ const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
|
|
23
26
|
: [];
|
24
27
|
const { verticalMargin, optionHeight, maxDropdownHeight } =
|
25
28
|
dropdownDefaultCSSData;
|
26
|
-
const dropdownHeight = Math.min(
|
27
|
-
filteredOptions.length * optionHeight,
|
28
|
-
maxDropdownHeight
|
29
|
-
);
|
30
|
-
const isEnoughBottomSpaceAvailable =
|
31
|
-
dropdownPosition.fromBottom >= dropdownHeight + verticalMargin;
|
32
29
|
|
33
|
-
const topPosition =
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
const topPosition = useMemo(() => {
|
31
|
+
let calculatedDropdownHeight = Math.min(
|
32
|
+
filteredOptions.length * optionHeight,
|
33
|
+
maxDropdownHeight
|
34
|
+
);
|
35
|
+
|
36
|
+
if (filteredOptions.length < 5 && withSelectButton) {
|
37
|
+
calculatedDropdownHeight += 32;
|
38
|
+
}
|
39
|
+
|
40
|
+
const isEnoughSpaceAvailable =
|
41
|
+
dropdownPosition.fromBottom >=
|
42
|
+
calculatedDropdownHeight + verticalMargin;
|
43
|
+
const topPosition = isEnoughSpaceAvailable
|
44
|
+
? dropdownPosition.top
|
45
|
+
: dropdownPosition.top -
|
46
|
+
calculatedDropdownHeight -
|
47
|
+
dropdownPosition.selectHeight -
|
48
|
+
2 * verticalMargin;
|
49
|
+
|
50
|
+
return topPosition;
|
51
|
+
}, [filteredOptions.length, withSelectButton, dropdownPosition]);
|
39
52
|
const themeContext = useContext(ThemeContext);
|
40
53
|
const currentTheme = themeContext?.currentTheme;
|
41
54
|
return (
|
@@ -52,22 +65,32 @@ const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
|
|
52
65
|
zIndex,
|
53
66
|
}}
|
54
67
|
>
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
role="option"
|
63
|
-
className={`dropdown-option-container`}
|
64
|
-
key={info.label}
|
65
|
-
onClick={() => handleOptionChange(info, !info.isChecked)}
|
66
|
-
>
|
67
|
-
<input type="checkbox" checked={info.isChecked} readOnly />
|
68
|
-
<span className="dropdown-option-label">{info.label}</span>
|
68
|
+
<div
|
69
|
+
className="ff-multiselect-options-wrapper"
|
70
|
+
style={{ maxHeight: withSelectButton ? '128px' : '160px' }}
|
71
|
+
>
|
72
|
+
{filteredOptions.length === 0 ? (
|
73
|
+
<div className="dropdown-option-container ">
|
74
|
+
<p className="no-options">No Option</p>
|
69
75
|
</div>
|
70
|
-
)
|
76
|
+
) : (
|
77
|
+
filteredOptions.map((info) => (
|
78
|
+
<div
|
79
|
+
role="option"
|
80
|
+
className={`dropdown-option-container`}
|
81
|
+
key={info.label}
|
82
|
+
onClick={() => handleOptionChange(info, !info.isChecked)}
|
83
|
+
>
|
84
|
+
<input type="checkbox" checked={info.isChecked} readOnly />
|
85
|
+
<span className="dropdown-option-label">{info.label}</span>
|
86
|
+
</div>
|
87
|
+
))
|
88
|
+
)}
|
89
|
+
</div>
|
90
|
+
{withSelectButton && filteredOptions.length > 0 && (
|
91
|
+
<div className="select-button-container">
|
92
|
+
<Button label="Select" variant="tertiary" onClick={onSelect} />
|
93
|
+
</div>
|
71
94
|
)}
|
72
95
|
</div>
|
73
96
|
);
|
@@ -22,17 +22,21 @@ export const Default: Story = {
|
|
22
22
|
args: {
|
23
23
|
...defaultArgs,
|
24
24
|
required: true,
|
25
|
+
withSelectButton: true,
|
26
|
+
onSelect: () => {
|
27
|
+
alert('selected');
|
28
|
+
},
|
25
29
|
options: [
|
26
30
|
{ label: 'Apple', value: 'apple' },
|
27
31
|
{ label: 'Banana', value: 'banana' },
|
28
32
|
{ label: 'Cherry', value: 'cherry' },
|
29
33
|
{ label: 'Date', value: 'date' },
|
30
34
|
{ label: 'Grape', value: 'grape' },
|
31
|
-
{ label: 'Kiwi', value: 'kiwi' },
|
32
|
-
{ label: 'Mango', value: 'mango' },
|
33
|
-
{ label: 'Orange', value: 'orange' },
|
34
|
-
{ label: 'Peach', value: 'peach' },
|
35
|
-
{ label: 'Strawberry', value: 'strawberry' },
|
35
|
+
// { label: 'Kiwi', value: 'kiwi' },
|
36
|
+
// { label: 'Mango', value: 'mango' },
|
37
|
+
// { label: 'Orange', value: 'orange' },
|
38
|
+
// { label: 'Peach', value: 'peach' },
|
39
|
+
// { label: 'Strawberry', value: 'strawberry' },
|
36
40
|
],
|
37
41
|
// selectedOptions: [{ label: 'Apple', value: 'apple' }],
|
38
42
|
},
|
@@ -38,6 +38,8 @@ const MultiSelect = ({
|
|
38
38
|
required = false,
|
39
39
|
disabled = false,
|
40
40
|
errorMessage = 'Fill this field',
|
41
|
+
withSelectButton = false,
|
42
|
+
onSelect = () => {},
|
41
43
|
}: MultiSelectProps) => {
|
42
44
|
const [isOpen, setIsOpen] = useState<boolean>(false);
|
43
45
|
const [allOptions, setAllOptions] = useState(options);
|
@@ -249,6 +251,8 @@ const MultiSelect = ({
|
|
249
251
|
options={allOptions}
|
250
252
|
dropdownPosition={dropdownPosition}
|
251
253
|
zIndex={zIndex}
|
254
|
+
withSelectButton={withSelectButton}
|
255
|
+
onSelect={onSelect}
|
252
256
|
/>,
|
253
257
|
document.body
|
254
258
|
)}
|
package/src/index.ts
CHANGED
@@ -26,7 +26,6 @@ import Typography from './components/Typography';
|
|
26
26
|
import useTheme from './hooks/useTheme';
|
27
27
|
import Form from './components/Form';
|
28
28
|
|
29
|
-
|
30
29
|
import InputWithDropdown from './components/InputWithDropdown';
|
31
30
|
import RadioButton from './components/RadioButton';
|
32
31
|
import RadioGroup from './components/RadioGroup';
|
@@ -35,7 +34,7 @@ import TableTree from './components/TableTree';
|
|
35
34
|
import Tabs from './components/Tabs';
|
36
35
|
import HighlightText from './components/HighlightText';
|
37
36
|
import Checkbox from './components/Checkbox';
|
38
|
-
import Search from './components/Search/Search'
|
37
|
+
import Search from './components/Search/Search';
|
39
38
|
|
40
39
|
// Utils imports
|
41
40
|
import { checkEmpty } from './utils/checkEmpty/checkEmpty';
|
@@ -69,11 +68,9 @@ export {
|
|
69
68
|
useTheme,
|
70
69
|
InputWithDropdown,
|
71
70
|
Table,
|
72
|
-
|
73
71
|
RadioButton,
|
74
72
|
RadioGroup,
|
75
73
|
Form,
|
76
|
-
|
77
74
|
MiniModal,
|
78
75
|
Container,
|
79
76
|
Row,
|
@@ -1,10 +1,24 @@
|
|
1
1
|
type valueType = any;
|
2
2
|
|
3
|
-
export const checkEmpty = (value: valueType) => {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
export const checkEmpty = (value: valueType): boolean => {
|
4
|
+
// Check for null or undefined
|
5
|
+
if (value == null) return true;
|
6
|
+
|
7
|
+
// Check for strings
|
8
|
+
if (typeof value === 'string') return value.trim().length === 0;
|
9
|
+
|
10
|
+
// Check for arrays
|
11
|
+
if (Array.isArray(value)) return value.length === 0;
|
12
|
+
|
13
|
+
// Check for objects
|
14
|
+
if (typeof value === 'object') {
|
15
|
+
// Handle Map and Set
|
16
|
+
if (value instanceof Map || value instanceof Set) return value.size === 0;
|
17
|
+
|
18
|
+
// Handle regular objects
|
19
|
+
return Object.keys(value).length === 0;
|
20
|
+
}
|
21
|
+
|
22
|
+
// For all other types (numbers, booleans, etc.), return false as they are not "empty"
|
23
|
+
return false;
|
10
24
|
};
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import { compareArrays } from './compareArrays'; // Adjust the import path as necessary
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: 'Utils/compareArrays',
|
5
|
+
component: compareArrays,
|
6
|
+
};
|
7
|
+
|
8
|
+
export const Default = () => {
|
9
|
+
const testCases = [
|
10
|
+
{ arr1: [1, 2, 3], arr2: [1, 2, 3], expected: true },
|
11
|
+
{ arr1: [1, 2, 3], arr2: [1, 2, 4], expected: false },
|
12
|
+
{ arr1: [1, { a: 1 }], arr2: [1, { a: 1 }], expected: true },
|
13
|
+
{ arr1: [1, { a: 1 }], arr2: [1, { a: 2 }], expected: false },
|
14
|
+
{ arr1: [1, 2, 3], arr2: [1, 2, 3, 4], expected: false },
|
15
|
+
{ arr1: [], arr2: [], expected: true },
|
16
|
+
{ arr1: [null, undefined], arr2: [null, undefined], expected: true },
|
17
|
+
{ arr1: [null], arr2: [undefined], expected: false },
|
18
|
+
{
|
19
|
+
arr1: [
|
20
|
+
[1, 2],
|
21
|
+
[3, 4],
|
22
|
+
],
|
23
|
+
arr2: [
|
24
|
+
[1, 2],
|
25
|
+
[3, 4],
|
26
|
+
],
|
27
|
+
expected: true,
|
28
|
+
},
|
29
|
+
{
|
30
|
+
arr1: [
|
31
|
+
[1, 2],
|
32
|
+
[3, 4],
|
33
|
+
],
|
34
|
+
arr2: [
|
35
|
+
[1, 2],
|
36
|
+
[4, 3],
|
37
|
+
],
|
38
|
+
expected: false,
|
39
|
+
},
|
40
|
+
];
|
41
|
+
|
42
|
+
return (
|
43
|
+
<div>
|
44
|
+
<h1>
|
45
|
+
<u>compareArrays(arr1, arr2)</u> - Expected / Actual
|
46
|
+
</h1>
|
47
|
+
{testCases.map(({ arr1, arr2, expected }, index) => {
|
48
|
+
const actual = compareArrays(arr1, arr2);
|
49
|
+
return (
|
50
|
+
<div key={index}>
|
51
|
+
<strong>
|
52
|
+
compareArrays({JSON.stringify(arr1)}, {JSON.stringify(arr2)}) -
|
53
|
+
</strong>
|
54
|
+
<span style={{ color: actual === expected ? 'green' : 'red' }}>
|
55
|
+
{` Expected: ${expected}, Actual: ${actual}`}
|
56
|
+
</span>
|
57
|
+
</div>
|
58
|
+
);
|
59
|
+
})}
|
60
|
+
</div>
|
61
|
+
);
|
62
|
+
};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { compareObjects } from '../compareObjects/compareObjects';
|
2
|
+
|
3
|
+
// Define a type for any object
|
4
|
+
export type AnyObject = Record<string, unknown>;
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Compare two arrays for equality.
|
8
|
+
* This function checks if both arrays contain the same elements in the same order,
|
9
|
+
* including nested structures.
|
10
|
+
*
|
11
|
+
* @param arr1 - The first array to compare.
|
12
|
+
* @param arr2 - The second array to compare.
|
13
|
+
* @returns - A boolean indicating if the arrays are equal.
|
14
|
+
*/
|
15
|
+
export const compareArrays = (arr1: unknown[], arr2: unknown[]): boolean => {
|
16
|
+
// Check if both are arrays
|
17
|
+
if (!Array.isArray(arr1) || !Array.isArray(arr2)) return false;
|
18
|
+
|
19
|
+
// Check if lengths are different
|
20
|
+
if (arr1.length !== arr2.length) return false;
|
21
|
+
|
22
|
+
// Compare each element
|
23
|
+
return arr1.every((element, index) => {
|
24
|
+
const otherElement = arr2[index];
|
25
|
+
// Recursively compare objects or arrays, or check for strict equality
|
26
|
+
return compareObjects(
|
27
|
+
element as AnyObject | null,
|
28
|
+
otherElement as AnyObject | null
|
29
|
+
);
|
30
|
+
});
|
31
|
+
};
|