@dktunited-techoff/techoff-suite-ui 1.5.7 → 1.6.1

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.
Files changed (50) hide show
  1. package/esm/components/TsCheckbox/TsCheckbox.css +0 -3
  2. package/esm/components/TsDropdown/TsDropdown/TsDropdown.css +92 -0
  3. package/esm/components/TsDropdown/TsDropdown/TsDropdown.d.ts +4 -0
  4. package/esm/components/TsDropdown/TsDropdown/TsDropdown.js +73 -0
  5. package/esm/components/TsDropdown/TsDropdown/TsDropdown.js.map +1 -0
  6. package/esm/components/TsDropdown/TsDropdown/TsDropdown.tsx +131 -0
  7. package/esm/components/TsDropdown/TsDropdown/TsDropdown.types.d.ts +13 -0
  8. package/esm/components/TsDropdown/TsDropdown/TsDropdown.types.js +2 -0
  9. package/esm/components/TsDropdown/TsDropdown/TsDropdown.types.js.map +1 -0
  10. package/esm/components/TsDropdown/TsDropdown/TsDropdown.types.ts +13 -0
  11. package/esm/components/TsDropdown/TsDropdown/__stories__/TsDropdown.stories.mdx +68 -0
  12. package/esm/components/TsDropdown/TsDropdown/__stories__/fruits.d.ts +4 -0
  13. package/esm/components/TsDropdown/TsDropdown/__stories__/fruits.js +48 -0
  14. package/esm/components/TsDropdown/TsDropdown/__stories__/fruits.js.map +1 -0
  15. package/esm/components/TsDropdown/TsDropdown/__stories__/fruits.ts +47 -0
  16. package/esm/components/TsInput/TsInput/TsInput.css +1 -0
  17. package/esm/components/TsInput/TsInput/__stories__/TsInput.stories.mdx +6 -1
  18. package/esm/index.d.ts +1 -0
  19. package/esm/index.js +1 -0
  20. package/esm/index.js.map +1 -1
  21. package/lib/components/TsCheckbox/TsCheckbox.css +0 -3
  22. package/lib/components/TsDropdown/TsDropdown/TsDropdown.css +92 -0
  23. package/lib/components/TsDropdown/TsDropdown/TsDropdown.d.ts +4 -0
  24. package/lib/components/TsDropdown/TsDropdown/TsDropdown.js +77 -0
  25. package/lib/components/TsDropdown/TsDropdown/TsDropdown.js.map +1 -0
  26. package/lib/components/TsDropdown/TsDropdown/TsDropdown.tsx +131 -0
  27. package/lib/components/TsDropdown/TsDropdown/TsDropdown.types.d.ts +13 -0
  28. package/lib/components/TsDropdown/TsDropdown/TsDropdown.types.js +3 -0
  29. package/lib/components/TsDropdown/TsDropdown/TsDropdown.types.js.map +1 -0
  30. package/lib/components/TsDropdown/TsDropdown/TsDropdown.types.ts +13 -0
  31. package/lib/components/TsDropdown/TsDropdown/__stories__/TsDropdown.stories.mdx +68 -0
  32. package/lib/components/TsDropdown/TsDropdown/__stories__/fruits.d.ts +4 -0
  33. package/lib/components/TsDropdown/TsDropdown/__stories__/fruits.js +51 -0
  34. package/lib/components/TsDropdown/TsDropdown/__stories__/fruits.js.map +1 -0
  35. package/lib/components/TsDropdown/TsDropdown/__stories__/fruits.ts +47 -0
  36. package/lib/components/TsInput/TsInput/TsInput.css +1 -0
  37. package/lib/components/TsInput/TsInput/__stories__/TsInput.stories.mdx +6 -1
  38. package/lib/index.d.ts +1 -0
  39. package/lib/index.js +1 -0
  40. package/lib/index.js.map +1 -1
  41. package/package.json +1 -1
  42. package/src/components/TsCheckbox/TsCheckbox.css +0 -3
  43. package/src/components/TsDropdown/TsDropdown/TsDropdown.css +92 -0
  44. package/src/components/TsDropdown/TsDropdown/TsDropdown.tsx +131 -0
  45. package/src/components/TsDropdown/TsDropdown/TsDropdown.types.ts +13 -0
  46. package/src/components/TsDropdown/TsDropdown/__stories__/TsDropdown.stories.mdx +68 -0
  47. package/src/components/TsDropdown/TsDropdown/__stories__/fruits.ts +47 -0
  48. package/src/components/TsInput/TsInput/TsInput.css +1 -0
  49. package/src/components/TsInput/TsInput/__stories__/TsInput.stories.mdx +6 -1
  50. package/src/index.ts +1 -0
@@ -0,0 +1,92 @@
1
+ .ts-dropdown-container {
2
+ position: relative;
3
+ width: 100%;
4
+ }
5
+ .ts-dropdown-input {
6
+ display: flex;
7
+ align-items: center;
8
+ width: 100%;
9
+ height: 32px;
10
+ padding-left: 10px;
11
+ border: 1px solid #949494;
12
+ cursor: pointer;
13
+ }
14
+ .ts-dropdown-input--disabled {
15
+ background: #fafafa;
16
+ cursor: not-allowed;
17
+ }
18
+ .ts-dropdown-input--placeholder {
19
+ flex: 1;
20
+ color: #7a7a7a;
21
+ font-weight: 400;
22
+ }
23
+ .ts-dropdown-input--value {
24
+ flex: 1;
25
+ font-weight: 600;
26
+ }
27
+ .ts-dropdown-input--chevron {
28
+ display: flex;
29
+ align-items: center;
30
+ justify-content: center;
31
+ width: 32px;
32
+ height: 32px;
33
+ }
34
+ /* ####### */
35
+ /* LABEL */
36
+ .ts-dropdown-label {
37
+ padding-bottom: 6px;
38
+ }
39
+ /* ###### */
40
+ /* MENU */
41
+ .ts-dropdown-menu-container {
42
+ position: absolute;
43
+ top: calc(100%+8px);
44
+ display: flex;
45
+ flex-direction: column;
46
+ min-width: 100%;
47
+ max-height: 250px;
48
+ padding: 12px;
49
+ box-shadow: 0px 8px 9px 0px #1010101a;
50
+ background: #ffffff;
51
+ overflow: hidden;
52
+ z-index: 10;
53
+ }
54
+ .ts-dropdown-search {
55
+ padding-bottom: 12px;
56
+ margin-bottom: 12px;
57
+ border-bottom: 1px solid #d9dde1;
58
+ }
59
+ .ts-dropdown-menu {
60
+ overflow: auto;
61
+ }
62
+ .ts-dropdown-menu-loader {
63
+ display: flex;
64
+ justify-content: center;
65
+ }
66
+ .ts-dropdown-menu-error-text {
67
+ display: flex;
68
+ justify-content: center;
69
+ color: #7a7a7a;
70
+ font-style: italic;
71
+ }
72
+ .ts-dropdown-menu-item {
73
+ display: flex;
74
+ align-items: center;
75
+ height: 36px;
76
+ padding: 0 12px;
77
+ cursor: pointer;
78
+ }
79
+ .ts-dropdown-menu-item:hover {
80
+ background: #e1e3f5;
81
+ color: #3643ba;
82
+ }
83
+
84
+ /* ######### */
85
+ /* GLOBALS */
86
+ * {
87
+ font-size: 14px;
88
+ outline: none;
89
+ box-sizing: border-box;
90
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
91
+ 'Helvetica Neue', sans-serif;
92
+ }
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import { TsDropdownProps } from './TsDropdown.types';
3
+ import './TsDropdown.css';
4
+ export declare const TsDropdown: <T extends unknown>({ label, options, placeholder, searchPlaceholder, value, disabled, searchable, getOptionValue, getOptionLabel, loadOptions, onChange, }: TsDropdownProps<T>) => React.JSX.Element;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TsDropdown = void 0;
4
+ const React = require("react");
5
+ const react_1 = require("react");
6
+ const TsIcon_1 = require("../../TsIcon/TsIcon");
7
+ const TsInput_1 = require("../../TsInput/TsInput/TsInput");
8
+ const use_click_outside_1 = require("../../../hooks/use-click-outside");
9
+ const string_utils_1 = require("../../../utils/string.utils");
10
+ require("./TsDropdown.css");
11
+ const TsLoader_1 = require("../../TsLoader/TsLoader");
12
+ const TsDropdown = ({ label, options, placeholder, searchPlaceholder, value, disabled, searchable, getOptionValue, getOptionLabel, loadOptions, onChange, }) => {
13
+ const [showDropdownMenu, setShowDropdownMenu] = (0, react_1.useState)(false);
14
+ const [searchValue, setSearchValue] = (0, react_1.useState)('');
15
+ const [items, setItems] = (0, react_1.useState)(options ?? []);
16
+ const [selectedItem, setSelectedItem] = (0, react_1.useState)(value);
17
+ const [loading, setLoading] = (0, react_1.useState)(false);
18
+ const [isFetchError, setIsFetchError] = (0, react_1.useState)(false);
19
+ const ref = (0, use_click_outside_1.useClickOutside)(() => setShowDropdownMenu(false));
20
+ // ########
21
+ // Fetchers
22
+ const fetchOptions = () => {
23
+ if (!options && loadOptions) {
24
+ setLoading(true);
25
+ setIsFetchError(false);
26
+ loadOptions(searchValue)
27
+ .then(setItems)
28
+ .catch(() => setIsFetchError(true))
29
+ .finally(() => setLoading(false));
30
+ }
31
+ };
32
+ // ########
33
+ // Handlers
34
+ const handleSelectItem = (item) => {
35
+ setSelectedItem(item);
36
+ setShowDropdownMenu(false);
37
+ onChange(item);
38
+ };
39
+ const handleShowDropdownMenu = () => !disabled && setShowDropdownMenu(true);
40
+ // ########
41
+ // Watchers
42
+ (0, react_1.useEffect)(fetchOptions, []);
43
+ (0, react_1.useEffect)(() => {
44
+ if (searchable && options) {
45
+ setItems(options.filter(option => getOptionLabel(option).toLowerCase().includes(searchValue.toLowerCase())));
46
+ }
47
+ if (searchable && !options && loadOptions) {
48
+ const timeOutId = setTimeout(fetchOptions, 500);
49
+ return () => clearTimeout(timeOutId);
50
+ }
51
+ return () => { };
52
+ }, [searchValue]);
53
+ // #########
54
+ // Rendering
55
+ return (React.createElement("div", { className: "ts-dropdown-container", ref: ref },
56
+ React.createElement("div", { className: "ts-dropdown-input-container" },
57
+ label && React.createElement("div", { className: "ts-dropdown-label" }, label),
58
+ React.createElement("div", { className: `ts-dropdown-input ${disabled ? 'ts-dropdown-input--disabled' : ''}`, onClick: handleShowDropdownMenu },
59
+ !selectedItem && placeholder && React.createElement("div", { className: "ts-dropdown-input--placeholder" }, placeholder),
60
+ selectedItem && React.createElement("div", { className: "ts-dropdown-input--value" }, getOptionLabel(selectedItem)),
61
+ React.createElement("div", { className: "ts-dropdown-input--chevron" },
62
+ React.createElement(TsIcon_1.TsIcon, { name: "chevron-down" })))),
63
+ !disabled && showDropdownMenu && (React.createElement("div", { className: "ts-dropdown-menu-container" },
64
+ searchable && (React.createElement("div", { className: "ts-dropdown-search" },
65
+ React.createElement(TsInput_1.TsInput, { icon: "search", placeholder: searchPlaceholder, value: searchValue, autoFocus: true, onChange: setSearchValue }))),
66
+ React.createElement("div", { className: "ts-dropdown-menu" },
67
+ loading && (React.createElement("div", { className: "ts-dropdown-menu-loader" },
68
+ React.createElement(TsLoader_1.TsLoader, { size: "sm" }))),
69
+ !loading && isFetchError && (React.createElement("div", { className: "ts-dropdown-menu-error-text" }, "An error occured, try again later.")),
70
+ !loading && !isFetchError && items.length === 0 && (React.createElement("div", { className: "ts-dropdown-menu-error-text" }, "No options found.")),
71
+ !loading &&
72
+ !isFetchError &&
73
+ items.length > 0 &&
74
+ items.map(item => (React.createElement("div", { key: getOptionValue(item), className: "ts-dropdown-menu-item", onClick: () => handleSelectItem(item) }, (0, string_utils_1.capitalize)(getOptionLabel(item))))))))));
75
+ };
76
+ exports.TsDropdown = TsDropdown;
77
+ //# sourceMappingURL=TsDropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TsDropdown.js","sourceRoot":"","sources":["../../../../src/components/TsDropdown/TsDropdown/TsDropdown.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,iCAA4C;AAE5C,gDAA6C;AAC7C,2DAAwD;AACxD,wEAAmE;AACnE,8DAAyD;AACzD,4BAA0B;AAC1B,sDAAmD;AAE5C,MAAM,UAAU,GAAG,CAAoB,EAC5C,KAAK,EACL,OAAO,EACP,WAAW,EACX,iBAAiB,EACjB,KAAK,EACL,QAAQ,EACR,UAAU,EACV,cAAc,EACd,cAAc,EACd,WAAW,EACX,QAAQ,GACW,EAAE,EAAE;IACvB,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAU,KAAK,CAAC,CAAC;IACzE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAAS,EAAE,CAAC,CAAC;IAC3D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAM,OAAO,IAAI,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAgB,KAAK,CAAC,CAAC;IACvE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAU,KAAK,CAAC,CAAC;IACvD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAU,KAA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I,CAC3B,6BAAK,SAAS,EAAC,6BAA6B,yCAAyC,CACtF;gBACA,CAAC,OAAO,IAAI,CAAC,YAAY,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAClD,6BAAK,SAAS,EAAC,6BAA6B,wBAAwB,CACrE;gBACA,CAAC,OAAO;oBACP,CAAC,YAAY;oBACb,KAAK,CAAC,MAAM,GAAG,CAAC;oBAChB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAChB,6BACE,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,EACzB,SAAS,EAAC,uBAAuB,EACjC,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAEpC,IAAA,yBAAU,EAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAC7B,CACP,CAAC,CACA,CACF,CACP,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AAxHW,QAAA,UAAU,cAwHrB"}
@@ -0,0 +1,131 @@
1
+ import * as React from 'react';
2
+ import { useEffect, useState } from 'react';
3
+ import { TsDropdownProps } from './TsDropdown.types';
4
+ import { TsIcon } from '../../TsIcon/TsIcon';
5
+ import { TsInput } from '../../TsInput/TsInput/TsInput';
6
+ import { useClickOutside } from '../../../hooks/use-click-outside';
7
+ import { capitalize } from '../../../utils/string.utils';
8
+ import './TsDropdown.css';
9
+ import { TsLoader } from '../../TsLoader/TsLoader';
10
+
11
+ export const TsDropdown = <T extends unknown>({
12
+ label,
13
+ options,
14
+ placeholder,
15
+ searchPlaceholder,
16
+ value,
17
+ disabled,
18
+ searchable,
19
+ getOptionValue,
20
+ getOptionLabel,
21
+ loadOptions,
22
+ onChange,
23
+ }: TsDropdownProps<T>) => {
24
+ const [showDropdownMenu, setShowDropdownMenu] = useState<boolean>(false);
25
+ const [searchValue, setSearchValue] = useState<string>('');
26
+ const [items, setItems] = useState<T[]>(options ?? []);
27
+ const [selectedItem, setSelectedItem] = useState<T | undefined>(value);
28
+ const [loading, setLoading] = useState<boolean>(false);
29
+ const [isFetchError, setIsFetchError] = useState<boolean>(false);
30
+ const ref = useClickOutside(() => setShowDropdownMenu(false));
31
+
32
+ // ########
33
+ // Fetchers
34
+ const fetchOptions = () => {
35
+ if (!options && loadOptions) {
36
+ setLoading(true);
37
+ setIsFetchError(false);
38
+ loadOptions(searchValue)
39
+ .then(setItems)
40
+ .catch(() => setIsFetchError(true))
41
+ .finally(() => setLoading(false));
42
+ }
43
+ };
44
+
45
+ // ########
46
+ // Handlers
47
+ const handleSelectItem = (item: T) => {
48
+ setSelectedItem(item);
49
+ setShowDropdownMenu(false);
50
+ onChange(item);
51
+ };
52
+ const handleShowDropdownMenu = () => !disabled && setShowDropdownMenu(true);
53
+
54
+ // ########
55
+ // Watchers
56
+ useEffect(fetchOptions, []);
57
+ useEffect(() => {
58
+ if (searchable && options) {
59
+ setItems(options.filter(option => getOptionLabel(option).toLowerCase().includes(searchValue.toLowerCase())));
60
+ }
61
+
62
+ if (searchable && !options && loadOptions) {
63
+ const timeOutId = setTimeout(fetchOptions, 500);
64
+ return () => clearTimeout(timeOutId);
65
+ }
66
+
67
+ return () => {};
68
+ }, [searchValue]);
69
+
70
+ // #########
71
+ // Rendering
72
+ return (
73
+ <div className="ts-dropdown-container" ref={ref}>
74
+ <div className="ts-dropdown-input-container">
75
+ {label && <div className="ts-dropdown-label">{label}</div>}
76
+ <div
77
+ className={`ts-dropdown-input ${disabled ? 'ts-dropdown-input--disabled' : ''}`}
78
+ onClick={handleShowDropdownMenu}
79
+ >
80
+ {!selectedItem && placeholder && <div className="ts-dropdown-input--placeholder">{placeholder}</div>}
81
+ {selectedItem && <div className="ts-dropdown-input--value">{getOptionLabel(selectedItem)}</div>}
82
+ <div className="ts-dropdown-input--chevron">
83
+ <TsIcon name="chevron-down" />
84
+ </div>
85
+ </div>
86
+ </div>
87
+
88
+ {!disabled && showDropdownMenu && (
89
+ <div className="ts-dropdown-menu-container">
90
+ {searchable && (
91
+ <div className="ts-dropdown-search">
92
+ <TsInput
93
+ icon="search"
94
+ placeholder={searchPlaceholder}
95
+ value={searchValue}
96
+ autoFocus
97
+ onChange={setSearchValue}
98
+ />
99
+ </div>
100
+ )}
101
+
102
+ <div className="ts-dropdown-menu">
103
+ {loading && (
104
+ <div className="ts-dropdown-menu-loader">
105
+ <TsLoader size="sm" />
106
+ </div>
107
+ )}
108
+ {!loading && isFetchError && (
109
+ <div className="ts-dropdown-menu-error-text">An error occured, try again later.</div>
110
+ )}
111
+ {!loading && !isFetchError && items.length === 0 && (
112
+ <div className="ts-dropdown-menu-error-text">No options found.</div>
113
+ )}
114
+ {!loading &&
115
+ !isFetchError &&
116
+ items.length > 0 &&
117
+ items.map(item => (
118
+ <div
119
+ key={getOptionValue(item)}
120
+ className="ts-dropdown-menu-item"
121
+ onClick={() => handleSelectItem(item)}
122
+ >
123
+ {capitalize(getOptionLabel(item))}
124
+ </div>
125
+ ))}
126
+ </div>
127
+ </div>
128
+ )}
129
+ </div>
130
+ );
131
+ };
@@ -0,0 +1,13 @@
1
+ export type TsDropdownProps<T> = {
2
+ label?: string;
3
+ options?: T[];
4
+ placeholder?: string;
5
+ searchPlaceholder?: string;
6
+ value?: T;
7
+ disabled?: boolean;
8
+ searchable?: boolean;
9
+ getOptionLabel: (option: T) => string;
10
+ getOptionValue: (option: T) => string;
11
+ loadOptions?: (search?: string) => Promise<T[]>;
12
+ onChange: (value?: T) => void;
13
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TsDropdown.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TsDropdown.types.js","sourceRoot":"","sources":["../../../../src/components/TsDropdown/TsDropdown/TsDropdown.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ export type TsDropdownProps<T> = {
2
+ label?: string;
3
+ options?: T[];
4
+ placeholder?: string;
5
+ searchPlaceholder?: string;
6
+ value?: T;
7
+ disabled?: boolean;
8
+ searchable?: boolean;
9
+ getOptionLabel: (option: T) => string;
10
+ getOptionValue: (option: T) => string;
11
+ loadOptions?: (search?: string) => Promise<T[]>;
12
+ onChange: (value?: T) => void;
13
+ };
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import { ArgsTable, Canvas, Meta, Story } from '@storybook/blocks';
3
+ import { TsDropdown } from '../TsDropdown';
4
+ import { fruits } from './fruits';
5
+
6
+ <Meta title="Components/Dropdown" />
7
+
8
+ export const dropdownArgTypes = {
9
+ label: {
10
+ control: 'text',
11
+ description: 'Label of the dropdown.',
12
+ },
13
+ placeholder: {
14
+ control: 'text',
15
+ description: 'Placeholder of the dropdown.',
16
+ },
17
+ searchPlaceholder: {
18
+ control: 'text',
19
+ description: 'Placeholder of the option search (only for searchable dropdowns).',
20
+ },
21
+ searchable: {
22
+ control: 'boolean',
23
+ description: 'Enable search on dropdown items.',
24
+ table: { defaultValue: { summary: 'false' } },
25
+ },
26
+ disabled: {
27
+ control: 'boolean',
28
+ description: 'Enable state of the dropdown.',
29
+ table: { defaultValue: { summary: 'false' } },
30
+ },
31
+ onChange: {
32
+ control: 'function',
33
+ description: 'The handler called when clicking on the dropdown.',
34
+ },
35
+ };
36
+
37
+ # Dropdown
38
+
39
+ Dropdowns show a list of options that can be used to select, filter or sort content.
40
+
41
+ ## Overview
42
+
43
+ <Canvas>
44
+ <Story
45
+ name="Overview"
46
+ args={{
47
+ label: 'Label',
48
+ options: fruits,
49
+ searchPlaceholder: '',
50
+ placeholder: 'Select an item',
51
+ disabled: false,
52
+ searchable: false,
53
+ getOptionLabel: function ol(fruit) {
54
+ return fruit.name;
55
+ },
56
+ getOptionValue: function ov(fruit) {
57
+ return fruit.id;
58
+ },
59
+ }}
60
+ argTypes={dropdownArgTypes}
61
+ >
62
+ {args => <TsDropdown {...args}>{args.children}</TsDropdown>}
63
+ </Story>
64
+ </Canvas>
65
+
66
+ ## Props
67
+
68
+ <ArgsTable story="Overview" of={TsDropdown} />
@@ -0,0 +1,4 @@
1
+ export declare const fruits: {
2
+ name: string;
3
+ id: number;
4
+ }[];
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fruits = void 0;
4
+ exports.fruits = [
5
+ { name: 'Persimmon', id: 52 },
6
+ { name: 'Strawberry', id: 3 },
7
+ { name: 'Banana', id: 1 },
8
+ { name: 'Tomato', id: 5 },
9
+ { name: 'Pear', id: 4 },
10
+ { name: 'Durian', id: 60 },
11
+ { name: 'Blackberry', id: 64 },
12
+ { name: 'Lingonberry', id: 65 },
13
+ { name: 'Kiwi', id: 66 },
14
+ { name: 'Lychee', id: 67 },
15
+ { name: 'Pineapple', id: 10 },
16
+ { name: 'Fig', id: 68 },
17
+ { name: 'Gooseberry', id: 69 },
18
+ { name: 'Passionfruit', id: 70 },
19
+ { name: 'Plum', id: 71 },
20
+ { name: 'Orange', id: 2 },
21
+ { name: 'GreenApple', id: 72 },
22
+ { name: 'Raspberry', id: 23 },
23
+ { name: 'Watermelon', id: 25 },
24
+ { name: 'Lemon', id: 26 },
25
+ { name: 'Mango', id: 27 },
26
+ { name: 'Blueberry', id: 33 },
27
+ { name: 'Apple', id: 6 },
28
+ { name: 'Guava', id: 37 },
29
+ { name: 'Apricot', id: 35 },
30
+ { name: 'Papaya', id: 42 },
31
+ { name: 'Melon', id: 41 },
32
+ { name: 'Tangerine', id: 77 },
33
+ { name: 'Pitahaya', id: 78 },
34
+ { name: 'Lime', id: 44 },
35
+ { name: 'Pomegranate', id: 79 },
36
+ { name: 'Dragonfruit', id: 80 },
37
+ { name: 'Grape', id: 81 },
38
+ { name: 'Morus', id: 82 },
39
+ { name: 'Feijoa', id: 76 },
40
+ { name: 'Avocado', id: 84 },
41
+ { name: 'Kiwifruit', id: 85 },
42
+ { name: 'Cranberry', id: 87 },
43
+ { name: 'Cherry', id: 9 },
44
+ { name: 'Peach', id: 86 },
45
+ { name: 'Jackfruit', id: 94 },
46
+ { name: 'Horned Melon', id: 95 },
47
+ { name: 'Hazelnut', id: 96 },
48
+ { name: 'Pomelo', id: 98 },
49
+ { name: 'Mangosteen', id: 99 },
50
+ ];
51
+ //# sourceMappingURL=fruits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fruits.js","sourceRoot":"","sources":["../../../../../src/components/TsDropdown/TsDropdown/__stories__/fruits.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG;IACpB,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE;IAC7B,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,EAAE;IAC7B,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE;IACzB,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE;IACzB,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE;IACvB,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE;IAC1B,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,EAAE,EAAE;IAC9B,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,EAAE,EAAE;IAC/B,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE;IACxB,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE;IAC1B,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE;IAC7B,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE;IACvB,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,EAAE,EAAE;IAC9B,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE,EAAE;IAChC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE;IACxB,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE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EAAE;IAC3B,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE;IAC7B,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE;IAC7B,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE;IACzB,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE;IACzB,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE;IAC7B,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE,EAAE;IAChC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE;IAC5B,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE;IAC1B,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,EAAE,EAAE;CAC/B,CAAC"}
@@ -0,0 +1,47 @@
1
+ export const fruits = [
2
+ { name: 'Persimmon', id: 52 },
3
+ { name: 'Strawberry', id: 3 },
4
+ { name: 'Banana', id: 1 },
5
+ { name: 'Tomato', id: 5 },
6
+ { name: 'Pear', id: 4 },
7
+ { name: 'Durian', id: 60 },
8
+ { name: 'Blackberry', id: 64 },
9
+ { name: 'Lingonberry', id: 65 },
10
+ { name: 'Kiwi', id: 66 },
11
+ { name: 'Lychee', id: 67 },
12
+ { name: 'Pineapple', id: 10 },
13
+ { name: 'Fig', id: 68 },
14
+ { name: 'Gooseberry', id: 69 },
15
+ { name: 'Passionfruit', id: 70 },
16
+ { name: 'Plum', id: 71 },
17
+ { name: 'Orange', id: 2 },
18
+ { name: 'GreenApple', id: 72 },
19
+ { name: 'Raspberry', id: 23 },
20
+ { name: 'Watermelon', id: 25 },
21
+ { name: 'Lemon', id: 26 },
22
+ { name: 'Mango', id: 27 },
23
+ { name: 'Blueberry', id: 33 },
24
+ { name: 'Apple', id: 6 },
25
+ { name: 'Guava', id: 37 },
26
+ { name: 'Apricot', id: 35 },
27
+ { name: 'Papaya', id: 42 },
28
+ { name: 'Melon', id: 41 },
29
+ { name: 'Tangerine', id: 77 },
30
+ { name: 'Pitahaya', id: 78 },
31
+ { name: 'Lime', id: 44 },
32
+ { name: 'Pomegranate', id: 79 },
33
+ { name: 'Dragonfruit', id: 80 },
34
+ { name: 'Grape', id: 81 },
35
+ { name: 'Morus', id: 82 },
36
+ { name: 'Feijoa', id: 76 },
37
+ { name: 'Avocado', id: 84 },
38
+ { name: 'Kiwifruit', id: 85 },
39
+ { name: 'Cranberry', id: 87 },
40
+ { name: 'Cherry', id: 9 },
41
+ { name: 'Peach', id: 86 },
42
+ { name: 'Jackfruit', id: 94 },
43
+ { name: 'Horned Melon', id: 95 },
44
+ { name: 'Hazelnut', id: 96 },
45
+ { name: 'Pomelo', id: 98 },
46
+ { name: 'Mangosteen', id: 99 },
47
+ ];
@@ -12,6 +12,7 @@
12
12
  font-weight: 600;
13
13
  }
14
14
  input::placeholder {
15
+ color: #7a7a7a;
15
16
  font-weight: 400;
16
17
  }
17
18
  input:disabled {
@@ -19,6 +19,11 @@ export const inputArgTypes = {
19
19
  control: 'text',
20
20
  description: 'Placeholder of the input.',
21
21
  },
22
+ disabled: {
23
+ control: 'boolean',
24
+ description: 'Enable state of the input.',
25
+ table: { defaultValue: { summary: 'false' } },
26
+ },
22
27
  };
23
28
 
24
29
  # Input
@@ -30,7 +35,7 @@ Input allows the user to enter content and data when the expected user input is
30
35
  <Canvas>
31
36
  <Story
32
37
  name="Overview"
33
- args={{ label: '', placeholder: 'Enter some text', onChange: () => {} }}
38
+ args={{ label: 'Label', placeholder: 'Enter some text', disabled: false, onChange: () => {} }}
34
39
  argTypes={inputArgTypes}
35
40
  >
36
41
  {args => <TsInput {...args} />}
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './components/TsButton/TsButton';
2
2
  export * from './components/TsCheckbox/TsCheckbox';
3
+ export * from './components/TsDropdown/TsDropdown/TsDropdown';
3
4
  export * from './components/TsIcon/TsIcon';
4
5
  export * from './components/TsInput/TsInput/TsInput';
5
6
  export * from './components/TsLoader/TsLoader';
package/lib/index.js CHANGED
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./components/TsButton/TsButton"), exports);
18
18
  __exportStar(require("./components/TsCheckbox/TsCheckbox"), exports);
19
+ __exportStar(require("./components/TsDropdown/TsDropdown/TsDropdown"), exports);
19
20
  __exportStar(require("./components/TsIcon/TsIcon"), exports);
20
21
  __exportStar(require("./components/TsInput/TsInput/TsInput"), exports);
21
22
  __exportStar(require("./components/TsLoader/TsLoader"), exports);
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C;AAC/C,qEAAmD;AACnD,6DAA2C;AAC3C,uEAAqD;AACrD,iEAA+C;AAC/C,8DAA4C;AAC5C,qEAAmD;AACnD,sEAAoD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C;AAC/C,qEAAmD;AACnD,gFAA8D;AAC9D,6DAA2C;AAC3C,uEAAqD;AACrD,iEAA+C;AAC/C,8DAA4C;AAC5C,qEAAmD;AACnD,sEAAoD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dktunited-techoff/techoff-suite-ui",
3
- "version": "1.5.7",
3
+ "version": "1.6.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib",
6
6
  "module": "esm/index.js",
@@ -32,9 +32,6 @@
32
32
  .ts-checkbox:hover .ts-checkbox-box:not(.ts-checkbox-box--checked) {
33
33
  color: #3643ba;
34
34
  }
35
- .ts-checkbox-box .ts-icon {
36
- z-index: 20;
37
- }
38
35
 
39
36
  /* ################# */
40
37
  /* LABEL / CAPTION */