@saasquatch/mint-components 2.4.1 → 2.4.2-2

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.
Files changed (51) hide show
  1. package/dist/cjs/{GenericTableView-be5648e4.js → GenericTableView-4c48c630.js} +46 -6
  2. package/dist/cjs/sqm-banking-info-form_10.cjs.entry.js +8 -3
  3. package/dist/cjs/sqm-referral-table_11.cjs.entry.js +8 -3
  4. package/dist/cjs/sqm-rewards-table_9.cjs.entry.js +8 -3
  5. package/dist/cjs/sqm-stencilbook.cjs.entry.js +1 -1
  6. package/dist/cjs/{useReferralTable-6e9de0d5.js → useReferralTable-06887d9a.js} +10 -0
  7. package/dist/collection/components/sqm-invoice-table/sqm-invoice-table.js +7 -1
  8. package/dist/collection/components/sqm-referral-table/sqm-referral-table.js +7 -1
  9. package/dist/collection/components/sqm-rewards-table/sqm-rewards-table.js +7 -1
  10. package/dist/collection/tables/GenericTableView.js +46 -6
  11. package/dist/collection/tables/plopTargets.js +8 -0
  12. package/dist/esm/{GenericTableView-8c72ac30.js → GenericTableView-471a9386.js} +46 -6
  13. package/dist/esm/sqm-banking-info-form_10.entry.js +8 -3
  14. package/dist/esm/sqm-referral-table_11.entry.js +8 -3
  15. package/dist/esm/sqm-rewards-table_9.entry.js +8 -3
  16. package/dist/esm/sqm-stencilbook.entry.js +1 -1
  17. package/dist/esm/{useReferralTable-03d32c6f.js → useReferralTable-3aa4b527.js} +10 -1
  18. package/dist/esm-es5/GenericTableView-471a9386.js +1 -0
  19. package/dist/esm-es5/sqm-banking-info-form_10.entry.js +1 -1
  20. package/dist/esm-es5/sqm-referral-table_11.entry.js +1 -1
  21. package/dist/esm-es5/sqm-rewards-table_9.entry.js +1 -1
  22. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  23. package/dist/esm-es5/useReferralTable-3aa4b527.js +1 -0
  24. package/dist/mint-components/mint-components.esm.js +1 -1
  25. package/dist/mint-components/p-1f48ffa2.system.entry.js +1 -0
  26. package/dist/mint-components/p-2972e950.system.entry.js +1 -0
  27. package/dist/mint-components/p-381af581.js +1 -0
  28. package/dist/mint-components/p-700d8950.system.js +1 -0
  29. package/dist/mint-components/p-83571aad.system.entry.js +1 -0
  30. package/dist/mint-components/{p-2e33148c.entry.js → p-8bdabf61.entry.js} +1 -1
  31. package/dist/mint-components/{p-bb0b5e4b.js → p-9944b514.js} +4 -4
  32. package/dist/mint-components/{p-2a2332a6.entry.js → p-9d671586.entry.js} +8 -8
  33. package/dist/mint-components/p-b69dbed8.system.js +1 -0
  34. package/dist/mint-components/p-bfb00685.system.js +1 -1
  35. package/dist/mint-components/p-cb3fbaff.entry.js +1 -0
  36. package/dist/mint-components/p-da357714.entry.js +148 -0
  37. package/dist/mint-components/{p-3784c92c.system.entry.js → p-ee6700a3.system.entry.js} +1 -1
  38. package/dist/types/tables/GenericTableView.d.ts +2 -0
  39. package/dist/types/tables/plopTargets.d.ts +3 -0
  40. package/docs/docs.docx +0 -0
  41. package/package.json +1 -1
  42. package/dist/esm-es5/GenericTableView-8c72ac30.js +0 -1
  43. package/dist/esm-es5/useReferralTable-03d32c6f.js +0 -1
  44. package/dist/mint-components/p-241e7226.system.entry.js +0 -1
  45. package/dist/mint-components/p-7c657e1f.entry.js +0 -1
  46. package/dist/mint-components/p-933bae53.system.entry.js +0 -1
  47. package/dist/mint-components/p-b1eb2a6a.js +0 -1
  48. package/dist/mint-components/p-d284ae70.system.js +0 -1
  49. package/dist/mint-components/p-d5eb601d.system.js +0 -1
  50. package/dist/mint-components/p-e2fb11af.entry.js +0 -148
  51. package/dist/mint-components/p-f7218609.system.entry.js +0 -1
@@ -9,6 +9,11 @@ function GenericTableView(props) {
9
9
  const { columns, rows } = elements;
10
10
  const { show } = states;
11
11
  const hiddenCols = data.hiddenColumns && data.hiddenColumns.split(",").map(Number);
12
+ // Only the producer knows which columns are plop targets; a column can render a
13
+ // VNode label and still be real data (e.g. the invoice download column).
14
+ const dropZones = new Set(elements.dropZoneColumns);
15
+ const hasDropZones = dropZones.size > 0;
16
+ const showLabels = data.textOverrides.showLabels;
12
17
  const mobile = "@media (max-width: " + data.mdBreakpoint + "px)";
13
18
  const tablet = `@media (min-width: ${Boolean(rows.length < 2) ? data.mdBreakpoint : data.smBreakpoint}px) and (max-width: ${data.mdBreakpoint}px)`;
14
19
  // Due to mobile media queries being dependant on props, not feasiable to move out of render function
@@ -29,6 +34,13 @@ function GenericTableView(props) {
29
34
  fontWeight: "var(--sl-font-weight-semibold)",
30
35
  overflowWrap: "anywhere",
31
36
  },
37
+ "& th.collapsed": {
38
+ fontSize: "0",
39
+ padding: "14px 0",
40
+ },
41
+ "& th.drop-zone": {
42
+ width: "30px",
43
+ },
32
44
  "& td": {
33
45
  padding: "var(--sl-spacing-small)",
34
46
  paddingLeft: "0",
@@ -36,10 +48,35 @@ function GenericTableView(props) {
36
48
  textOverflow: "ellipsis",
37
49
  },
38
50
  [mobile]: {
51
+ // Body rows become blocks here, so the header has to leave the table layout to stay full width
39
52
  "& thead": {
53
+ display: hasDropZones ? "block" : "none",
54
+ },
55
+ // Columns read top-to-bottom inside a card, so the drop zones between them stack the same way
56
+ "& thead tr": {
57
+ display: "flex",
58
+ flexDirection: "column",
59
+ },
60
+ "& thead th.label": {
61
+ padding: "0",
62
+ lineHeight: "20px",
63
+ fontSize: "var(--sl-font-size-small)",
64
+ color: "var(--sl-color-neutral-500)",
65
+ },
66
+ "& thead th.drop-zone": {
67
+ width: "auto",
68
+ padding: "14px 0",
69
+ lineHeight: "0",
70
+ position: "relative",
71
+ },
72
+ // The plop target is inline-styled position:absolute, so it needs the cell as its containing block to span it
73
+ "& thead th.drop-zone slot::slotted(raisins-plop-target)": {
74
+ width: "100%",
75
+ },
76
+ "& tbody td.drop-zone": {
40
77
  display: "none",
41
78
  },
42
- "& tr": {
79
+ "& tbody tr": {
43
80
  display: "block",
44
81
  background: "inherit",
45
82
  border: "var(--sqm-border-thickness, 1px) solid var(--sqm-border-color)",
@@ -96,11 +133,11 @@ function GenericTableView(props) {
96
133
  return (index.h("div", null,
97
134
  index.h("style", { type: "text/css" }, styleString),
98
135
  index.h("table", { class: sheet.classes.Table },
99
- data.textOverrides.showLabels && (index.h("thead", null,
100
- index.h("tr", null, columns === null || columns === void 0 ? void 0 : columns.map((column) => {
101
- if (typeof column === "string")
102
- return index.h("th", null, column);
103
- return index.h("th", { style: { width: "30px" } }, column);
136
+ (showLabels || hasDropZones) && (index.h("thead", null,
137
+ index.h("tr", null, columns === null || columns === void 0 ? void 0 : columns.map((column, i) => {
138
+ if (dropZones.has(i))
139
+ return index.h("th", { class: "drop-zone" }, column);
140
+ return (index.h("th", { class: showLabels ? "label" : "collapsed" }, column));
104
141
  })))),
105
142
  index.h("tbody", null,
106
143
  show === "loading" && elements.loadingElement,
@@ -108,6 +145,9 @@ function GenericTableView(props) {
108
145
  return (index.h("tr", { style: {
109
146
  borderTop: `${!data.textOverrides.showLabels && i === 0 ? "none" : ""}`,
110
147
  }, part: "table-row" }, row.map((cell, j) => {
148
+ if (dropZones.has(j))
149
+ return index.h("td", { class: "drop-zone" }, cell);
150
+ // Only string labels can be echoed into the mobile card's :before
111
151
  return typeof columns[j] === "string" ? (index.h("td", { class: (hiddenCols === null || hiddenCols === void 0 ? void 0 : hiddenCols.includes(j)) ? "hidden" : "", "data-label": columns[j] + ":", style: {
112
152
  gridTemplateColumns: (hiddenCols === null || hiddenCols === void 0 ? void 0 : hiddenCols.includes(j)) ? "1fr"
113
153
  : "0.5fr 0.5fr",
@@ -13,11 +13,11 @@ const JSS = require('./JSS-8503a151.js');
13
13
  require('./mixins-4761d472.js');
14
14
  require('./AsYouType-d15caac8.js');
15
15
  const subregions = require('./subregions-3d27e279.js');
16
- const GenericTableView = require('./GenericTableView-be5648e4.js');
16
+ const GenericTableView = require('./GenericTableView-4c48c630.js');
17
17
  const reRender = require('./re-render-72a0ef45.js');
18
+ const useReferralTable = require('./useReferralTable-06887d9a.js');
18
19
  const useChildElements = require('./useChildElements-041127d7.js');
19
20
  const luxon = require('./luxon-c1ad356a.js');
20
- const useReferralTable = require('./useReferralTable-6e9de0d5.js');
21
21
  const sqmUserInfoFormView = require('./sqm-user-info-form-view-c5f9b79b.js');
22
22
  const data = require('./data-89ac73dd.js');
23
23
  const keys = require('./keys-5a2c9ed2.js');
@@ -3436,7 +3436,12 @@ function useInvoiceTableDemo(props, emptyElement, loadingElement) {
3436
3436
  setContent({ rows });
3437
3437
  const columns = columnsPromise && (await Promise.all(columnsPromise));
3438
3438
  // Set the content to render and finish loading components
3439
- setContent({ columns, loading: false, page: 0 });
3439
+ setContent({
3440
+ columns,
3441
+ dropZoneColumns: useReferralTable.dropZoneColumnIndexes(columnComponents),
3442
+ loading: false,
3443
+ page: 0,
3444
+ });
3440
3445
  }
3441
3446
  domContextHooks_module.useEffect(() => {
3442
3447
  setContent({ loading: true });
@@ -11,12 +11,12 @@ const utils = require('./utils-6847bc06.js');
11
11
  const JSS = require('./JSS-8503a151.js');
12
12
  require('./mixins-4761d472.js');
13
13
  const sqmTextSpanView = require('./sqm-text-span-view-b9e10f5d.js');
14
- const GenericTableView = require('./GenericTableView-be5648e4.js');
14
+ const GenericTableView = require('./GenericTableView-4c48c630.js');
15
15
  const reRender = require('./re-render-72a0ef45.js');
16
+ const useReferralTable = require('./useReferralTable-06887d9a.js');
16
17
  const useChildElements = require('./useChildElements-041127d7.js');
17
18
  const luxon = require('./luxon-c1ad356a.js');
18
19
  const mockRewardData = require('./mockRewardData-ed603fca.js');
19
- const useReferralTable = require('./useReferralTable-6e9de0d5.js');
20
20
 
21
21
  const mockReferralData = (count = 4) => {
22
22
  const data = [...Array(count)].map(() => getMockData());
@@ -290,7 +290,12 @@ function useReferralTableDemo(props, emptyElement, loadingElement) {
290
290
  setContent({ rows });
291
291
  const columns = columnsPromise && (await Promise.all(columnsPromise));
292
292
  // Set the content to render and finish loading components
293
- setContent({ columns, loading: false, page: 0 });
293
+ setContent({
294
+ columns,
295
+ dropZoneColumns: useReferralTable.dropZoneColumnIndexes(columnComponents),
296
+ loading: false,
297
+ page: 0,
298
+ });
294
299
  }
295
300
  domContextHooks_module.useEffect(() => {
296
301
  setContent({ loading: true });
@@ -10,12 +10,12 @@ const cjs = require('./cjs-1066ec21.js');
10
10
  const utils = require('./utils-6847bc06.js');
11
11
  const JSS = require('./JSS-8503a151.js');
12
12
  require('./mixins-4761d472.js');
13
- const GenericTableView = require('./GenericTableView-be5648e4.js');
13
+ const GenericTableView = require('./GenericTableView-4c48c630.js');
14
14
  const reRender = require('./re-render-72a0ef45.js');
15
+ const useReferralTable = require('./useReferralTable-06887d9a.js');
15
16
  const useChildElements = require('./useChildElements-041127d7.js');
16
17
  const luxon = require('./luxon-c1ad356a.js');
17
18
  const mockRewardData = require('./mockRewardData-ed603fca.js');
18
- const useReferralTable = require('./useReferralTable-6e9de0d5.js');
19
19
 
20
20
  const debug = domContextHooks_module.browser("sq:useRewardsTable");
21
21
  const CSS_NAMESPACE = "sqm-rewards-table";
@@ -394,7 +394,12 @@ function useRewardsTableDemo(props, emptyElement, loadingElement) {
394
394
  setContent({ rows });
395
395
  const columns = columnsPromise && (await Promise.all(columnsPromise));
396
396
  // Set the content to render and finish loading components
397
- setContent({ columns, loading: false, page: 0 });
397
+ setContent({
398
+ columns,
399
+ dropZoneColumns: useReferralTable.dropZoneColumnIndexes(columnComponents),
400
+ loading: false,
401
+ page: 0,
402
+ });
398
403
  }
399
404
  domContextHooks_module.useEffect(() => {
400
405
  setContent({ loading: true });
@@ -17,7 +17,7 @@ const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-717d063
17
17
  require('./AsYouType-d15caac8.js');
18
18
  const subregions = require('./subregions-3d27e279.js');
19
19
  const sqmPortalRegistrationFormView = require('./sqm-portal-registration-form-view-a45f7a52.js');
20
- const GenericTableView = require('./GenericTableView-be5648e4.js');
20
+ const GenericTableView = require('./GenericTableView-4c48c630.js');
21
21
  require('./useChildElements-041127d7.js');
22
22
  const luxon = require('./luxon-c1ad356a.js');
23
23
  const sqmCloseButtonView = require('./sqm-close-button-view-e9f2a454.js');
@@ -6,6 +6,15 @@ const index_module = require('./index.module-f8c8495f.js');
6
6
  const reRender = require('./re-render-72a0ef45.js');
7
7
  const useChildElements = require('./useChildElements-041127d7.js');
8
8
 
9
+ const PLOP_TARGET_TAG = "RAISINS-PLOP-TARGET";
10
+ function isPlopTarget(element) {
11
+ return element.tagName === PLOP_TARGET_TAG;
12
+ }
13
+ /** Indexes of the column components the widget editor injected as drop zones. */
14
+ function dropZoneColumnIndexes(columnComponents) {
15
+ return columnComponents.reduce((indexes, component, idx) => isPlopTarget(component) ? [...indexes, idx] : indexes, []);
16
+ }
17
+
9
18
  const debug = domContextHooks_module.browser("sq:useReferralTable");
10
19
  const CSS_NAMESPACE = "sqm-referral-table";
11
20
  const GET_REFERRER_DATA = index_module.dist.gql `
@@ -427,6 +436,7 @@ async function tryMethod(c, callback) {
427
436
  }
428
437
  }
429
438
 
439
+ exports.dropZoneColumnIndexes = dropZoneColumnIndexes;
430
440
  exports.generateUserError = generateUserError;
431
441
  exports.tryMethod = tryMethod;
432
442
  exports.useReferralTable = useReferralTable;
@@ -5,6 +5,7 @@ import { Component, h, Prop } from "@stencil/core";
5
5
  import deepmerge from "deepmerge";
6
6
  import { GenericTableView, } from "../../tables/GenericTableView";
7
7
  import { useRequestRerender, useRerenderListener, } from "../../tables/re-render";
8
+ import { dropZoneColumnIndexes } from "../../tables/plopTargets";
8
9
  import { useChildElements } from "../../tables/useChildElements";
9
10
  import mockInvoiceData from "./mockInvoiceData";
10
11
  import { InvoiceTableView } from "./sqm-invoice-table-view";
@@ -422,7 +423,12 @@ function useInvoiceTableDemo(props, emptyElement, loadingElement) {
422
423
  setContent({ rows });
423
424
  const columns = columnsPromise && (await Promise.all(columnsPromise));
424
425
  // Set the content to render and finish loading components
425
- setContent({ columns, loading: false, page: 0 });
426
+ setContent({
427
+ columns,
428
+ dropZoneColumns: dropZoneColumnIndexes(columnComponents),
429
+ loading: false,
430
+ page: 0,
431
+ });
426
432
  }
427
433
  useEffect(() => {
428
434
  setContent({ loading: true });
@@ -5,6 +5,7 @@ import { Component, h, Prop } from "@stencil/core";
5
5
  import deepmerge from "deepmerge";
6
6
  import { GenericTableView, } from "../../tables/GenericTableView";
7
7
  import { useRequestRerender, useRerenderListener, } from "../../tables/re-render";
8
+ import { dropZoneColumnIndexes } from "../../tables/plopTargets";
8
9
  import { useChildElements } from "../../tables/useChildElements";
9
10
  import mockReferralData from "./mockReferralData";
10
11
  import { tryMethod, useReferralTable } from "./useReferralTable";
@@ -380,7 +381,12 @@ function useReferralTableDemo(props, emptyElement, loadingElement) {
380
381
  setContent({ rows });
381
382
  const columns = columnsPromise && (await Promise.all(columnsPromise));
382
383
  // Set the content to render and finish loading components
383
- setContent({ columns, loading: false, page: 0 });
384
+ setContent({
385
+ columns,
386
+ dropZoneColumns: dropZoneColumnIndexes(columnComponents),
387
+ loading: false,
388
+ page: 0,
389
+ });
384
390
  }
385
391
  useEffect(() => {
386
392
  setContent({ loading: true });
@@ -5,6 +5,7 @@ import { Component, h, Prop } from "@stencil/core";
5
5
  import deepmerge from "deepmerge";
6
6
  import { GenericTableView, } from "../../tables/GenericTableView";
7
7
  import { useRequestRerender, useRerenderListener, } from "../../tables/re-render";
8
+ import { dropZoneColumnIndexes } from "../../tables/plopTargets";
8
9
  import { useChildElements } from "../../tables/useChildElements";
9
10
  import mockRewardData from "./mockRewardData";
10
11
  import { tryMethod, useRewardsTable } from "./useRewardsTable";
@@ -325,7 +326,12 @@ function useRewardsTableDemo(props, emptyElement, loadingElement) {
325
326
  setContent({ rows });
326
327
  const columns = columnsPromise && (await Promise.all(columnsPromise));
327
328
  // Set the content to render and finish loading components
328
- setContent({ columns, loading: false, page: 0 });
329
+ setContent({
330
+ columns,
331
+ dropZoneColumns: dropZoneColumnIndexes(columnComponents),
332
+ loading: false,
333
+ page: 0,
334
+ });
329
335
  }
330
336
  useEffect(() => {
331
337
  setContent({ loading: true });
@@ -6,6 +6,11 @@ export function GenericTableView(props) {
6
6
  const { columns, rows } = elements;
7
7
  const { show } = states;
8
8
  const hiddenCols = data.hiddenColumns && data.hiddenColumns.split(",").map(Number);
9
+ // Only the producer knows which columns are plop targets; a column can render a
10
+ // VNode label and still be real data (e.g. the invoice download column).
11
+ const dropZones = new Set(elements.dropZoneColumns);
12
+ const hasDropZones = dropZones.size > 0;
13
+ const showLabels = data.textOverrides.showLabels;
9
14
  const mobile = "@media (max-width: " + data.mdBreakpoint + "px)";
10
15
  const tablet = `@media (min-width: ${Boolean(rows.length < 2) ? data.mdBreakpoint : data.smBreakpoint}px) and (max-width: ${data.mdBreakpoint}px)`;
11
16
  // Due to mobile media queries being dependant on props, not feasiable to move out of render function
@@ -26,6 +31,13 @@ export function GenericTableView(props) {
26
31
  fontWeight: "var(--sl-font-weight-semibold)",
27
32
  overflowWrap: "anywhere",
28
33
  },
34
+ "& th.collapsed": {
35
+ fontSize: "0",
36
+ padding: "14px 0",
37
+ },
38
+ "& th.drop-zone": {
39
+ width: "30px",
40
+ },
29
41
  "& td": {
30
42
  padding: "var(--sl-spacing-small)",
31
43
  paddingLeft: "0",
@@ -33,10 +45,35 @@ export function GenericTableView(props) {
33
45
  textOverflow: "ellipsis",
34
46
  },
35
47
  [mobile]: {
48
+ // Body rows become blocks here, so the header has to leave the table layout to stay full width
36
49
  "& thead": {
50
+ display: hasDropZones ? "block" : "none",
51
+ },
52
+ // Columns read top-to-bottom inside a card, so the drop zones between them stack the same way
53
+ "& thead tr": {
54
+ display: "flex",
55
+ flexDirection: "column",
56
+ },
57
+ "& thead th.label": {
58
+ padding: "0",
59
+ lineHeight: "20px",
60
+ fontSize: "var(--sl-font-size-small)",
61
+ color: "var(--sl-color-neutral-500)",
62
+ },
63
+ "& thead th.drop-zone": {
64
+ width: "auto",
65
+ padding: "14px 0",
66
+ lineHeight: "0",
67
+ position: "relative",
68
+ },
69
+ // The plop target is inline-styled position:absolute, so it needs the cell as its containing block to span it
70
+ "& thead th.drop-zone slot::slotted(raisins-plop-target)": {
71
+ width: "100%",
72
+ },
73
+ "& tbody td.drop-zone": {
37
74
  display: "none",
38
75
  },
39
- "& tr": {
76
+ "& tbody tr": {
40
77
  display: "block",
41
78
  background: "inherit",
42
79
  border: "var(--sqm-border-thickness, 1px) solid var(--sqm-border-color)",
@@ -93,11 +130,11 @@ export function GenericTableView(props) {
93
130
  return (h("div", null,
94
131
  h("style", { type: "text/css" }, styleString),
95
132
  h("table", { class: sheet.classes.Table },
96
- data.textOverrides.showLabels && (h("thead", null,
97
- h("tr", null, columns === null || columns === void 0 ? void 0 : columns.map((column) => {
98
- if (typeof column === "string")
99
- return h("th", null, column);
100
- return h("th", { style: { width: "30px" } }, column);
133
+ (showLabels || hasDropZones) && (h("thead", null,
134
+ h("tr", null, columns === null || columns === void 0 ? void 0 : columns.map((column, i) => {
135
+ if (dropZones.has(i))
136
+ return h("th", { class: "drop-zone" }, column);
137
+ return (h("th", { class: showLabels ? "label" : "collapsed" }, column));
101
138
  })))),
102
139
  h("tbody", null,
103
140
  show === "loading" && elements.loadingElement,
@@ -105,6 +142,9 @@ export function GenericTableView(props) {
105
142
  return (h("tr", { style: {
106
143
  borderTop: `${!data.textOverrides.showLabels && i === 0 ? "none" : ""}`,
107
144
  }, part: "table-row" }, row.map((cell, j) => {
145
+ if (dropZones.has(j))
146
+ return h("td", { class: "drop-zone" }, cell);
147
+ // Only string labels can be echoed into the mobile card's :before
108
148
  return typeof columns[j] === "string" ? (h("td", { class: (hiddenCols === null || hiddenCols === void 0 ? void 0 : hiddenCols.includes(j)) ? "hidden" : "", "data-label": columns[j] + ":", style: {
109
149
  gridTemplateColumns: (hiddenCols === null || hiddenCols === void 0 ? void 0 : hiddenCols.includes(j)) ? "1fr"
110
150
  : "0.5fr 0.5fr",
@@ -0,0 +1,8 @@
1
+ const PLOP_TARGET_TAG = "RAISINS-PLOP-TARGET";
2
+ export function isPlopTarget(element) {
3
+ return element.tagName === PLOP_TARGET_TAG;
4
+ }
5
+ /** Indexes of the column components the widget editor injected as drop zones. */
6
+ export function dropZoneColumnIndexes(columnComponents) {
7
+ return columnComponents.reduce((indexes, component, idx) => isPlopTarget(component) ? [...indexes, idx] : indexes, []);
8
+ }
@@ -7,6 +7,11 @@ function GenericTableView(props) {
7
7
  const { columns, rows } = elements;
8
8
  const { show } = states;
9
9
  const hiddenCols = data.hiddenColumns && data.hiddenColumns.split(",").map(Number);
10
+ // Only the producer knows which columns are plop targets; a column can render a
11
+ // VNode label and still be real data (e.g. the invoice download column).
12
+ const dropZones = new Set(elements.dropZoneColumns);
13
+ const hasDropZones = dropZones.size > 0;
14
+ const showLabels = data.textOverrides.showLabels;
10
15
  const mobile = "@media (max-width: " + data.mdBreakpoint + "px)";
11
16
  const tablet = `@media (min-width: ${Boolean(rows.length < 2) ? data.mdBreakpoint : data.smBreakpoint}px) and (max-width: ${data.mdBreakpoint}px)`;
12
17
  // Due to mobile media queries being dependant on props, not feasiable to move out of render function
@@ -27,6 +32,13 @@ function GenericTableView(props) {
27
32
  fontWeight: "var(--sl-font-weight-semibold)",
28
33
  overflowWrap: "anywhere",
29
34
  },
35
+ "& th.collapsed": {
36
+ fontSize: "0",
37
+ padding: "14px 0",
38
+ },
39
+ "& th.drop-zone": {
40
+ width: "30px",
41
+ },
30
42
  "& td": {
31
43
  padding: "var(--sl-spacing-small)",
32
44
  paddingLeft: "0",
@@ -34,10 +46,35 @@ function GenericTableView(props) {
34
46
  textOverflow: "ellipsis",
35
47
  },
36
48
  [mobile]: {
49
+ // Body rows become blocks here, so the header has to leave the table layout to stay full width
37
50
  "& thead": {
51
+ display: hasDropZones ? "block" : "none",
52
+ },
53
+ // Columns read top-to-bottom inside a card, so the drop zones between them stack the same way
54
+ "& thead tr": {
55
+ display: "flex",
56
+ flexDirection: "column",
57
+ },
58
+ "& thead th.label": {
59
+ padding: "0",
60
+ lineHeight: "20px",
61
+ fontSize: "var(--sl-font-size-small)",
62
+ color: "var(--sl-color-neutral-500)",
63
+ },
64
+ "& thead th.drop-zone": {
65
+ width: "auto",
66
+ padding: "14px 0",
67
+ lineHeight: "0",
68
+ position: "relative",
69
+ },
70
+ // The plop target is inline-styled position:absolute, so it needs the cell as its containing block to span it
71
+ "& thead th.drop-zone slot::slotted(raisins-plop-target)": {
72
+ width: "100%",
73
+ },
74
+ "& tbody td.drop-zone": {
38
75
  display: "none",
39
76
  },
40
- "& tr": {
77
+ "& tbody tr": {
41
78
  display: "block",
42
79
  background: "inherit",
43
80
  border: "var(--sqm-border-thickness, 1px) solid var(--sqm-border-color)",
@@ -94,11 +131,11 @@ function GenericTableView(props) {
94
131
  return (h("div", null,
95
132
  h("style", { type: "text/css" }, styleString),
96
133
  h("table", { class: sheet.classes.Table },
97
- data.textOverrides.showLabels && (h("thead", null,
98
- h("tr", null, columns === null || columns === void 0 ? void 0 : columns.map((column) => {
99
- if (typeof column === "string")
100
- return h("th", null, column);
101
- return h("th", { style: { width: "30px" } }, column);
134
+ (showLabels || hasDropZones) && (h("thead", null,
135
+ h("tr", null, columns === null || columns === void 0 ? void 0 : columns.map((column, i) => {
136
+ if (dropZones.has(i))
137
+ return h("th", { class: "drop-zone" }, column);
138
+ return (h("th", { class: showLabels ? "label" : "collapsed" }, column));
102
139
  })))),
103
140
  h("tbody", null,
104
141
  show === "loading" && elements.loadingElement,
@@ -106,6 +143,9 @@ function GenericTableView(props) {
106
143
  return (h("tr", { style: {
107
144
  borderTop: `${!data.textOverrides.showLabels && i === 0 ? "none" : ""}`,
108
145
  }, part: "table-row" }, row.map((cell, j) => {
146
+ if (dropZones.has(j))
147
+ return h("td", { class: "drop-zone" }, cell);
148
+ // Only string labels can be echoed into the mobile card's :before
109
149
  return typeof columns[j] === "string" ? (h("td", { class: (hiddenCols === null || hiddenCols === void 0 ? void 0 : hiddenCols.includes(j)) ? "hidden" : "", "data-label": columns[j] + ":", style: {
110
150
  gridTemplateColumns: (hiddenCols === null || hiddenCols === void 0 ? void 0 : hiddenCols.includes(j)) ? "1fr"
111
151
  : "0.5fr 0.5fr",
@@ -9,11 +9,11 @@ import { c as createStyleSheet } from './JSS-67b5cff8.js';
9
9
  import './mixins-f750863a.js';
10
10
  import './AsYouType-2d56519e.js';
11
11
  import { t as taxTypeToName, b as validTaxDocument, I as INDIRECT_TAX_SPAIN_REGIONS, a as INDIRECT_TAX_PROVINCES, o as objectIsFull, c as toDomesticNumber, A as ADDRESS_REGIONS } from './subregions-810a5c2d.js';
12
- import { G as GenericTableView } from './GenericTableView-8c72ac30.js';
12
+ import { G as GenericTableView } from './GenericTableView-471a9386.js';
13
13
  import { u as useRerenderListener, a as useRequestRerender } from './re-render-bf46ba54.js';
14
+ import { g as generateUserError, d as dropZoneColumnIndexes } from './useReferralTable-3aa4b527.js';
14
15
  import { u as useChildElements } from './useChildElements-06937df7.js';
15
16
  import { l as luxon } from './luxon-1be92a8e.js';
16
- import { g as generateUserError } from './useReferralTable-03d32c6f.js';
17
17
  import { O as OtherRegionSlotView, I as InvoiceTableView, v as vatLabels, T as TaxAndCashDashboardView, U as UserInfoFormView } from './sqm-user-info-form-view-ceb3917a.js';
18
18
  import { F as FORM_STEPS, a as TAX_FORM_CONTEXT_NAMESPACE, S as SORTED_COUNTRIES_NAMESPACE, f as FINANCE_NETWORK_SETTINGS_NAMESPACE, c as USER_QUERY_NAMESPACE, T as TAX_CONTEXT_NAMESPACE, C as CURRENCIES_NAMESPACE, U as USER_FORM_CONTEXT_NAMESPACE } from './data-8698cbc6.js';
19
19
  import { c as VERIFICATION_EVENT_KEY } from './keys-1054056a.js';
@@ -3432,7 +3432,12 @@ function useInvoiceTableDemo(props, emptyElement, loadingElement) {
3432
3432
  setContent({ rows });
3433
3433
  const columns = columnsPromise && (await Promise.all(columnsPromise));
3434
3434
  // Set the content to render and finish loading components
3435
- setContent({ columns, loading: false, page: 0 });
3435
+ setContent({
3436
+ columns,
3437
+ dropZoneColumns: dropZoneColumnIndexes(columnComponents),
3438
+ loading: false,
3439
+ page: 0,
3440
+ });
3436
3441
  }
3437
3442
  useEffect(() => {
3438
3443
  setContent({ loading: true });
@@ -7,12 +7,12 @@ import { l as luxonLocale } from './utils-334c1e34.js';
7
7
  import { c as createStyleSheet } from './JSS-67b5cff8.js';
8
8
  import './mixins-f750863a.js';
9
9
  import { T as TextSpanView } from './sqm-text-span-view-72f43dff.js';
10
- import { G as GenericTableView } from './GenericTableView-8c72ac30.js';
10
+ import { G as GenericTableView } from './GenericTableView-471a9386.js';
11
11
  import { a as useRequestRerender, u as useRerenderListener } from './re-render-bf46ba54.js';
12
+ import { u as useReferralTable, t as tryMethod, d as dropZoneColumnIndexes } from './useReferralTable-3aa4b527.js';
12
13
  import { u as useChildElements } from './useChildElements-06937df7.js';
13
14
  import { l as luxon } from './luxon-1be92a8e.js';
14
15
  import { g as getPaypalMeta } from './mockRewardData-9b27d6f1.js';
15
- import { u as useReferralTable, t as tryMethod } from './useReferralTable-03d32c6f.js';
16
16
 
17
17
  const mockReferralData = (count = 4) => {
18
18
  const data = [...Array(count)].map(() => getMockData());
@@ -286,7 +286,12 @@ function useReferralTableDemo(props, emptyElement, loadingElement) {
286
286
  setContent({ rows });
287
287
  const columns = columnsPromise && (await Promise.all(columnsPromise));
288
288
  // Set the content to render and finish loading components
289
- setContent({ columns, loading: false, page: 0 });
289
+ setContent({
290
+ columns,
291
+ dropZoneColumns: dropZoneColumnIndexes(columnComponents),
292
+ loading: false,
293
+ page: 0,
294
+ });
290
295
  }
291
296
  useEffect(() => {
292
297
  setContent({ loading: true });
@@ -6,12 +6,12 @@ import { c as cjs } from './cjs-bdfb4486.js';
6
6
  import { l as luxonLocale } from './utils-334c1e34.js';
7
7
  import { c as createStyleSheet } from './JSS-67b5cff8.js';
8
8
  import './mixins-f750863a.js';
9
- import { G as GenericTableView } from './GenericTableView-8c72ac30.js';
9
+ import { G as GenericTableView } from './GenericTableView-471a9386.js';
10
10
  import { u as useRerenderListener, a as useRequestRerender } from './re-render-bf46ba54.js';
11
+ import { g as generateUserError, d as dropZoneColumnIndexes } from './useReferralTable-3aa4b527.js';
11
12
  import { u as useChildElements } from './useChildElements-06937df7.js';
12
13
  import { l as luxon } from './luxon-1be92a8e.js';
13
14
  import { m as mockRewardData } from './mockRewardData-9b27d6f1.js';
14
- import { g as generateUserError } from './useReferralTable-03d32c6f.js';
15
15
 
16
16
  const debug = browser("sq:useRewardsTable");
17
17
  const CSS_NAMESPACE = "sqm-rewards-table";
@@ -390,7 +390,12 @@ function useRewardsTableDemo(props, emptyElement, loadingElement) {
390
390
  setContent({ rows });
391
391
  const columns = columnsPromise && (await Promise.all(columnsPromise));
392
392
  // Set the content to render and finish loading components
393
- setContent({ columns, loading: false, page: 0 });
393
+ setContent({
394
+ columns,
395
+ dropZoneColumns: dropZoneColumnIndexes(columnComponents),
396
+ loading: false,
397
+ page: 0,
398
+ });
394
399
  }
395
400
  useEffect(() => {
396
401
  setContent({ loading: true });
@@ -13,7 +13,7 @@ import { b as PortalRegisterView, P as PortalForgotPasswordView, a as PortalLogi
13
13
  import './AsYouType-2d56519e.js';
14
14
  import { t as taxTypeToName, L as LoadingView, I as INDIRECT_TAX_SPAIN_REGIONS, a as INDIRECT_TAX_PROVINCES } from './subregions-810a5c2d.js';
15
15
  import { P as PortalRegistrationFormView } from './sqm-portal-registration-form-view-79265df5.js';
16
- import { G as GenericTableView } from './GenericTableView-8c72ac30.js';
16
+ import { G as GenericTableView } from './GenericTableView-471a9386.js';
17
17
  import './useChildElements-06937df7.js';
18
18
  import { l as luxon } from './luxon-1be92a8e.js';
19
19
  import { C as CloseButtonView } from './sqm-close-button-view-fd9012e7.js';
@@ -4,6 +4,15 @@ import { d as dist, J, H, L, w as wn, R as Rn } from './index.module-02cb914c.js
4
4
  import { u as useRerenderListener } from './re-render-bf46ba54.js';
5
5
  import { u as useChildElements } from './useChildElements-06937df7.js';
6
6
 
7
+ const PLOP_TARGET_TAG = "RAISINS-PLOP-TARGET";
8
+ function isPlopTarget(element) {
9
+ return element.tagName === PLOP_TARGET_TAG;
10
+ }
11
+ /** Indexes of the column components the widget editor injected as drop zones. */
12
+ function dropZoneColumnIndexes(columnComponents) {
13
+ return columnComponents.reduce((indexes, component, idx) => isPlopTarget(component) ? [...indexes, idx] : indexes, []);
14
+ }
15
+
7
16
  const debug = browser("sq:useReferralTable");
8
17
  const CSS_NAMESPACE = "sqm-referral-table";
9
18
  const GET_REFERRER_DATA = dist.gql `
@@ -425,4 +434,4 @@ async function tryMethod(c, callback) {
425
434
  }
426
435
  }
427
436
 
428
- export { generateUserError as g, tryMethod as t, useReferralTable as u };
437
+ export { dropZoneColumnIndexes as d, generateUserError as g, tryMethod as t, useReferralTable as u };
@@ -0,0 +1 @@
1
+ var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var a,t=1,r=arguments.length;t<r;t++){a=arguments[t];for(var s in a)if(Object.prototype.hasOwnProperty.call(a,s))e[s]=a[s]}return e};return __assign.apply(this,arguments)};import{h}from"./index-38ad4957.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import{g as gap}from"./mixins-f750863a.js";function GenericTableView(e){var a;var t=e.states,r=e.data,s=e.callbacks,o=e.elements;var l=o.columns,i=o.rows;var n=t.show;var d=r.hiddenColumns&&r.hiddenColumns.split(",").map(Number);var p=new Set(o.dropZoneColumns);var c=p.size>0;var m=r.textOverrides.showLabels;var b="@media (max-width: "+r.mdBreakpoint+"px)";var g="@media (min-width: "+(Boolean(i.length<2)?r.mdBreakpoint:r.smBreakpoint)+"px) and (max-width: "+r.mdBreakpoint+"px)";var v={Table:(a={borderCollapse:"collapse",tableLayout:"fixed",width:"100%","& tbody tr":{borderBottom:"var(--sqm-border-thickness, 1px) solid var(--sqm-border-color)","&:first-child":{borderTop:"var(--sqm-border-thickness, 1px) solid var(--sqm-border-color)"}},"& th":{paddingBottom:"var(--sl-spacing-small)",textAlign:"left",fontWeight:"var(--sl-font-weight-semibold)",overflowWrap:"anywhere"},"& th.collapsed":{fontSize:"0",padding:"14px 0"},"& th.drop-zone":{width:"30px"},"& td":{padding:"var(--sl-spacing-small)",paddingLeft:"0",overflow:"hidden",textOverflow:"ellipsis"}},a[b]={"& thead":{display:c?"block":"none"},"& thead tr":{display:"flex",flexDirection:"column"},"& thead th.label":{padding:"0",lineHeight:"20px",fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)"},"& thead th.drop-zone":{width:"auto",padding:"14px 0",lineHeight:"0",position:"relative"},"& thead th.drop-zone slot::slotted(raisins-plop-target)":{width:"100%"},"& tbody td.drop-zone":{display:"none"},"& tbody tr":{display:"block",background:"inherit",border:"var(--sqm-border-thickness, 1px) solid var(--sqm-border-color)",boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.1)",borderRadius:"var(--sl-border-radius-large)",padding:"var(--sl-spacing-medium)",fontSize:"var(--sl-font-size-small)",marginBottom:"var(--sl-spacing-large)"},"& td":{display:"grid",borderTop:"none",padding:"0",marginBottom:"var(--sl-spacing-medium)","&:first-child":{textAlign:"left"},"&:before":{content:"attr(data-label)",whiteSpace:"nowrap"},"&:last-child":{marginBottom:"0"},"&.hidden:before":{content:"none"}}},a[g]={"& tbody":{display:"grid",gridTemplateColumns:"0.5fr 0.5fr",gap:"25px"}},a),ButtonContainer:__assign({display:"flex","justify-content":"flex-end","margin-top":"var(--sl-spacing-small)"},gap({direction:"row",size:"var(--sl-spacing-small)"})),ButtonDisabled:{"&::part(base)":{opacity:"0.25"}}};var u=createStyleSheet(v);var f=u.toString();if(n==="empty")return o.emptyElement;return h("div",null,h("style",{type:"text/css"},f),h("table",{class:u.classes.Table},(m||c)&&h("thead",null,h("tr",null,l===null||l===void 0?void 0:l.map((function(e,a){if(p.has(a))return h("th",{class:"drop-zone"},e);return h("th",{class:m?"label":"collapsed"},e)})))),h("tbody",null,n==="loading"&&o.loadingElement,n==="rows"&&(i===null||i===void 0?void 0:i.map((function(e,a){return h("tr",{style:{borderTop:""+(!r.textOverrides.showLabels&&a===0?"none":"")},part:"table-row"},e.map((function(e,a){if(p.has(a))return h("td",{class:"drop-zone"},e);return typeof l[a]==="string"?h("td",{class:(d===null||d===void 0?void 0:d.includes(a))?"hidden":"","data-label":l[a]+":",style:{gridTemplateColumns:(d===null||d===void 0?void 0:d.includes(a))?"1fr":"0.5fr 0.5fr"}},e):h("td",null,e)})))}))))),h("div",{class:u.classes.ButtonContainer,part:t.namespace+"-button-wrapper"},h("sl-button",{size:"small",disabled:!t.hasPrev,loading:n==="loading",onClick:s.prevPage,exportparts:"base: secondarybutton-base",class:!t.hasPrev?u.classes.ButtonDisabled:""},r.textOverrides.prevLabel),h("sl-button",{size:"small",loading:n==="loading",disabled:!t.hasNext,onClick:s.nextPage,exportparts:"base: secondarybutton-base",class:!t.hasNext?u.classes.ButtonDisabled:""},r.textOverrides.moreLabel)))}export{GenericTableView as G};