@headless-adminapp/fluent 0.0.17-alpha.35 → 0.0.17-alpha.38

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.
@@ -4,5 +4,6 @@ export interface TableCellLinkProps {
4
4
  href?: string;
5
5
  onClick?: () => void;
6
6
  width: number;
7
+ target?: string;
7
8
  }
8
9
  export declare const TableCellLink: FC<TableCellLinkProps>;
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_components_1 = require("@fluentui/react-components");
6
6
  const hooks_1 = require("@headless-adminapp/app/route/hooks");
7
7
  const react_1 = require("react");
8
- exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width }) => {
8
+ exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width, target }) => {
9
9
  const router = (0, hooks_1.useRouter)();
10
10
  return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: {
11
11
  textOverflow: 'ellipsis',
@@ -16,7 +16,10 @@ exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width }) => {
16
16
  maxWidth: width,
17
17
  display: 'flex',
18
18
  alignItems: 'center',
19
- }, children: (0, jsx_runtime_1.jsx)(react_components_1.Link, { as: "a", href: href, onClick: (event) => {
19
+ }, children: (0, jsx_runtime_1.jsx)(react_components_1.Link, { as: "a", href: href, target: target, onClick: (event) => {
20
+ if (target === '_blank') {
21
+ return;
22
+ }
20
23
  if (event.metaKey || event.ctrlKey) {
21
24
  return;
22
25
  }
@@ -16,6 +16,7 @@ const utils_1 = require("@headless-adminapp/app/utils");
16
16
  const app_1 = require("@headless-adminapp/core/experience/app");
17
17
  const react_table_1 = require("@tanstack/react-table");
18
18
  const react_1 = require("react");
19
+ const componentStore_1 = require("../componentStore");
19
20
  const GridColumnHeader_1 = require("../DataGrid/GridColumnHeader");
20
21
  const TableCell_1 = require("../DataGrid/TableCell");
21
22
  const TableCellLink_1 = require("../DataGrid/TableCell/TableCellLink");
@@ -207,6 +208,13 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
207
208
  dateFormat: dateFormats.short,
208
209
  timezone,
209
210
  })) !== null && _c !== void 0 ? _c : '';
211
+ if (column.component) {
212
+ const Component = componentStore_1.componentStore.getComponent(column.component);
213
+ if (!Component) {
214
+ throw new Error(`Component with name ${column.component} not found`);
215
+ }
216
+ return ((0, jsx_runtime_1.jsx)(Component, { column: column, schema: schema, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue }));
217
+ }
210
218
  if (schema.primaryAttribute === column.name) {
211
219
  const path = routeResolver({
212
220
  logicalName: schema.logicalName,
@@ -233,6 +241,12 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
233
241
  recordSetSetter('', []);
234
242
  router.push(path);
235
243
  } }, column.id));
244
+ case 'attachment':
245
+ const url = value === null || value === void 0 ? void 0 : value.url;
246
+ if (!url) {
247
+ return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info.column.getSize() }, column.id));
248
+ }
249
+ return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: formattedValue, width: info.column.getSize(), href: url, target: "_blank" }, column.id));
236
250
  }
237
251
  return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
238
252
  },
@@ -254,10 +268,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
254
268
  recordSetSetter,
255
269
  routeResolver,
256
270
  router,
257
- schema.attributes,
258
- schema.idAttribute,
259
- schema.logicalName,
260
- schema.primaryAttribute,
271
+ schema,
261
272
  schemaStore,
262
273
  setSorting,
263
274
  timezone,
@@ -26,6 +26,7 @@ const SwitchControl_1 = require("../form/controls/SwitchControl");
26
26
  const TelephoneControl_1 = require("../form/controls/TelephoneControl");
27
27
  const TextAreaControl_1 = require("../form/controls/TextAreaControl");
28
28
  const TextControl_1 = require("../form/controls/TextControl");
29
+ const UrlControl_1 = require("../form/controls/UrlControl");
29
30
  const StandardControl = (props) => {
30
31
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
31
32
  const { attribute, label: _label, isError,
@@ -74,7 +75,7 @@ const StandardControl = (props) => {
74
75
  return (0, jsx_runtime_1.jsx)(Control, Object.assign({}, controlProps));
75
76
  }
76
77
  case 'url': {
77
- const Control = (_e = componentStore_1.componentStore.getComponent('Form.UrlControl')) !== null && _e !== void 0 ? _e : TextControl_1.TextControl;
78
+ const Control = (_e = componentStore_1.componentStore.getComponent('Form.UrlControl')) !== null && _e !== void 0 ? _e : UrlControl_1.UrlControl;
78
79
  return (0, jsx_runtime_1.jsx)(Control, Object.assign({}, controlProps));
79
80
  }
80
81
  case 'textarea': {
@@ -0,0 +1,4 @@
1
+ import { ControlProps } from './types';
2
+ export interface UrlControlProps extends ControlProps<string> {
3
+ }
4
+ export declare function UrlControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, }: UrlControlProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UrlControl = UrlControl;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_components_1 = require("@fluentui/react-components");
6
+ const icons_1 = require("@headless-adminapp/icons");
7
+ function UrlControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, }) {
8
+ return ((0, jsx_runtime_1.jsx)(react_components_1.Input, { type: "url", placeholder: placeholder, id: id, appearance: "filled-darker", name: name, value: value || '', onChange: (e) => onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value), onBlur: () => onBlur === null || onBlur === void 0 ? void 0 : onBlur(), onFocus: () => onFocus === null || onFocus === void 0 ? void 0 : onFocus(),
9
+ // invalid={error}
10
+ disabled: disabled, autoComplete: "off", style: {
11
+ width: '100%',
12
+ paddingRight: react_components_1.tokens.spacingHorizontalXS,
13
+ },
14
+ // size="sm"
15
+ contentAfter: !!value ? ((0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "transparent", size: "small", onClick: () => window.open(value, '_blank'), icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.OpenInNew, {}) })) : undefined }));
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/fluent",
3
- "version": "0.0.17-alpha.35",
3
+ "version": "0.0.17-alpha.38",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -48,5 +48,5 @@
48
48
  "uuid": "11.0.3",
49
49
  "yup": "^1.4.0"
50
50
  },
51
- "gitHead": "2250994fad501c28490b8167c7fca8141323e2b3"
51
+ "gitHead": "cf5abc4c56618fcc873bd31e3a26a84a9509edfa"
52
52
  }