gbs-add-block 1.0.19 → 1.0.21

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.19)
1
+ # GBS Building Blocks 2.0 (v1.0.21)
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.19)
9
+ ## What's New 🎉 (Ver 1.0.21)
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.19",
3
+ "version": "1.0.21",
4
4
  "description": "React Component Library",
5
5
  "type": "module",
6
6
  "files": [
@@ -79,7 +79,6 @@ const MultiSelect = forwardRef<MultiSelectHandle, MultiSelectProps>(
79
79
  }, [showPopover]);
80
80
 
81
81
  const getSelectedDisplay = useCallback(() => {
82
- // if (selected.length === 0) return placeholder;
83
82
  const displayedItems = selected
84
83
  .slice(0, 3)
85
84
  .map(
@@ -164,33 +163,40 @@ const MultiSelect = forwardRef<MultiSelectHandle, MultiSelectProps>(
164
163
  </>
165
164
  );
166
165
 
167
- // Selected display Content
168
166
  const selectedDisplay = (
169
- <span className="flex items-center gap-1">
167
+ <div className="flex items-center gap-1 flex-wrap pr-16">
170
168
  {selected
171
169
  .slice(0, truncate && selected.length > 3 ? 3 : selected.length)
172
- .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
+
173
176
  return (
174
177
  <span
175
178
  key={index}
176
- 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"
177
180
  >
178
- {item}{" "}
181
+ {label.length > 15 ? `${label.substring(0, 15)}...` : label}
179
182
  <span
180
- onClick={() => handleSelect(item)}
181
- 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"
182
188
  >
183
- <Icon elements={x} svgClass={iconClass["grey-common"]} />
189
+ <Icon elements={x} svgClass="h-3 w-3 stroke-white" />
184
190
  </span>
185
191
  </span>
186
192
  );
187
193
  })}
188
194
  {truncate && selected.length > 3 && (
189
- <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">
190
196
  +{selected.length - 3} more
191
197
  </span>
192
198
  )}
193
- </span>
199
+ </div>
194
200
  );
195
201
 
196
202
  return (
@@ -200,28 +206,34 @@ const MultiSelect = forwardRef<MultiSelectHandle, MultiSelectProps>(
200
206
  ref={buttonRef}
201
207
  className={`${error ? primary["error-border"] : "border"} ${
202
208
  selectStyle["select-button"]
203
- } ${disabled ? "opacity-50 cursor-not-allowed" : ""}`}
209
+ } ${disabled ? "opacity-50 cursor-not-allowed" : ""} relative`}
204
210
  onClick={togglePopover}
205
211
  type="button"
206
212
  disabled={disabled}
207
213
  >
208
214
  {selected.length == 0 ? (
209
- <span>{placeholder}</span>
215
+ <span className="pr-8">{placeholder}</span>
210
216
  ) : (
211
- <span>{selectedDisplay}</span>
217
+ selectedDisplay
212
218
  )}
213
219
 
214
- <Icon
215
- elements={upDown}
216
- svgClass={`${iconClass["grey-common"]} ${
217
- disabled ? "opacity-50" : ""
218
- }`}
219
- />
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>
220
228
  </button>
229
+
221
230
  {selected.length > 0 && (
222
231
  <button
223
- className={selectStyle["selectedDisplay-Button"]}
224
- onClick={handleClear}
232
+ className={`${selectStyle["selectedDisplay-Button"]}`}
233
+ onClick={(e) => {
234
+ e.stopPropagation();
235
+ handleClear();
236
+ }}
225
237
  type="button"
226
238
  >
227
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"]} ${