From a44938643c710f42134ad6ee252f2593af2e1245 Mon Sep 17 00:00:00 2001 From: "shashank.mishra_once" Date: Wed, 12 Jun 2024 12:47:16 +0530 Subject: [PATCH 01/11] feat: ONCEHUB-73610 Optimized select types for dropdown multiselect and quick select --- .../select.type.ts} | 3 ++- src/lib/components/multi-select/README.md | 9 ++++--- .../multi-select/multi-select.stories.tsx | 2 +- .../components/multi-select/multi-select.tsx | 2 +- .../components/quick-multi-select/README.md | 9 ++++--- .../quick-multi-select.stories.tsx | 2 +- .../quick-multi-select/quick-multi-select.tsx | 4 +-- .../quick-multi-select.type.ts | 6 ----- src/lib/components/quick-select/README.md | 9 ++++--- .../quick-select/quick-select.stories.tsx | 3 +-- .../components/quick-select/quick-select.tsx | 2 +- .../quick-select/quick-select.type.ts | 6 ----- src/lib/components/select/README.md | 4 +-- src/lib/components/select/auto-complete.tsx | 16 ++++++------ src/lib/components/select/select.stories.tsx | 25 +++++++++---------- src/lib/components/select/select.tsx | 10 ++++---- src/lib/components/select/select.types.ts | 6 ----- 17 files changed, 51 insertions(+), 67 deletions(-) rename src/lib/{components/multi-select/multi-select.type.ts => Models/select.type.ts} (68%) delete mode 100644 src/lib/components/quick-multi-select/quick-multi-select.type.ts delete mode 100644 src/lib/components/quick-select/quick-select.type.ts delete mode 100644 src/lib/components/select/select.types.ts diff --git a/src/lib/components/multi-select/multi-select.type.ts b/src/lib/Models/select.type.ts similarity index 68% rename from src/lib/components/multi-select/multi-select.type.ts rename to src/lib/Models/select.type.ts index 2bdd689..0051fb2 100644 --- a/src/lib/components/multi-select/multi-select.type.ts +++ b/src/lib/Models/select.type.ts @@ -1,6 +1,7 @@ export interface Option { id: string; text: string; - order: number; + order?: number; + avatar?: string; disabled?: boolean; } diff --git a/src/lib/components/multi-select/README.md b/src/lib/components/multi-select/README.md index b59c199..b61efbc 100644 --- a/src/lib/components/multi-select/README.md +++ b/src/lib/components/multi-select/README.md @@ -19,10 +19,11 @@ Here's an example of how to define the `Option` interface: ```jsx export interface Option { - id: number; - text: string; - order?: number; - disabled?: boolean; + id: string; + text: string; + order: number; + avatar?: string; + disabled?: boolean; } ``` diff --git a/src/lib/components/multi-select/multi-select.stories.tsx b/src/lib/components/multi-select/multi-select.stories.tsx index ea8c5a0..9822a8a 100644 --- a/src/lib/components/multi-select/multi-select.stories.tsx +++ b/src/lib/components/multi-select/multi-select.stories.tsx @@ -1,7 +1,7 @@ import type { Meta, StoryObj } from '@storybook/react'; import React from 'react'; import { MultiSelect } from './multi-select'; -import { Option } from './multi-select.type'; +import { Option } from './../../Models/select.type'; const meta: Meta = { title: 'Basic/MultiSelect', diff --git a/src/lib/components/multi-select/multi-select.tsx b/src/lib/components/multi-select/multi-select.tsx index 3ecce0c..5f249c4 100644 --- a/src/lib/components/multi-select/multi-select.tsx +++ b/src/lib/components/multi-select/multi-select.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useRef, CSSProperties, KeyboardEvent } from 'react'; -import { Option } from './multi-select.type'; +import { Option } from './../../Models/select.type'; import { Button } from '../button/button'; import styles from './multi-select.module.scss'; import luminance from '@oncehub/relative-luminance'; diff --git a/src/lib/components/quick-multi-select/README.md b/src/lib/components/quick-multi-select/README.md index 715af89..eb16152 100644 --- a/src/lib/components/quick-multi-select/README.md +++ b/src/lib/components/quick-multi-select/README.md @@ -19,10 +19,11 @@ Here's an example of how to define the `Option` interface: ```jsx export interface Option { - id: number; - text: string; - order?: number; - disabled?: boolean; + id: string; + text: string; + order: number; + avatar?: string; + disabled?: boolean; } ``` diff --git a/src/lib/components/quick-multi-select/quick-multi-select.stories.tsx b/src/lib/components/quick-multi-select/quick-multi-select.stories.tsx index c5149cb..7adb913 100644 --- a/src/lib/components/quick-multi-select/quick-multi-select.stories.tsx +++ b/src/lib/components/quick-multi-select/quick-multi-select.stories.tsx @@ -1,7 +1,7 @@ import type { Meta, StoryObj } from '@storybook/react'; import { QuickMultiSelect } from './quick-multi-select'; -import { Option } from './quick-multi-select.type'; +import { Option } from './../../Models/select.type'; const meta: Meta = { title: 'Basic/QuickMultiSelect', diff --git a/src/lib/components/quick-multi-select/quick-multi-select.tsx b/src/lib/components/quick-multi-select/quick-multi-select.tsx index c9221f6..6f5a0b8 100644 --- a/src/lib/components/quick-multi-select/quick-multi-select.tsx +++ b/src/lib/components/quick-multi-select/quick-multi-select.tsx @@ -1,7 +1,7 @@ -import React, { CSSProperties, useEffect, useRef, useState } from 'react'; +import React, { CSSProperties, useRef, useState } from 'react'; import { Checkbox } from '../checkbox/checkbox'; import styles from './quick-multi-select.module.scss'; -import { Option } from './quick-multi-select.type'; +import { Option } from './../../Models/select.type'; import luminance from '@oncehub/relative-luminance'; import { ColorsService } from '../colors.service'; diff --git a/src/lib/components/quick-multi-select/quick-multi-select.type.ts b/src/lib/components/quick-multi-select/quick-multi-select.type.ts deleted file mode 100644 index 2bdd689..0000000 --- a/src/lib/components/quick-multi-select/quick-multi-select.type.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface Option { - id: string; - text: string; - order: number; - disabled?: boolean; -} diff --git a/src/lib/components/quick-select/README.md b/src/lib/components/quick-select/README.md index 8217807..12eed64 100644 --- a/src/lib/components/quick-select/README.md +++ b/src/lib/components/quick-select/README.md @@ -19,10 +19,11 @@ Here's an example of how to define the `Option` interface: ```jsx export interface Option { - id: number; - text: string; - order?: number; - disbled?: boolean; + id: string; + text: string; + order: number; + avatar?: string; + disabled?: boolean; } ``` diff --git a/src/lib/components/quick-select/quick-select.stories.tsx b/src/lib/components/quick-select/quick-select.stories.tsx index 5616516..843ea09 100644 --- a/src/lib/components/quick-select/quick-select.stories.tsx +++ b/src/lib/components/quick-select/quick-select.stories.tsx @@ -1,7 +1,6 @@ import type { Meta, StoryObj } from '@storybook/react'; - import { QuickSelect } from './quick-select'; -import { Option } from './quick-select.type'; +import { Option } from './../../Models/select.type'; const meta: Meta = { title: 'Basic/QuickSelect', diff --git a/src/lib/components/quick-select/quick-select.tsx b/src/lib/components/quick-select/quick-select.tsx index 160453b..ffff2c7 100644 --- a/src/lib/components/quick-select/quick-select.tsx +++ b/src/lib/components/quick-select/quick-select.tsx @@ -1,7 +1,7 @@ import { CSSProperties, FC, useState } from 'react'; import styles from './quick-select.module.scss'; import luminance from '@oncehub/relative-luminance'; -import { Option } from './quick-select.type'; +import { Option } from './../../Models/select.type'; import { ColorsService } from '../colors.service'; interface Props { diff --git a/src/lib/components/quick-select/quick-select.type.ts b/src/lib/components/quick-select/quick-select.type.ts deleted file mode 100644 index 2bdd689..0000000 --- a/src/lib/components/quick-select/quick-select.type.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface Option { - id: string; - text: string; - order: number; - disabled?: boolean; -} diff --git a/src/lib/components/select/README.md b/src/lib/components/select/README.md index 62f0abe..abe6910 100644 --- a/src/lib/components/select/README.md +++ b/src/lib/components/select/README.md @@ -36,7 +36,7 @@ const people = [ # Dropdown without search ```ts -const [selected, setSelected] = useState(people.length ? people[0] : null); +const [selected, setSelected] = useState