ar-design 0.1.9 → 0.1.11

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.
@@ -1,4 +1,5 @@
1
1
  .ar-chip {
2
2
  padding: 0.25rem 0.5rem;
3
3
  font-size: 0.75rem;
4
+ white-space: nowrap;
4
5
  }
@@ -6,12 +6,14 @@
6
6
  .ar-checkbox-wrapper > label > span {
7
7
  display: flex;
8
8
  align-items: center;
9
+ gap: 0 0.5rem;
10
+ user-select: none;
9
11
  }
10
12
  .ar-checkbox-wrapper > label > span > .ar-checkbox {
11
13
  position: relative;
12
14
  display: inline-block;
13
- width: 1rem;
14
- height: 1rem;
15
+ min-width: 1rem;
16
+ min-height: 1rem;
15
17
  }
16
18
  .ar-checkbox-wrapper > label > input[type="checkbox"]:checked + span > .ar-checkbox::before {
17
19
  position: absolute;
@@ -7,6 +7,10 @@
7
7
  border-right-color: var(--primary);
8
8
  border-bottom-color: var(--primary);
9
9
  }
10
+ .ar-checkbox-wrapper > label > input[type="checkbox"]:checked + span > .ar-checkbox.borderless.primary::before {
11
+ border-right-color: var(--primary);
12
+ border-bottom-color: var(--primary);
13
+ }
10
14
  /* #endregion */
11
15
  /* Border Color -> PRIMARY */
12
16
 
@@ -19,6 +23,10 @@
19
23
  border-right-color: var(--secondary);
20
24
  border-bottom-color: var(--secondary);
21
25
  }
26
+ .ar-checkbox-wrapper > label > input[type="checkbox"]:checked + span > .ar-checkbox.borderless.secondary::before {
27
+ border-right-color: var(--secondary);
28
+ border-bottom-color: var(--secondary);
29
+ }
22
30
  /* #endregion */
23
31
  /* Border Color -> SECONDARY */
24
32
 
@@ -31,6 +39,10 @@
31
39
  border-right-color: var(--success);
32
40
  border-bottom-color: var(--success);
33
41
  }
42
+ .ar-checkbox-wrapper > label > input[type="checkbox"]:checked + span > .ar-checkbox.borderless.success::before {
43
+ border-right-color: var(--success);
44
+ border-bottom-color: var(--success);
45
+ }
34
46
  /* #endregion */
35
47
  /* Border Color -> SUCCESS */
36
48
 
@@ -43,6 +55,10 @@
43
55
  border-right-color: var(--warning);
44
56
  border-bottom-color: var(--warning);
45
57
  }
58
+ .ar-checkbox-wrapper > label > input[type="checkbox"]:checked + span > .ar-checkbox.borderless.warning::before {
59
+ border-right-color: var(--warning);
60
+ border-bottom-color: var(--warning);
61
+ }
46
62
  /* #endregion */
47
63
  /* Border Color -> WARNING */
48
64
 
@@ -55,6 +71,10 @@
55
71
  border-right-color: var(--danger);
56
72
  border-bottom-color: var(--danger);
57
73
  }
74
+ .ar-checkbox-wrapper > label > input[type="checkbox"]:checked + span > .ar-checkbox.borderless.danger::before {
75
+ border-right-color: var(--danger);
76
+ border-bottom-color: var(--danger);
77
+ }
58
78
  /* #endregion */
59
79
  /* Border Color -> DANGER */
60
80
 
@@ -67,6 +87,10 @@
67
87
  border-right-color: var(--information);
68
88
  border-bottom-color: var(--information);
69
89
  }
90
+ .ar-checkbox-wrapper > label > input[type="checkbox"]:checked + span > .ar-checkbox.borderless.information::before {
91
+ border-right-color: var(--information);
92
+ border-bottom-color: var(--information);
93
+ }
70
94
  /* #endregion */
71
95
  /* Border Color -> INFORMATION */
72
96
 
@@ -79,6 +103,10 @@
79
103
  border-right-color: var(--dark);
80
104
  border-bottom-color: var(--dark);
81
105
  }
106
+ .ar-checkbox-wrapper > label > input[type="checkbox"]:checked + span > .ar-checkbox.borderless.dark::before {
107
+ border-right-color: var(--dark);
108
+ border-bottom-color: var(--dark);
109
+ }
82
110
  /* #endregion */
83
111
  /* Border Color -> DARK */
84
112
 
@@ -91,6 +119,10 @@
91
119
  border-right-color: var(--light);
92
120
  border-bottom-color: var(--light);
93
121
  }
122
+ .ar-checkbox-wrapper > label > input[type="checkbox"]:checked + span > .ar-checkbox.borderless.light::before {
123
+ border-right-color: var(--light);
124
+ border-bottom-color: var(--light);
125
+ }
94
126
  /* #endregion */
95
127
  /* Border Color -> LIGHT */
96
128
 
@@ -8,11 +8,11 @@
8
8
  transition: visibility 250ms, opacity 250ms, transform 250ms ease-in-out;
9
9
  }
10
10
  .ar-select-wrapper > .options.top {
11
- inset: var(--input-height) 0 auto 0;
11
+ inset: 100% 0 auto 0;
12
12
  box-shadow: 0 5px 15px -2.5px rgba(var(--black-rgb), 0.1);
13
13
  }
14
14
  .ar-select-wrapper > .options.bottom {
15
- inset: auto 0 var(--input-height) 0;
15
+ inset: auto 0 100% 0;
16
16
  box-shadow: 0 -5px 15px -2.5px rgba(var(--black-rgb), 0.1);
17
17
  }
18
18
 
@@ -23,12 +23,16 @@
23
23
 
24
24
  .ar-select-wrapper > .options > ul {
25
25
  width: 100%;
26
+ max-height: calc(var(--input-height) * 5);
27
+ overflow-x: hidden;
28
+ overflow-y: auto;
26
29
  }
27
30
  .ar-select-wrapper > .options > ul > li {
28
31
  display: flex;
29
32
  align-items: center;
30
33
  gap: 0 0.5rem;
31
- padding: 0.5rem 1rem;
34
+ padding: 0 1rem;
35
+ height: var(--input-height);
32
36
  cursor: pointer;
33
37
  }
34
38
  .ar-select-wrapper > .options > ul > li:hover {
@@ -44,7 +48,6 @@
44
48
  .ar-select-wrapper > .options:is(.opened) {
45
49
  visibility: visible;
46
50
  opacity: 1;
47
- background-color: var(--white);
48
51
  transform: scaleY(1);
49
52
  }
50
53
  .ar-select-wrapper > .options:is(.closed) {
@@ -8,30 +8,45 @@
8
8
  width: 100%;
9
9
  }
10
10
 
11
- .ar-select-wrapper > .ar-select > .selections {
12
- display: flex;
13
- align-items: center;
14
- gap: 0 0.25rem;
15
- height: var(--input-height);
16
- padding: 0 0.35rem;
11
+ .ar-select-wrapper > .ar-select > .angel-down {
12
+ position: absolute;
13
+ top: 50%;
14
+ right: 0.5rem;
15
+ width: 0.75rem;
16
+ height: 0.75rem;
17
+ cursor: pointer;
18
+ transform-origin: center;
19
+ transition: transform 250ms ease-in-out;
17
20
  }
18
- .ar-select-wrapper > .ar-select > .selections > ul {
19
- display: flex;
20
- flex-direction: row;
21
- gap: 0.5rem;
21
+ .ar-select-wrapper > .ar-select > .angel-down:is(.opened) {
22
+ transform: translateY(-50%) scaleY(-1);
22
23
  }
23
- .ar-select-wrapper > .ar-select > .selections > ul > li {
24
- background-color: var(--gray-100);
25
- padding: 0 0.5rem;
26
- border: solid 1px var(--gray-200);
27
- border-radius: var(--border-radius-sm);
24
+ .ar-select-wrapper > .ar-select > .angel-down:is(.closed) {
25
+ transform: translateY(-50%) scaleY(1);
26
+ }
27
+ .ar-select-wrapper > .ar-select > .angel-down::before {
28
+ display: inline-block;
29
+ content: "";
30
+ position: absolute;
31
+ width: 100%;
32
+ height: 100%;
33
+ border: 1px transparent;
34
+ border-top-style: dashed;
35
+ border-right-style: dashed;
36
+ border-bottom-style: solid;
37
+ border-left-style: solid;
38
+ border-top-color: rgba(var(--black-rgb), 0.1);
39
+ border-right-color: rgba(var(--black-rgb), 0.1);
40
+ border-bottom-color: rgba(var(--black-rgb), 0.5);
41
+ border-left-color: rgba(var(--black-rgb), 0.5);
42
+ transform: rotate(-45deg);
28
43
  }
29
44
 
30
45
  .ar-select-wrapper > .ar-select > .button-clear {
31
46
  position: absolute;
32
47
  top: 50%;
33
48
  transform: translateY(-50%);
34
- right: 0.5rem;
49
+ right: 2rem;
35
50
  background-color: rgba(var(--black-rgb), 0.25);
36
51
  backdrop-filter: blur(5px);
37
52
  width: 1rem;
@@ -47,4 +62,34 @@
47
62
  font-size: 0.75rem;
48
63
  }
49
64
 
65
+ .ar-select-wrapper > .ar-select > .selections {
66
+ display: flex;
67
+ flex-wrap: nowrap;
68
+ align-items: center;
69
+ min-height: var(--input-height);
70
+ padding: 0.35rem;
71
+ }
72
+ .ar-select-wrapper > .ar-select > .selections > .items {
73
+ display: flex;
74
+ flex-wrap: wrap;
75
+ align-items: center;
76
+ gap: 0.25rem;
77
+ width: calc(100% - 2.75rem);
78
+ }
79
+ .ar-select-wrapper > .ar-select > .selections > .items > span.placeholder {
80
+ opacity: 0.5;
81
+ font-weight: 800;
82
+ }
83
+ .ar-select-wrapper > .ar-select > .selections > ul {
84
+ display: flex;
85
+ flex-direction: row;
86
+ gap: 0.5rem;
87
+ }
88
+ .ar-select-wrapper > .ar-select > .selections > ul > li {
89
+ background-color: var(--gray-100);
90
+ padding: 0 0.5rem;
91
+ border: solid 1px var(--gray-200);
92
+ border-radius: var(--border-radius-sm);
93
+ }
94
+
50
95
  @import url("./options.css");
@@ -14,7 +14,7 @@
14
14
 
15
15
  /* #region Height */
16
16
  :root {
17
- --input-height: 2.25rem;
17
+ --input-height: 2.5rem;
18
18
  }
19
19
  /* #endregion */
20
20
  /* Height */
@@ -147,6 +147,13 @@
147
147
  border-color: transparent;
148
148
  transition: border 250ms, box-shadow 250ms ease-in-out;
149
149
  }
150
+ .borderless:disabled {
151
+ background-color: var(--gray-100) !important;
152
+ border: none !important;
153
+ color: var(--gray-500) !important;
154
+ cursor: no-drop !important;
155
+ }
156
+
150
157
  @import url("./variants/borderless/borderless.css");
151
158
  @import url("./variants/border.css");
152
159
 
@@ -156,5 +163,16 @@
156
163
  color: var(--gray-500) !important;
157
164
  cursor: no-drop !important;
158
165
  }
166
+ /* :is(button):disabled {
167
+ background-color: var(--gray-100) !important;
168
+ color: var(--gray-500) !important;
169
+ cursor: no-drop !important;
170
+ }
171
+ :is(button):is(.filled):disabled {
172
+ border: solid 1px var(--gray-500) !important;
173
+ }
174
+ :is(button):is(.outlined):is(.):disabled {
175
+ border: solid 1px var(--gray-500) !important;
176
+ } */
159
177
  /* #endregion */
160
178
  /* Variants */
@@ -4,6 +4,10 @@
4
4
  .outlined.border-style-dashed {
5
5
  border-style: dashed;
6
6
  }
7
+ .outlined.border-style-dashed:disabled {
8
+ border-style: dashed !important;
9
+ border-color: var(--gray-500) !important;
10
+ }
7
11
  .outlined.border-style-none {
8
12
  border-style: none;
9
13
  }
@@ -1,3 +1,4 @@
1
+ import { BorderRadiuses } from "../../../libs/types/BorderRadius";
1
2
  import { Colors } from "../../../libs/types/Colors";
2
3
  import { Variants } from "../../../libs/types/Variants";
3
4
  export type Props = {
@@ -5,7 +6,7 @@ export type Props = {
5
6
  color?: Colors;
6
7
  border?: {
7
8
  style?: "solid" | "dashed" | "none";
8
- radius?: "sm" | "lg" | "xl" | "xxl" | "pill" | "none";
9
+ radius?: BorderRadiuses;
9
10
  };
10
11
  text: string;
11
12
  };
@@ -1,3 +1,4 @@
1
+ import { BorderRadiuses } from "../../../libs/types/BorderRadius";
1
2
  import { Colors } from "../../../libs/types/Colors";
2
3
  import { Variants } from "../../../libs/types/Variants";
3
4
  export type Props = {
@@ -136,7 +137,7 @@ export type Props = {
136
137
  */
137
138
  border?: {
138
139
  style?: "solid" | "dashed" | "none";
139
- radius?: "sm" | "lg" | "xl" | "xxl" | "pill" | "none";
140
+ radius?: BorderRadiuses;
140
141
  };
141
142
  /**
142
143
  * Bileşenin genişlik özelliğini belirtir.
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { Props as ButtonProps } from "../button/Types";
3
3
  import { Colors } from "../../../libs/types/Colors";
4
4
  import { Variants } from "../../../libs/types/Variants";
5
+ import { BorderRadiuses } from "../../../libs/types/BorderRadius";
5
6
  type Props = {
6
7
  variant?: Variants;
7
8
  status?: Colors;
@@ -10,7 +11,7 @@ type Props = {
10
11
  position?: "start" | "end";
11
12
  };
12
13
  border?: {
13
- radius: "sm" | "lg" | "xl" | "xxl" | "pill" | "none";
14
+ radius: BorderRadiuses;
14
15
  };
15
16
  button?: ButtonProps;
16
17
  addon?: {
@@ -8,7 +8,7 @@ declare const Input: React.ForwardRefExoticComponent<{
8
8
  position?: "start" | "end";
9
9
  };
10
10
  border?: {
11
- radius: "sm" | "lg" | "xl" | "xxl" | "pill" | "none";
11
+ radius: import("../../../libs/types/BorderRadius").BorderRadiuses;
12
12
  };
13
13
  button?: import("../button/Types").Props;
14
14
  addon?: {
@@ -1,3 +1,4 @@
1
+ import { BorderRadiuses } from "../../../libs/types/BorderRadius";
1
2
  import { Colors } from "../../../libs/types/Colors";
2
3
  import { Variants } from "../../../libs/types/Variants";
3
4
  export type Option = {
@@ -7,7 +8,10 @@ export type Option = {
7
8
  type Multiple = {
8
9
  status?: {
9
10
  color?: Colors;
10
- selected?: Colors;
11
+ selected?: {
12
+ variant?: Variants;
13
+ color?: Colors;
14
+ };
11
15
  };
12
16
  onChange: (option: Option[]) => void;
13
17
  multiple: true;
@@ -18,9 +22,9 @@ type Single = {
18
22
  multiple?: false;
19
23
  };
20
24
  export type Props = {
21
- variant?: Variants;
25
+ variant?: Exclude<Variants, "borderless">;
22
26
  border?: {
23
- radius: "sm" | "lg" | "xl" | "xxl" | "pill" | "none";
27
+ radius: BorderRadiuses;
24
28
  };
25
29
  options: Option[];
26
30
  placeholder?: string;
@@ -4,6 +4,7 @@ import Input from "../input";
4
4
  import "../../../assets/css/components/form/select/select.css";
5
5
  import Chip from "../../data-display/chip";
6
6
  import Checkbox from "../checkbox";
7
+ import Paragraph from "../../data-display/typography/paragraph/Paragraph";
7
8
  const Select = ({ variant = "outlined", status, border, options, onChange, multiple, placeholder, disabled = false, }) => {
8
9
  // refs
9
10
  let _selectionClassName = useRef("selections").current;
@@ -17,6 +18,7 @@ const Select = ({ variant = "outlined", status, border, options, onChange, multi
17
18
  let _navigationIndex = useRef(0);
18
19
  // states
19
20
  const [optionsOpen, setOptionsOpen] = useState(false);
21
+ const [filteredOptions, setFilteredOptions] = useState([]);
20
22
  const [searchText, setSearchText] = useState("");
21
23
  const [selection, setSelection] = useState(null);
22
24
  const [selections, setSelections] = useState([]);
@@ -139,8 +141,12 @@ const Select = ({ variant = "outlined", status, border, options, onChange, multi
139
141
  };
140
142
  }
141
143
  else {
142
- if (multiple) {
144
+ // Options paneli kapanma süresi 250ms.
145
+ // 300ms sonra temizlenmesinin sebebi kapanırken birder veriler gerliyor ve panel yüksekliği artıyor.
146
+ setTimeout(() => {
143
147
  setSearchText("");
148
+ }, 300);
149
+ if (multiple) {
144
150
  if (_searchField.current)
145
151
  _searchField.current.value = "";
146
152
  }
@@ -154,6 +160,12 @@ const Select = ({ variant = "outlined", status, border, options, onChange, multi
154
160
  }
155
161
  }, [optionsOpen]);
156
162
  useEffect(() => {
163
+ // Arama kriterlerine uygun olan değerleri bir state e gönderiyoruz.
164
+ setFilteredOptions(options.filter((option) => {
165
+ if (!optionsOpen)
166
+ return option;
167
+ return option.text.toLowerCase().includes(searchText.toLowerCase());
168
+ }));
157
169
  // Arama yapılması durumunda değerleri sıfırla.
158
170
  setNavigationIndex(0);
159
171
  _navigationIndex.current = 0;
@@ -166,14 +178,22 @@ const Select = ({ variant = "outlined", status, border, options, onChange, multi
166
178
  _optionItems.current
167
179
  .filter((optionItem) => optionItem !== null)
168
180
  .forEach((item, index) => {
169
- index === navigationIndex
170
- ? item?.classList.add("navigate-with-arrow-keys")
171
- : item?.classList.remove("navigate-with-arrow-keys");
181
+ if (index === navigationIndex) {
182
+ item?.classList.add("navigate-with-arrow-keys");
183
+ item.scrollIntoView({
184
+ behavior: "smooth", // Yumuşak bir kaydırma animasyonu
185
+ block: "nearest", // En yakın pozisyona kaydır
186
+ });
187
+ }
188
+ else {
189
+ item?.classList.remove("navigate-with-arrow-keys");
190
+ }
172
191
  });
173
192
  }, [navigationIndex]);
174
193
  return (React.createElement("div", { ref: _arSelect, className: "ar-select-wrapper" },
175
194
  React.createElement("div", { ref: _multipleInput, className: "ar-select" },
176
- multiple ? (React.createElement("div", { className: _selectionClassName, onClick: () => setOptionsOpen((x) => !x) }, selections.map((selection, index) => (React.createElement(Chip, { key: index, color: status?.selected || "primary", text: selection.text }))))) : (
195
+ multiple ? (React.createElement("div", { className: _selectionClassName, onClick: () => setOptionsOpen((x) => !x) },
196
+ React.createElement("div", { className: "items" }, selections.length > 0 ? (selections.map((selection, index) => (React.createElement(Chip, { key: index, variant: status?.selected?.variant || "filled", color: status?.selected?.color || status?.color, text: selection.text })))) : (React.createElement("span", { className: `placeholder ${status?.color || "light"}` }, placeholder))))) : (
177
197
  // Single
178
198
  React.createElement(Input, { ref: _singleInput, variant: variant, status: status || "light", onClick: () => setOptionsOpen((x) => !x), onChange: () => !optionsOpen && setOptionsOpen(true), onKeyUp: (event) => {
179
199
  if (event.key === "Enter")
@@ -196,25 +216,20 @@ const Select = ({ variant = "outlined", status, border, options, onChange, multi
196
216
  }
197
217
  setSelection(null);
198
218
  }
199
- } }))),
200
- options.length > 0 && (React.createElement("div", { ref: _options, className: optionsClassName.map((className) => className).join(" ") },
219
+ } })),
220
+ React.createElement("span", { className: `angel-down ${optionsOpen ? "opened" : "closed"}`, onClick: () => setOptionsOpen((x) => !x) })),
221
+ React.createElement("div", { ref: _options, className: optionsClassName.map((className) => className).join(" ") },
201
222
  multiple && (React.createElement("div", { className: "search-field" },
202
223
  React.createElement(Input, { ref: _searchField, variant: "outlined", status: "light", placeholder: "Search...", onKeyUp: (event) => {
203
224
  // Arama yapmak için kullanılan state bu kısımda dolduruluyor.
204
225
  setSearchText(event.currentTarget.value);
205
226
  } }))),
206
- React.createElement("ul", null, options
207
- .filter((option) => {
208
- if (!optionsOpen)
209
- return option;
210
- return option.text.toLowerCase().includes(searchText.toLowerCase());
211
- })
212
- .map((option, index) => {
227
+ filteredOptions.length > 0 ? (React.createElement("ul", null, filteredOptions.map((option, index) => {
213
228
  const isItem = selections.some((selection) => selection.value === option.value);
214
229
  return (React.createElement("li", { ref: (element) => (_optionItems.current[index] = element), key: index, onClick: () => handleItemSelected(option, index) },
215
- multiple && (React.createElement(Checkbox, { checked: isItem, status: isItem ? status?.selected || "primary" : "light", disabled: true })),
230
+ multiple && (React.createElement(Checkbox, { checked: isItem, status: isItem ? status?.selected?.color || status?.color : "light", disabled: true })),
216
231
  React.createElement("span", null, option.text)));
217
- }))))));
232
+ }))) : (React.createElement(Paragraph, { color: "gray-500", align: "center" }, "Het hangi bir kay\u0131t bulunumad\u0131!")))));
218
233
  };
219
234
  Select.displayName = "Select";
220
235
  export default Select;
@@ -0,0 +1 @@
1
+ export type BorderRadiuses = "sm" | "lg" | "xl" | "xxl" | "pill" | "none";
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",