@temp-spotwork/ui 1.7.7 → 1.7.9

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.
@@ -0,0 +1,40 @@
1
+ import { LabelValuePair } from '../form-types';
2
+
3
+ export type SpotterDropdownOption = LabelValuePair & {
4
+ /**
5
+ * URL of the spotter profile image.
6
+ */
7
+ image?: string;
8
+ /**
9
+ * Optional secondary line (e.g. email, role, location).
10
+ */
11
+ subtitle?: string;
12
+ };
13
+ export type DropdownItemProps = {
14
+ /**
15
+ * Unique identifier for the avatar.
16
+ */
17
+ avatarId: string;
18
+ /**
19
+ * Spotter display name.
20
+ */
21
+ name: string;
22
+ /**
23
+ * URL of the spotter profile image.
24
+ */
25
+ image?: string;
26
+ /**
27
+ * Text abbreviation fallback when no image is provided.
28
+ */
29
+ textView?: string;
30
+ /**
31
+ * Optional secondary line displayed below the name.
32
+ */
33
+ subtitle?: string;
34
+ /**
35
+ * Optional classes for the container.
36
+ */
37
+ className?: string;
38
+ };
39
+ export declare function DropdownItem({ avatarId, name, image, textView, subtitle, className, }: DropdownItemProps): import("react/jsx-runtime").JSX.Element;
40
+ export declare function renderSpotterDropdownOption(option: string | LabelValuePair | SpotterDropdownOption): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,49 @@
1
+ import { jsxs as o, jsx as r } from "react/jsx-runtime";
2
+ import { t as c } from "../../../../bundle-mjs-BjFsLjkg.js";
3
+ import { Avatar as p } from "../../avatar/avatar.js";
4
+ import { Typography as s } from "../../../styles/typography/typography.js";
5
+ import { getStyles as u } from "./styles.js";
6
+ function n({
7
+ avatarId: e,
8
+ name: t,
9
+ image: l,
10
+ textView: m,
11
+ subtitle: i,
12
+ className: d
13
+ }) {
14
+ const a = u();
15
+ return /* @__PURE__ */ o("div", { className: c(a.container, d), "data-testid": "dropdown-item", children: [
16
+ /* @__PURE__ */ r(
17
+ p,
18
+ {
19
+ id: e,
20
+ variant: "circular",
21
+ image: l,
22
+ textView: m ?? t,
23
+ size: 3.5
24
+ }
25
+ ),
26
+ /* @__PURE__ */ o("div", { className: a.textContainer, children: [
27
+ /* @__PURE__ */ r(s, { swStyle: 5, color: "default", className: a.name, children: t }),
28
+ i && /* @__PURE__ */ r(s, { swStyle: 6, color: "subdued", className: a.subtitle, children: i })
29
+ ] })
30
+ ] });
31
+ }
32
+ function h(e) {
33
+ if (typeof e == "string")
34
+ return /* @__PURE__ */ r(n, { avatarId: e, name: e });
35
+ const t = e;
36
+ return /* @__PURE__ */ r(
37
+ n,
38
+ {
39
+ avatarId: t.value,
40
+ name: t.label,
41
+ image: t.image,
42
+ subtitle: t.subtitle
43
+ }
44
+ );
45
+ }
46
+ export {
47
+ n as DropdownItem,
48
+ h as renderSpotterDropdownOption
49
+ };
@@ -0,0 +1,11 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { DropdownItem } from './dropdown-item';
3
+
4
+ declare const meta: Meta<typeof DropdownItem>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof meta>;
7
+ export declare const Default: Story;
8
+ export declare const WithoutImage: Story;
9
+ export declare const WithoutSubtitle: Story;
10
+ export declare const WithDropdownSearch: Story;
11
+ export declare const WithTypeahead: Story;
@@ -0,0 +1,109 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { useState as o } from "react";
3
+ import { DropdownItem as l, renderSpotterDropdownOption as a } from "./dropdown-item.js";
4
+ import { DropdownSearch as p } from "../dropdown-search/dropdown-search.js";
5
+ import { Typeahead as c } from "../typeahead/typeahead.js";
6
+ const s = [
7
+ {
8
+ label: "Sarah Johnson",
9
+ value: "spotter-1",
10
+ image: "https://i.pravatar.cc/150?u=spotter-1",
11
+ subtitle: "Toronto, ON"
12
+ },
13
+ {
14
+ label: "Michael Chen",
15
+ value: "spotter-2",
16
+ image: "https://i.pravatar.cc/150?u=spotter-2",
17
+ subtitle: "Vancouver, BC"
18
+ },
19
+ {
20
+ label: "Emily Rodriguez",
21
+ value: "spotter-3",
22
+ subtitle: "Calgary, AB"
23
+ },
24
+ {
25
+ label: "James Wilson",
26
+ value: "spotter-4",
27
+ image: "https://i.pravatar.cc/150?u=spotter-4"
28
+ }
29
+ ], g = {
30
+ title: "@spotwork-ui/atoms/form/DropdownItem",
31
+ component: l,
32
+ parameters: {
33
+ layout: "centered",
34
+ docs: {
35
+ description: {
36
+ component: "A reusable dropdown row for spotter search results. Displays an avatar, name, and optional subtitle using design tokens."
37
+ }
38
+ }
39
+ },
40
+ tags: ["autodocs"],
41
+ argTypes: {
42
+ name: { control: "text" },
43
+ subtitle: { control: "text" },
44
+ image: { control: "text" }
45
+ }
46
+ }, n = {
47
+ args: {
48
+ avatarId: "spotter-1",
49
+ name: "Sarah Johnson",
50
+ image: "https://i.pravatar.cc/150?u=spotter-1",
51
+ subtitle: "Toronto, ON"
52
+ },
53
+ decorators: [
54
+ (t) => /* @__PURE__ */ e("div", { className: "w-[32rem] border border-bcolor-subdued rounded", children: /* @__PURE__ */ e("div", { className: "min-h-[4rem] w-full flex items-center border-b border-bcolor-subdued py-[0.75rem] px-[1rem]", children: /* @__PURE__ */ e(t, {}) }) })
55
+ ]
56
+ }, w = {
57
+ args: {
58
+ avatarId: "spotter-3",
59
+ name: "Emily Rodriguez",
60
+ subtitle: "Calgary, AB"
61
+ },
62
+ decorators: n.decorators
63
+ }, y = {
64
+ args: {
65
+ avatarId: "spotter-4",
66
+ name: "James Wilson",
67
+ image: "https://i.pravatar.cc/150?u=spotter-4"
68
+ },
69
+ decorators: n.decorators
70
+ }, i = () => {
71
+ const [t, r] = o("");
72
+ return /* @__PURE__ */ e("div", { className: "w-[36rem]", children: /* @__PURE__ */ e(
73
+ p,
74
+ {
75
+ label: "Search spotters",
76
+ placeholder: "Search by name...",
77
+ options: s,
78
+ value: t,
79
+ selectValue: r,
80
+ renderOption: a
81
+ }
82
+ ) });
83
+ }, S = {
84
+ render: () => /* @__PURE__ */ e(i, {})
85
+ }, d = () => {
86
+ const [t, r] = o("");
87
+ return /* @__PURE__ */ e("div", { className: "w-[36rem]", children: /* @__PURE__ */ e(
88
+ c,
89
+ {
90
+ label: "Search spotters",
91
+ placeholder: "Search by name...",
92
+ options: s,
93
+ value: t,
94
+ onChange: r,
95
+ selectValue: r,
96
+ renderOption: a
97
+ }
98
+ ) });
99
+ }, f = {
100
+ render: () => /* @__PURE__ */ e(d, {})
101
+ };
102
+ export {
103
+ n as Default,
104
+ S as WithDropdownSearch,
105
+ f as WithTypeahead,
106
+ w as WithoutImage,
107
+ y as WithoutSubtitle,
108
+ g as default
109
+ };
@@ -0,0 +1,2 @@
1
+ export { DropdownItem, renderSpotterDropdownOption } from './dropdown-item';
2
+ export type { DropdownItemProps, SpotterDropdownOption } from './dropdown-item';
@@ -0,0 +1,5 @@
1
+ import { DropdownItem as e, renderSpotterDropdownOption as p } from "./dropdown-item.js";
2
+ export {
3
+ e as DropdownItem,
4
+ p as renderSpotterDropdownOption
5
+ };
@@ -0,0 +1,6 @@
1
+ export declare const getStyles: () => {
2
+ container: string;
3
+ textContainer: string;
4
+ name: string;
5
+ subtitle: string;
6
+ };
@@ -0,0 +1,9 @@
1
+ const e = () => ({
2
+ container: "flex items-center gap-md w-full min-w-0",
3
+ textContainer: "flex flex-col min-w-0 flex-1",
4
+ name: "truncate",
5
+ subtitle: "truncate"
6
+ });
7
+ export {
8
+ e as getStyles
9
+ };
@@ -16,6 +16,7 @@ export declare const Controlled: Story;
16
16
  export declare const ControlledWithExternalState: Story;
17
17
  export declare const WithAddValue: Story;
18
18
  export declare const CustomRenderOption: Story;
19
+ export declare const SpotterSearch: Story;
19
20
  export declare const LargeDataset: Story;
20
21
  export declare const AutoFocus: Story;
21
22
  export declare const CustomNotFoundText: Story;
@@ -6,6 +6,7 @@ import { Typography as p } from "../../../styles/typography/typography.js";
6
6
  import { Icons as h } from "../../icons/icons.js";
7
7
  import "../../icons/iconsSVGs/Large/Profile.js";
8
8
  import "../../icons/iconsSVGs/Small/Profile.js";
9
+ import { renderSpotterDropdownOption as g } from "../dropdown-item/dropdown-item.js";
9
10
  const t = [
10
11
  { label: "Apple", value: "apple" },
11
12
  { label: "Banana", value: "banana" },
@@ -15,7 +16,7 @@ const t = [
15
16
  { label: "Fig", value: "fig" },
16
17
  { label: "Grape", value: "grape" },
17
18
  { label: "Honeydew", value: "honeydew" }
18
- ], g = [
19
+ ], m = [
19
20
  { label: "Canada", value: "CA" },
20
21
  { label: "United States", value: "US" },
21
22
  { label: "United Kingdom", value: "UK" },
@@ -26,7 +27,25 @@ const t = [
26
27
  { label: "Japan", value: "JP" },
27
28
  { label: "Australia", value: "AU" },
28
29
  { label: "Brazil", value: "BR" }
29
- ], m = (e) => /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
30
+ ], v = [
31
+ {
32
+ label: "Sarah Johnson",
33
+ value: "spotter-1",
34
+ image: "https://i.pravatar.cc/150?u=spotter-1",
35
+ subtitle: "Toronto, ON"
36
+ },
37
+ {
38
+ label: "Michael Chen",
39
+ value: "spotter-2",
40
+ image: "https://i.pravatar.cc/150?u=spotter-2",
41
+ subtitle: "Vancouver, BC"
42
+ },
43
+ {
44
+ label: "Emily Rodriguez",
45
+ value: "spotter-3",
46
+ subtitle: "Calgary, AB"
47
+ }
48
+ ], y = (e) => /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
30
49
  /* @__PURE__ */ o(h, { icon: "Building" }),
31
50
  /* @__PURE__ */ l("div", { className: "flex flex-col", children: [
32
51
  /* @__PURE__ */ o(p, { swStyle: 5, color: "default", children: e.label }),
@@ -36,8 +55,8 @@ const t = [
36
55
  ] })
37
56
  ] })
38
57
  ] }), d = (e) => {
39
- var r, s;
40
- const [a, n] = u(e.value || "");
58
+ var n, s;
59
+ const [a, r] = u(e.value || "");
41
60
  return /* @__PURE__ */ l("div", { className: "space-y-4", children: [
42
61
  /* @__PURE__ */ o(
43
62
  c,
@@ -45,7 +64,7 @@ const t = [
45
64
  ...e,
46
65
  value: a,
47
66
  onChange: e.onChange,
48
- selectValue: n
67
+ selectValue: r
49
68
  }
50
69
  ),
51
70
  /* @__PURE__ */ l("div", { className: "text-sm text-gray-600", children: [
@@ -55,11 +74,11 @@ const t = [
55
74
  ] }),
56
75
  /* @__PURE__ */ l("p", { children: [
57
76
  "Selected option: ",
58
- /* @__PURE__ */ o("strong", { children: a ? ((s = (r = e.options) == null ? void 0 : r.find((i) => i.value === a)) == null ? void 0 : s.label) || "not found" : "none" })
77
+ /* @__PURE__ */ o("strong", { children: a ? ((s = (n = e.options) == null ? void 0 : n.find((i) => i.value === a)) == null ? void 0 : s.label) || "not found" : "none" })
59
78
  ] })
60
79
  ] })
61
80
  ] });
62
- }, A = {
81
+ }, E = {
63
82
  title: "@spotwork-ui/atoms/form/DropdownSearch",
64
83
  component: c,
65
84
  parameters: {
@@ -137,25 +156,25 @@ const t = [
137
156
  placeholder: "Search options...",
138
157
  notFoundText: "No results found"
139
158
  }
140
- }, F = {
159
+ }, D = {
141
160
  args: {
142
161
  options: t,
143
162
  label: "Select a fruit"
144
163
  }
145
- }, N = {
164
+ }, k = {
146
165
  args: {
147
166
  options: t,
148
167
  label: "Choose your favorite fruit",
149
168
  placeholder: "Type to search fruits..."
150
169
  }
151
- }, E = {
170
+ }, V = {
152
171
  args: {
153
172
  options: t,
154
173
  label: "Fruit Selection",
155
174
  helperText: "Select a fruit from the dropdown or search for one",
156
175
  placeholder: "Search fruits..."
157
176
  }
158
- }, k = {
177
+ }, O = {
159
178
  args: {
160
179
  options: t,
161
180
  label: "Fruit Selection",
@@ -163,7 +182,7 @@ const t = [
163
182
  helperText: "Please select a valid fruit",
164
183
  placeholder: "Search fruits..."
165
184
  }
166
- }, D = {
185
+ }, U = {
167
186
  args: {
168
187
  options: t,
169
188
  label: "Fruit Selection",
@@ -171,7 +190,7 @@ const t = [
171
190
  helperText: "Consider selecting a seasonal fruit",
172
191
  placeholder: "Search fruits..."
173
192
  }
174
- }, V = {
193
+ }, L = {
175
194
  args: {
176
195
  options: t,
177
196
  label: "Fruit Selection",
@@ -179,7 +198,7 @@ const t = [
179
198
  value: "apple",
180
199
  placeholder: "Search fruits..."
181
200
  }
182
- }, U = {
201
+ }, B = {
183
202
  args: {
184
203
  options: t,
185
204
  label: "Loading Options",
@@ -187,30 +206,30 @@ const t = [
187
206
  loadingIcon: /* @__PURE__ */ o(h, { icon: "Clock" }),
188
207
  placeholder: "Loading..."
189
208
  }
190
- }, L = {
209
+ }, R = {
191
210
  args: {
192
211
  options: [],
193
212
  label: "No Options",
194
213
  placeholder: "No options available",
195
214
  notFoundText: "No options match your search"
196
215
  }
197
- }, O = {
216
+ }, I = {
198
217
  render: (e) => /* @__PURE__ */ o(d, { ...e }),
199
218
  args: {
200
219
  options: t,
201
220
  label: "Controlled Dropdown",
202
221
  placeholder: "Type to search..."
203
222
  }
204
- }, I = {
223
+ }, W = {
205
224
  render: (e) => {
206
- var r, s;
207
- const [a, n] = u("banana");
225
+ var n, s;
226
+ const [a, r] = u("banana");
208
227
  return /* @__PURE__ */ l("div", { className: "space-y-4", children: [
209
228
  /* @__PURE__ */ l("div", { className: "flex gap-2", children: [
210
229
  /* @__PURE__ */ o(
211
230
  "button",
212
231
  {
213
- onClick: () => n("apple"),
232
+ onClick: () => r("apple"),
214
233
  className: "px-3 py-1 bg-blue-500 text-white rounded text-sm",
215
234
  children: "Set to Apple"
216
235
  }
@@ -218,7 +237,7 @@ const t = [
218
237
  /* @__PURE__ */ o(
219
238
  "button",
220
239
  {
221
- onClick: () => n("cherry"),
240
+ onClick: () => r("cherry"),
222
241
  className: "px-3 py-1 bg-blue-500 text-white rounded text-sm",
223
242
  children: "Set to Cherry"
224
243
  }
@@ -226,7 +245,7 @@ const t = [
226
245
  /* @__PURE__ */ o(
227
246
  "button",
228
247
  {
229
- onClick: () => n(""),
248
+ onClick: () => r(""),
230
249
  className: "px-3 py-1 bg-red-500 text-white rounded text-sm",
231
250
  children: "Clear"
232
251
  }
@@ -237,7 +256,7 @@ const t = [
237
256
  {
238
257
  ...e,
239
258
  value: a,
240
- selectValue: n
259
+ selectValue: r
241
260
  }
242
261
  ),
243
262
  /* @__PURE__ */ l("div", { className: "text-sm text-gray-600", children: [
@@ -247,7 +266,7 @@ const t = [
247
266
  ] }),
248
267
  /* @__PURE__ */ l("p", { children: [
249
268
  "Selected option: ",
250
- /* @__PURE__ */ o("strong", { children: a ? ((s = (r = e.options) == null ? void 0 : r.find((i) => i.value === a)) == null ? void 0 : s.label) || "not found" : "none" })
269
+ /* @__PURE__ */ o("strong", { children: a ? ((s = (n = e.options) == null ? void 0 : n.find((i) => i.value === a)) == null ? void 0 : s.label) || "not found" : "none" })
251
270
  ] })
252
271
  ] })
253
272
  ] });
@@ -264,7 +283,7 @@ const t = [
264
283
  }
265
284
  }
266
285
  }
267
- }, R = {
286
+ }, K = {
268
287
  render: (e) => /* @__PURE__ */ o(d, { ...e }),
269
288
  args: {
270
289
  options: t,
@@ -272,14 +291,21 @@ const t = [
272
291
  placeholder: "Search or add new value...",
273
292
  addValue: b()
274
293
  }
275
- }, W = {
294
+ }, P = {
276
295
  args: {
277
- options: g,
296
+ options: m,
278
297
  label: "Select Country",
279
298
  placeholder: "Search countries...",
280
- renderOption: m
299
+ renderOption: y
281
300
  }
282
- }, B = {
301
+ }, j = {
302
+ args: {
303
+ options: v,
304
+ label: "Search spotters",
305
+ placeholder: "Search by name...",
306
+ renderOption: g
307
+ }
308
+ }, z = {
283
309
  args: {
284
310
  options: Array.from({ length: 100 }, (e, a) => ({
285
311
  label: `Option ${a + 1}`,
@@ -288,28 +314,28 @@ const t = [
288
314
  label: "Large Dataset",
289
315
  placeholder: "Search through 100 options..."
290
316
  }
291
- }, K = {
317
+ }, J = {
292
318
  args: {
293
319
  options: t,
294
320
  label: "Auto Focus",
295
321
  autoFocus: !0,
296
322
  placeholder: "This field is auto-focused"
297
323
  }
298
- }, P = {
324
+ }, G = {
299
325
  args: {
300
326
  options: [],
301
327
  label: "Custom Not Found",
302
328
  placeholder: "Search for something...",
303
329
  notFoundText: "Sorry, we couldn't find what you're looking for. Try a different search term."
304
330
  }
305
- }, j = {
331
+ }, H = {
306
332
  args: {
307
333
  options: t,
308
334
  label: "Preselected Value",
309
335
  value: "banana",
310
336
  placeholder: "Search fruits..."
311
337
  }
312
- }, z = {
338
+ }, $ = {
313
339
  render: (e) => /* @__PURE__ */ o(d, { ...e }),
314
340
  args: {
315
341
  options: t,
@@ -324,7 +350,7 @@ const t = [
324
350
  }
325
351
  }
326
352
  }
327
- }, G = {
353
+ }, M = {
328
354
  args: {
329
355
  options: t,
330
356
  label: "Accessible Dropdown",
@@ -340,23 +366,24 @@ const t = [
340
366
  }
341
367
  };
342
368
  export {
343
- G as Accessibility,
344
- K as AutoFocus,
345
- O as Controlled,
346
- I as ControlledWithExternalState,
347
- P as CustomNotFoundText,
348
- W as CustomRenderOption,
349
- F as Default,
350
- V as Disabled,
351
- L as EmptyState,
352
- k as ErrorState,
353
- z as KeyboardNavigation,
354
- B as LargeDataset,
355
- U as Loading,
356
- D as WarningState,
357
- R as WithAddValue,
358
- E as WithHelperText,
359
- N as WithLabel,
360
- j as WithPreselectedValue,
361
- A as default
369
+ M as Accessibility,
370
+ J as AutoFocus,
371
+ I as Controlled,
372
+ W as ControlledWithExternalState,
373
+ G as CustomNotFoundText,
374
+ P as CustomRenderOption,
375
+ D as Default,
376
+ L as Disabled,
377
+ R as EmptyState,
378
+ O as ErrorState,
379
+ $ as KeyboardNavigation,
380
+ z as LargeDataset,
381
+ B as Loading,
382
+ j as SpotterSearch,
383
+ U as WarningState,
384
+ K as WithAddValue,
385
+ V as WithHelperText,
386
+ k as WithLabel,
387
+ H as WithPreselectedValue,
388
+ E as default
362
389
  };
@@ -79,5 +79,9 @@ export type TypeaheadProps = {
79
79
  * This prop added specially for Address Form Component when we render addresses from google API and don't need to filter them.
80
80
  */
81
81
  disableOptionsFiltering?: boolean;
82
+ /**
83
+ * Custom renderer for dropdown options.
84
+ */
85
+ renderOption?: (option: string | LabelValuePair) => React.ReactNode;
82
86
  };
83
- export declare function Typeahead({ error, warning, helperText, label, placeholder, disabled, options, value, selectValue, onChange, endIconClick, addValue, inputRef, onBlur, loadingIcon, autoFocus, expandOnFocus, notFoundText, disableOptionsFiltering, }: TypeaheadProps): import("react/jsx-runtime").JSX.Element;
87
+ export declare function Typeahead({ error, warning, helperText, label, placeholder, disabled, options, value, selectValue, onChange, endIconClick, addValue, inputRef, onBlur, loadingIcon, autoFocus, expandOnFocus, notFoundText, disableOptionsFiltering, renderOption, }: TypeaheadProps): import("react/jsx-runtime").JSX.Element;