@seamapi/react 2.1.3 → 2.1.4

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
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
2
3
  import { SupportedDeviceFilterResultRow } from '../../../../lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterResultRow.js';
3
4
  import { SupportedDeviceManufacturerSection } from '../../../../lib/seam/components/SupportedDeviceTable/SupportedDeviceManufacturerSection.js';
4
5
  import { useFilteredDeviceModels, } from '../../../../lib/seam/components/SupportedDeviceTable/use-filtered-device-models.js';
@@ -10,6 +11,7 @@ export function SupportedDeviceContent({ resetFilterValue, filterValue, filters,
10
11
  manufacturers,
11
12
  excludedManufacturers,
12
13
  });
14
+ const groupedDeviceModels = useMemo(() => groupDeviceModelsByManufacturer(deviceModels ?? []), [deviceModels]);
13
15
  if (isLoading) {
14
16
  return (_jsx("div", { className: 'seam-supported-device-table-content-state-block', children: _jsx("p", { children: t.loading }) }));
15
17
  }
@@ -29,13 +31,17 @@ export function SupportedDeviceContent({ resetFilterValue, filterValue, filters,
29
31
  if (hasFilters) {
30
32
  return (_jsx("div", { className: 'seam-supported-device-table-content', children: deviceModels.map((deviceModel) => (_jsx(SupportedDeviceFilterResultRow, { deviceModel: deviceModel }, deviceModel.device_model_id))) }));
31
33
  }
32
- return (_jsx(_Fragment, { children: Object.entries(groupDeviceModelsByManufacturer(deviceModels)).map(([manufacturerId, models]) => (_jsx(SupportedDeviceManufacturerSection, { manufacturerId: manufacturerId, deviceModels: models }, manufacturerId))) }));
34
+ return (_jsx(_Fragment, { children: Object.entries(groupedDeviceModels)
35
+ .sort((e1, e2) => e1[1][0]?.manufacturer.display_name.localeCompare(e2[1][0]?.manufacturer.display_name ?? '') ?? 0)
36
+ .map(([manufacturerId, models]) => {
37
+ return (_jsx(SupportedDeviceManufacturerSection, { manufacturerId: manufacturerId, deviceModels: models }, manufacturerId));
38
+ }) }));
33
39
  }
34
40
  function EmptyResult({ filterValue, resetFilterValue, }) {
35
41
  const noMatchingRows = (_jsxs(_Fragment, { children: [_jsx("p", { children: t.noMatch }), _jsx(Button, { variant: 'outline', size: 'small', onClick: resetFilterValue, className: 'seam-supported-device-table-content-message-clear-search', children: t.clear })] }));
36
42
  return (_jsx("div", { className: 'seam-supported-device-table-content-message-row', children: _jsx("div", { children: _jsx("div", { className: 'seam-supported-device-table-content-message', children: filterValue.length === 0 ? _jsx("p", { children: t.noneFound }) : noMatchingRows }) }) }));
37
43
  }
38
- function groupDeviceModelsByManufacturer(deviceModels) {
44
+ const groupDeviceModelsByManufacturer = (deviceModels) => {
39
45
  const result = {};
40
46
  for (const model of deviceModels) {
41
47
  const { manufacturer } = model;
@@ -43,7 +49,7 @@ function groupDeviceModelsByManufacturer(deviceModels) {
43
49
  result[manufacturer.manufacturer_id] = [...list, model];
44
50
  }
45
51
  return result;
46
- }
52
+ };
47
53
  const t = {
48
54
  loading: 'Loading device models...',
49
55
  retry: 'Retry',
@@ -1 +1 @@
1
- {"version":3,"file":"SupportedDeviceContent.js","sourceRoot":"","sources":["../../../../src/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,8BAA8B,EAAE,MAAM,4EAA4E,CAAA;AAC3H,OAAO,EAAE,kCAAkC,EAAE,MAAM,gFAAgF,CAAA;AAEnI,OAAO,EAEL,uBAAuB,GACxB,MAAM,wEAAwE,CAAA;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAUzC,MAAM,UAAU,sBAAsB,CAAC,EACrC,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,aAAa,EACb,qBAAqB,GACO;IAC5B,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,uBAAuB,CAC3E;QACE,WAAW;QACX,OAAO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ceContent.js","sourceRoot":"","sources":["../../../../src/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,8BAA8B,EAAE,MAAM,4EAA4E,CAAA;AAC3H,OAAO,EAAE,kCAAkC,EAAE,MAAM,gFAAgF,CAAA;AAEnI,OAAO,EAEL,uBAAuB,GACxB,MAAM,wEAAwE,CAAA;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAUzC,MAAM,UAAU,sBAAsB,CAAC,EACrC,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,aAAa,EACb,qBAAqB,GACO;IAC5B,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,uBAAuB,CAC3E;QACE,WAAW;QACX,OAAO;QACP,aAAa;QACb,qBAAqB;KACtB,CACF,CAAA;IAED,MAAM,mBAAmB,GAAG,OAAO,CACjC,GAAG,EAAE,CAAC,+BAA+B,CAAC,YAAY,IAAI,EAAE,CAAC,EACzD,CAAC,YAAY,CAAC,CACf,CAAA;IAED,IAAI,SAAS,EAAE;QACb,OAAO,CACL,cAAK,SAAS,EAAC,iDAAiD,YAC9D,sBAAI,CAAC,CAAC,OAAO,GAAK,GACd,CACP,CAAA;KACF;IAED,IAAI,OAAO,EAAE;QACX,OAAO,CACL,eAAK,SAAS,EAAC,iDAAiD,aAC9D,sBAAI,CAAC,CAAC,KAAK,GAAK,EAChB,KAAC,MAAM,IACL,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE;wBACZ,KAAK,OAAO,EAAE,CAAA;oBAChB,CAAC,YAEA,CAAC,CAAC,KAAK,GACD,IACL,CACP,CAAA;KACF;IAED,IAAI,YAAY,IAAI,IAAI,EAAE;QACxB,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,OAAO,GAAG,YA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I,EAAC,OAAO,EACZ,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAC,0DAA0D,YAEnE,CAAC,CAAC,KAAK,GACD,IACR,CACJ,CAAA;IAED,OAAO,CACL,cAAK,SAAS,EAAC,iDAAiD,YAC9D,wBACE,cAAK,SAAS,EAAC,6CAA6C,YACzD,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,sBAAI,CAAC,CAAC,SAAS,GAAK,CAAC,CAAC,CAAC,cAAc,GAC7D,GACF,GACF,CACP,CAAA;AACH,CAAC;AAED,MAAM,+BAA+B,GAAG,CACtC,YAAiC,EACA,EAAE;IACnC,MAAM,MAAM,GAAoC,EAAE,CAAA;IAElD,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE;QAChC,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAA;QAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,EAAE,CAAA;QACvD,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,CAAA;KACxD;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,CAAC,GAAG;IACR,OAAO,EAAE,0BAA0B;IACnC,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,4CAA4C;IACnD,SAAS,EAAE,yBAAyB;IACpC,OAAO,EAAE,uCAAuC;IAChD,KAAK,EAAE,oBAAoB;CAC5B,CAAA"}
package/lib/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const seamapiReactVersion = "2.1.3";
1
+ declare const seamapiReactVersion = "2.1.4";
2
2
  export default seamapiReactVersion;
package/lib/version.js CHANGED
@@ -1,3 +1,3 @@
1
- const seamapiReactVersion = '2.1.3';
1
+ const seamapiReactVersion = '2.1.4';
2
2
  export default seamapiReactVersion;
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamapi/react",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "Seam Components.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,4 +1,5 @@
1
1
  import type { DeviceModelV1 } from '@seamapi/types/devicedb'
2
+ import { useMemo } from 'react'
2
3
 
3
4
  import { SupportedDeviceFilterResultRow } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterResultRow.js'
4
5
  import { SupportedDeviceManufacturerSection } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceManufacturerSection.js'
@@ -33,6 +34,11 @@ export function SupportedDeviceContent({
33
34
  }
34
35
  )
35
36
 
37
+ const groupedDeviceModels = useMemo(
38
+ () => groupDeviceModelsByManufacturer(deviceModels ?? []),
39
+ [deviceModels]
40
+ )
41
+
36
42
  if (isLoading) {
37
43
  return (
38
44
  <div className='seam-supported-device-table-content-state-block'>
@@ -91,15 +97,22 @@ export function SupportedDeviceContent({
91
97
 
92
98
  return (
93
99
  <>
94
- {Object.entries(groupDeviceModelsByManufacturer(deviceModels)).map(
95
- ([manufacturerId, models]) => (
96
- <SupportedDeviceManufacturerSection
97
- key={manufacturerId}
98
- manufacturerId={manufacturerId}
99
- deviceModels={models}
100
- />
100
+ {Object.entries(groupedDeviceModels)
101
+ .sort(
102
+ (e1, e2) =>
103
+ e1[1][0]?.manufacturer.display_name.localeCompare(
104
+ e2[1][0]?.manufacturer.display_name ?? ''
105
+ ) ?? 0
101
106
  )
102
- )}
107
+ .map(([manufacturerId, models]) => {
108
+ return (
109
+ <SupportedDeviceManufacturerSection
110
+ key={manufacturerId}
111
+ manufacturerId={manufacturerId}
112
+ deviceModels={models}
113
+ />
114
+ )
115
+ })}
103
116
  </>
104
117
  )
105
118
  }
@@ -136,9 +149,9 @@ function EmptyResult({
136
149
  )
137
150
  }
138
151
 
139
- function groupDeviceModelsByManufacturer(
152
+ const groupDeviceModelsByManufacturer = (
140
153
  deviceModels: UseDeviceModelsData
141
- ): Record<string, DeviceModelV1[]> {
154
+ ): Record<string, DeviceModelV1[]> => {
142
155
  const result: Record<string, DeviceModelV1[]> = {}
143
156
 
144
157
  for (const model of deviceModels) {
@@ -1,3 +1,3 @@
1
- const seamapiReactVersion = '2.1.3'
1
+ const seamapiReactVersion = '2.1.4'
2
2
 
3
3
  export default seamapiReactVersion