gbs-add-block 1.0.18 → 1.0.20

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # GBS Building Blocks 2.0 (v1.0.18)
1
+ # GBS Building Blocks 2.0 (v1.0.20)
2
2
 
3
3
  Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
4
4
 
@@ -6,9 +6,10 @@ Latest and upgraded version of GBS building blocks with headless UI and removed
6
6
 
7
7
  For detailed documentation on usage and props, Please visit: [Building Block Documentation v2.0](https://blackmax-designs.gitbook.io/building-block-v2.0)
8
8
 
9
- ## What's New 🎉 (Ver 1.0.18)
9
+ ## What's New 🎉 (Ver 1.0.20)
10
10
 
11
11
  - Style Update
12
+ - General Bug Fix
12
13
 
13
14
  ## Authors
14
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbs-add-block",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "React Component Library",
5
5
  "type": "module",
6
6
  "files": [
@@ -72,12 +72,13 @@ const MultiSelect = forwardRef<MultiSelectHandle, MultiSelectProps>(
72
72
 
73
73
  useEffect(() => {
74
74
  if (showPopover) {
75
- inputRef.current?.focus();
75
+ setTimeout(() => {
76
+ inputRef.current?.focus();
77
+ }, 0);
76
78
  }
77
79
  }, [showPopover]);
78
80
 
79
81
  const getSelectedDisplay = useCallback(() => {
80
- // if (selected.length === 0) return placeholder;
81
82
  const displayedItems = selected
82
83
  .slice(0, 3)
83
84
  .map(
@@ -162,33 +163,40 @@ const MultiSelect = forwardRef<MultiSelectHandle, MultiSelectProps>(
162
163
  </>
163
164
  );
164
165
 
165
- // Selected display Content
166
166
  const selectedDisplay = (
167
- <span className="flex items-center gap-1">
167
+ <div className="flex items-center gap-1 flex-wrap pr-16">
168
168
  {selected
169
169
  .slice(0, truncate && selected.length > 3 ? 3 : selected.length)
170
- .map((item: string, index: number) => {
170
+ .map((value: string, index: number) => {
171
+ const item = workingDataSource.find(
172
+ (dataItem) => dataItem.value === value
173
+ );
174
+ const label = item?.label || value;
175
+
171
176
  return (
172
177
  <span
173
178
  key={index}
174
- className="bg-slate-800 text-white px-2 py-1 rounded flex items-center gap-1 text-xs"
179
+ className="bg-slate-800 text-white px-2 py-1 rounded flex items-center gap-1 text-xs whitespace-nowrap"
175
180
  >
176
- {item}{" "}
181
+ {label.length > 15 ? `${label.substring(0, 15)}...` : label}
177
182
  <span
178
- onClick={() => handleSelect(item)}
179
- className="cursor-pointer"
183
+ onClick={(e) => {
184
+ e.stopPropagation();
185
+ handleSelect(value);
186
+ }}
187
+ className="cursor-pointer hover:bg-slate-700 rounded p-0.5"
180
188
  >
181
- <Icon elements={x} svgClass={iconClass["grey-common"]} />
189
+ <Icon elements={x} svgClass="h-3 w-3 stroke-white" />
182
190
  </span>
183
191
  </span>
184
192
  );
185
193
  })}
186
194
  {truncate && selected.length > 3 && (
187
- <span className="bg-slate-800 text-white px-2 py-1 rounded text-xs">
195
+ <span className="bg-slate-800 text-white px-2 py-1 rounded text-xs whitespace-nowrap">
188
196
  +{selected.length - 3} more
189
197
  </span>
190
198
  )}
191
- </span>
199
+ </div>
192
200
  );
193
201
 
194
202
  return (
@@ -198,28 +206,34 @@ const MultiSelect = forwardRef<MultiSelectHandle, MultiSelectProps>(
198
206
  ref={buttonRef}
199
207
  className={`${error ? primary["error-border"] : "border"} ${
200
208
  selectStyle["select-button"]
201
- } ${disabled ? "opacity-50 cursor-not-allowed" : ""}`}
209
+ } ${disabled ? "opacity-50 cursor-not-allowed" : ""} relative`}
202
210
  onClick={togglePopover}
203
211
  type="button"
204
212
  disabled={disabled}
205
213
  >
206
214
  {selected.length == 0 ? (
207
- <span>{placeholder}</span>
215
+ <span className="pr-8">{placeholder}</span>
208
216
  ) : (
209
- <span>{selectedDisplay}</span>
217
+ selectedDisplay
210
218
  )}
211
219
 
212
- <Icon
213
- elements={upDown}
214
- svgClass={`${iconClass["grey-common"]} ${
215
- disabled ? "opacity-50" : ""
216
- }`}
217
- />
220
+ <div className="absolute right-2 top-1/2 transform -translate-y-1/2 pointer-events-none">
221
+ <Icon
222
+ elements={upDown}
223
+ svgClass={`${iconClass["grey-common"]} ${
224
+ disabled ? "opacity-50" : ""
225
+ }`}
226
+ />
227
+ </div>
218
228
  </button>
229
+
219
230
  {selected.length > 0 && (
220
231
  <button
221
- className={selectStyle["selectedDisplay-Button"]}
222
- onClick={handleClear}
232
+ className={`${selectStyle["selectedDisplay-Button"]}`}
233
+ onClick={(e) => {
234
+ e.stopPropagation();
235
+ handleClear();
236
+ }}
223
237
  type="button"
224
238
  >
225
239
  <Icon elements={x} svgClass={iconClass["grey-common"]} />
@@ -198,7 +198,9 @@ const Select = forwardRef<SelectHandle, SelectProps>((props, ref) => {
198
198
  type="button"
199
199
  disabled={disabled}
200
200
  >
201
- {selectedDisplay || placeholder}
201
+ {selectedDisplay.length > 20
202
+ ? `${selectedDisplay.substring(0, 20)}...` // We will truncate the display text if it exceeds 20 characters
203
+ : selectedDisplay || placeholder}
202
204
  <Icon
203
205
  elements={upDown}
204
206
  svgClass={`${iconClass["grey-common"]} ${