igniteui-webcomponents 7.3.0 → 7.3.1

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 (149) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +30 -0
  3. package/components/avatar/avatar.d.ts +1 -2
  4. package/components/avatar/avatar.js +4 -8
  5. package/components/avatar/avatar.js.map +1 -1
  6. package/components/badge/badge.d.ts +6 -1
  7. package/components/badge/badge.js +8 -5
  8. package/components/badge/badge.js.map +1 -1
  9. package/components/badge/themes/badge.base.css.js +1 -1
  10. package/components/badge/themes/badge.base.css.js.map +1 -1
  11. package/components/chip/chip.d.ts +30 -14
  12. package/components/chip/chip.js +54 -48
  13. package/components/chip/chip.js.map +1 -1
  14. package/components/chip/themes/chip.base.css.js +1 -1
  15. package/components/chip/themes/chip.base.css.js.map +1 -1
  16. package/components/chip/themes/dark/chip.bootstrap.css.js +1 -1
  17. package/components/chip/themes/dark/chip.bootstrap.css.js.map +1 -1
  18. package/components/chip/themes/dark/chip.fluent.css.js +1 -1
  19. package/components/chip/themes/dark/chip.fluent.css.js.map +1 -1
  20. package/components/chip/themes/dark/chip.indigo.css.js +1 -1
  21. package/components/chip/themes/dark/chip.indigo.css.js.map +1 -1
  22. package/components/chip/themes/dark/chip.material.css.js +1 -1
  23. package/components/chip/themes/dark/chip.material.css.js.map +1 -1
  24. package/components/chip/themes/light/chip.bootstrap.css.js +1 -1
  25. package/components/chip/themes/light/chip.bootstrap.css.js.map +1 -1
  26. package/components/chip/themes/light/chip.fluent.css.js +1 -1
  27. package/components/chip/themes/light/chip.fluent.css.js.map +1 -1
  28. package/components/chip/themes/light/chip.indigo.css.js +1 -1
  29. package/components/chip/themes/light/chip.indigo.css.js.map +1 -1
  30. package/components/chip/themes/light/chip.material.css.js +1 -1
  31. package/components/chip/themes/light/chip.material.css.js.map +1 -1
  32. package/components/chip/themes/shared/chip.bootstrap.css.js +1 -1
  33. package/components/chip/themes/shared/chip.bootstrap.css.js.map +1 -1
  34. package/components/chip/themes/shared/chip.common.css.js +1 -1
  35. package/components/chip/themes/shared/chip.common.css.js.map +1 -1
  36. package/components/chip/themes/shared/chip.fluent.css.js +1 -1
  37. package/components/chip/themes/shared/chip.fluent.css.js.map +1 -1
  38. package/components/chip/themes/shared/chip.indigo.css.js +1 -1
  39. package/components/chip/themes/shared/chip.indigo.css.js.map +1 -1
  40. package/components/color-picker/color-picker.d.ts +2 -2
  41. package/components/color-picker/color-picker.js.map +1 -1
  42. package/components/color-picker/picker-canvas.js +2 -1
  43. package/components/color-picker/picker-canvas.js.map +1 -1
  44. package/components/textarea/textarea.d.ts +2 -15
  45. package/components/textarea/textarea.js +48 -93
  46. package/components/textarea/textarea.js.map +1 -1
  47. package/components/tile-manager/position.d.ts +2 -9
  48. package/components/tile-manager/position.js +27 -42
  49. package/components/tile-manager/position.js.map +1 -1
  50. package/components/tile-manager/resize-state.d.ts +11 -22
  51. package/components/tile-manager/resize-state.js +60 -119
  52. package/components/tile-manager/resize-state.js.map +1 -1
  53. package/components/tile-manager/resize-util.d.ts +3 -7
  54. package/components/tile-manager/resize-util.js +65 -72
  55. package/components/tile-manager/resize-util.js.map +1 -1
  56. package/components/tile-manager/serializer.d.ts +1 -1
  57. package/components/tile-manager/serializer.js +9 -10
  58. package/components/tile-manager/serializer.js.map +1 -1
  59. package/components/tile-manager/themes/shared/tile/tile.common.css.js +1 -1
  60. package/components/tile-manager/themes/shared/tile/tile.common.css.js.map +1 -1
  61. package/components/tile-manager/themes/tile.base.css.js +1 -1
  62. package/components/tile-manager/themes/tile.base.css.js.map +1 -1
  63. package/components/tile-manager/tile-ghost-util.js +16 -20
  64. package/components/tile-manager/tile-ghost-util.js.map +1 -1
  65. package/components/tile-manager/tile-manager.d.ts +5 -2
  66. package/components/tile-manager/tile-manager.js +27 -23
  67. package/components/tile-manager/tile-manager.js.map +1 -1
  68. package/components/tile-manager/tile.d.ts +32 -18
  69. package/components/tile-manager/tile.js +181 -161
  70. package/components/tile-manager/tile.js.map +1 -1
  71. package/components/tile-manager/types.d.ts +1 -5
  72. package/components/tile-manager/types.js.map +1 -1
  73. package/custom-elements.json +498 -853
  74. package/igniteui-webcomponents.css-data.json +1 -1
  75. package/igniteui-webcomponents.html-data.json +1 -1
  76. package/index.d.ts +1 -0
  77. package/index.js.map +1 -1
  78. package/internals/directives/drag.d.ts +144 -0
  79. package/internals/directives/drag.js +278 -0
  80. package/internals/directives/drag.js.map +1 -0
  81. package/internals/directives/resize.d.ts +109 -0
  82. package/internals/directives/resize.js +214 -0
  83. package/internals/directives/resize.js.map +1 -0
  84. package/internals/templates/input-shell.d.ts +12 -1
  85. package/internals/templates/input-shell.js +17 -10
  86. package/internals/templates/input-shell.js.map +1 -1
  87. package/internals/utils/dom.d.ts +2 -0
  88. package/internals/utils/dom.js +3 -0
  89. package/internals/utils/dom.js.map +1 -1
  90. package/internals/utils/events.d.ts +2 -0
  91. package/internals/utils/events.js +3 -0
  92. package/internals/utils/events.js.map +1 -1
  93. package/package.json +1 -1
  94. package/skills/README.md +1 -0
  95. package/web-types.json +2 -2
  96. package/components/resize-container/default-ghost.d.ts +0 -5
  97. package/components/resize-container/default-ghost.js +0 -20
  98. package/components/resize-container/default-ghost.js.map +0 -1
  99. package/components/resize-container/resize-container.d.ts +0 -60
  100. package/components/resize-container/resize-container.js +0 -156
  101. package/components/resize-container/resize-container.js.map +0 -1
  102. package/components/resize-container/resize-controller.d.ts +0 -46
  103. package/components/resize-container/resize-controller.js +0 -195
  104. package/components/resize-container/resize-controller.js.map +0 -1
  105. package/components/resize-container/themes/dark/resize-indicator.bootstrap.css.d.ts +0 -1
  106. package/components/resize-container/themes/dark/resize-indicator.bootstrap.css.js +0 -3
  107. package/components/resize-container/themes/dark/resize-indicator.bootstrap.css.js.map +0 -1
  108. package/components/resize-container/themes/dark/resize-indicator.fluent.css.d.ts +0 -1
  109. package/components/resize-container/themes/dark/resize-indicator.fluent.css.js +0 -3
  110. package/components/resize-container/themes/dark/resize-indicator.fluent.css.js.map +0 -1
  111. package/components/resize-container/themes/dark/resize-indicator.indigo.css.d.ts +0 -1
  112. package/components/resize-container/themes/dark/resize-indicator.indigo.css.js +0 -3
  113. package/components/resize-container/themes/dark/resize-indicator.indigo.css.js.map +0 -1
  114. package/components/resize-container/themes/dark/resize-indicator.material.css.d.ts +0 -1
  115. package/components/resize-container/themes/dark/resize-indicator.material.css.js +0 -3
  116. package/components/resize-container/themes/dark/resize-indicator.material.css.js.map +0 -1
  117. package/components/resize-container/themes/dark/resize-indicator.shared.css.d.ts +0 -1
  118. package/components/resize-container/themes/dark/resize-indicator.shared.css.js +0 -3
  119. package/components/resize-container/themes/dark/resize-indicator.shared.css.js.map +0 -1
  120. package/components/resize-container/themes/light/resize-indicator.bootstrap.css.d.ts +0 -1
  121. package/components/resize-container/themes/light/resize-indicator.bootstrap.css.js +0 -3
  122. package/components/resize-container/themes/light/resize-indicator.bootstrap.css.js.map +0 -1
  123. package/components/resize-container/themes/light/resize-indicator.fluent.css.d.ts +0 -1
  124. package/components/resize-container/themes/light/resize-indicator.fluent.css.js +0 -3
  125. package/components/resize-container/themes/light/resize-indicator.fluent.css.js.map +0 -1
  126. package/components/resize-container/themes/light/resize-indicator.indigo.css.d.ts +0 -1
  127. package/components/resize-container/themes/light/resize-indicator.indigo.css.js +0 -3
  128. package/components/resize-container/themes/light/resize-indicator.indigo.css.js.map +0 -1
  129. package/components/resize-container/themes/light/resize-indicator.material.css.d.ts +0 -1
  130. package/components/resize-container/themes/light/resize-indicator.material.css.js +0 -3
  131. package/components/resize-container/themes/light/resize-indicator.material.css.js.map +0 -1
  132. package/components/resize-container/themes/light/resize-indicator.shared.css.d.ts +0 -1
  133. package/components/resize-container/themes/light/resize-indicator.shared.css.js +0 -3
  134. package/components/resize-container/themes/light/resize-indicator.shared.css.js.map +0 -1
  135. package/components/resize-container/themes/resize-container.base.css.d.ts +0 -1
  136. package/components/resize-container/themes/resize-container.base.css.js +0 -3
  137. package/components/resize-container/themes/resize-container.base.css.js.map +0 -1
  138. package/components/resize-container/themes/shared/resize-container.common.css.d.ts +0 -1
  139. package/components/resize-container/themes/shared/resize-container.common.css.js +0 -3
  140. package/components/resize-container/themes/shared/resize-container.common.css.js.map +0 -1
  141. package/components/resize-container/themes/themes.d.ts +0 -2
  142. package/components/resize-container/themes/themes.js +0 -47
  143. package/components/resize-container/themes/themes.js.map +0 -1
  144. package/components/resize-container/types.d.ts +0 -40
  145. package/components/resize-container/types.js +0 -2
  146. package/components/resize-container/types.js.map +0 -1
  147. package/internals/controllers/drag.d.ts +0 -166
  148. package/internals/controllers/drag.js +0 -283
  149. package/internals/controllers/drag.js.map +0 -1
@@ -1,7 +1,10 @@
1
1
  import { firstOf } from '#internals/utils/arrays.js';
2
2
  import { asNumber } from '#internals/utils/math.js';
3
- import { ResizeUtil } from './resize-util.js';
3
+ import { calculatePosition, calculateResizedSpan, calculateSnappedDimension, } from './resize-util.js';
4
4
  const CssValues = /(?<start>\d+)?\s*\/?\s*span\s*(?<span>\d+)?/gi;
5
+ function createAxisState(dimension = { entries: [], minSize: 0 }) {
6
+ return { dimension, prevDelta: 0, prevSnapped: 0 };
7
+ }
5
8
  function parseTileGridRect(tile) {
6
9
  const computed = getComputedStyle(tile);
7
10
  const { gridColumn, gridRow } = computed;
@@ -20,18 +23,14 @@ function parseTileGridRect(tile) {
20
23
  function parseTileParentGrid(gridContainer) {
21
24
  const computed = getComputedStyle(gridContainer);
22
25
  const { gap, gridTemplateColumns, gridTemplateRows } = computed;
23
- const columns = gridTemplateColumns.split(' ').map(asNumber);
24
- const rows = gridTemplateRows.split(' ').map(asNumber);
25
26
  return {
26
27
  gap: asNumber(gap),
27
28
  columns: {
28
- count: columns.length,
29
- entries: columns,
29
+ entries: gridTemplateColumns.split(' ').map(asNumber),
30
30
  minSize: asNumber(computed.getPropertyValue('--min-col-width')),
31
31
  },
32
32
  rows: {
33
- count: rows.length,
34
- entries: rows,
33
+ entries: gridTemplateRows.split(' ').map(asNumber),
35
34
  minSize: asNumber(computed.getPropertyValue('--min-row-height')),
36
35
  },
37
36
  };
@@ -39,138 +38,80 @@ function parseTileParentGrid(gridContainer) {
39
38
  class TileResizeState {
40
39
  constructor() {
41
40
  this._gap = 0;
42
- this._prevDeltaX = 0;
43
- this._prevDeltaY = 0;
44
- this._prevSnappedWidth = 0;
45
- this._prevSnappedHeight = 0;
46
41
  this._position = {
47
42
  column: { start: 0, span: 0 },
48
43
  row: { start: 0, span: 0 },
49
44
  };
50
- this._columns = {
51
- count: 0,
52
- entries: [],
53
- minSize: 0,
54
- };
55
- this._rows = {
56
- count: 0,
57
- entries: [],
58
- minSize: 0,
45
+ this._axes = {
46
+ column: createAxisState(),
47
+ row: createAxisState(),
59
48
  };
60
- this.resizedDimensions = {
61
- width: null,
62
- height: null,
63
- };
64
- }
65
- get gap() {
66
- return this._gap;
67
- }
68
- get position() {
69
- return structuredClone(this._position);
70
- }
71
- get columns() {
72
- return structuredClone(this._columns);
73
- }
74
- get rows() {
75
- return structuredClone(this._rows);
76
49
  }
77
50
  calculateSnappedWidth(state) {
78
- const resizeProps = this.getResizeProps(state);
79
- const snappedDimension = this._resizeUtil.calculateSnappedDimension(resizeProps);
80
- this._prevDeltaX = snappedDimension.newDelta;
81
- this._prevSnappedWidth = snappedDimension.snappedSize;
82
- return snappedDimension.snappedSize;
51
+ return this._calculateSnappedSize('column', state.deltaX, state.current.width);
83
52
  }
84
53
  calculateSnappedHeight(state) {
85
- const resizeProps = this.getResizeProps(state, true);
86
- const snappedDimension = this._resizeUtil.calculateSnappedDimension(resizeProps);
87
- this._prevDeltaY = snappedDimension.newDelta;
88
- this._prevSnappedHeight = snappedDimension.snappedSize;
89
- return snappedDimension.snappedSize;
54
+ return this._calculateSnappedSize('row', state.deltaY, state.current.height);
90
55
  }
91
56
  updateState(tileRect, tile, grid) {
92
- this.initState(grid, tile);
93
- this.calculateTileStartPosition(grid, tileRect);
57
+ this._initState(grid, tile);
58
+ this._calculateTileStartPosition(grid, tileRect);
94
59
  }
95
60
  calculateResizedGridPosition(rect) {
96
- const colProps = this.getResizeSpanProps(rect);
97
- const rowProps = this.getResizeSpanProps(rect, true);
98
- this._position.column.span =
99
- this._resizeUtil.calculateResizedSpan(colProps);
100
- this._position.row.span = this._resizeUtil.calculateResizedSpan(rowProps);
101
- return {
102
- colSpan: this._position.column.span,
103
- rowSpan: this._position.row.span,
104
- };
61
+ const { column, row } = this._position;
62
+ column.span = calculateResizedSpan({
63
+ targetSize: rect.width,
64
+ tilePosition: column,
65
+ tileGridDimension: this._axes.column.dimension,
66
+ gap: this._gap,
67
+ isRow: false,
68
+ });
69
+ row.span = calculateResizedSpan({
70
+ targetSize: rect.height,
71
+ tilePosition: row,
72
+ tileGridDimension: this._axes.row.dimension,
73
+ gap: this._gap,
74
+ isRow: true,
75
+ });
76
+ return { colSpan: column.span, rowSpan: row.span };
105
77
  }
106
- initState(grid, tile) {
78
+ _calculateSnappedSize(axis, currentDelta, currentSize) {
79
+ const axisState = this._axes[axis];
80
+ const { snappedSize, newDelta } = calculateSnappedDimension({
81
+ currentDelta,
82
+ currentSize,
83
+ prevDelta: axisState.prevDelta,
84
+ prevSnapped: axisState.prevSnapped,
85
+ gridEntries: axisState.dimension.entries,
86
+ startIndex: this._position[axis].start,
87
+ gap: this._gap,
88
+ });
89
+ axisState.prevDelta = newDelta;
90
+ axisState.prevSnapped = snappedSize;
91
+ return snappedSize;
92
+ }
93
+ _initState(grid, tile) {
107
94
  const { gap, columns, rows } = parseTileParentGrid(grid);
108
- this._resizeUtil = new ResizeUtil(gap);
109
- this._initialPosition = parseTileGridRect(tile);
110
- this._position = structuredClone(this._initialPosition);
111
95
  this._gap = gap;
112
- this._columns = columns;
113
- this._rows = rows;
114
- this._prevDeltaX = 0;
115
- this._prevDeltaY = 0;
116
- this._prevSnappedWidth = 0;
117
- this._prevSnappedHeight = 0;
96
+ this._position = parseTileGridRect(tile);
97
+ this._axes = {
98
+ column: createAxisState(columns),
99
+ row: createAxisState(rows),
100
+ };
118
101
  }
119
- calculateTileStartPosition(grid, tileRect) {
120
- if (this._position.column.start < 0) {
121
- const offsetX = this.getGridOffset(grid, 'horizontal');
122
- this._position.column.start = this._resizeUtil.calculatePosition(tileRect.left + window.scrollX + grid.scrollLeft - offsetX, this._columns.entries);
102
+ _calculateTileStartPosition(grid, tileRect) {
103
+ const { column, row } = this._position;
104
+ if (column.start >= 0 && row.start >= 0) {
105
+ return;
123
106
  }
124
- if (this._position.row.start < 0) {
125
- const offsetY = this.getGridOffset(grid, 'vertical');
126
- this._position.row.start = this._resizeUtil.calculatePosition(tileRect.top + window.scrollY - offsetY, this._rows.entries);
127
- }
128
- }
129
- getGridOffset(grid, axis) {
130
107
  const gridRect = grid.getBoundingClientRect();
131
108
  const computed = getComputedStyle(grid);
132
- return axis === 'horizontal'
133
- ? gridRect.left +
134
- window.scrollX +
135
- grid.scrollLeft +
136
- Number.parseFloat(computed.paddingLeft)
137
- : gridRect.top + window.scrollY + Number.parseFloat(computed.paddingTop);
138
- }
139
- getResizeProps(state, isRow = false) {
140
- return isRow
141
- ? {
142
- currentDelta: state.deltaY,
143
- currentSize: state.current.height,
144
- prevDelta: this._prevDeltaY,
145
- gridEntries: this._rows.entries,
146
- startIndex: this._position.row.start,
147
- prevSnapped: this._prevSnappedHeight,
148
- }
149
- : {
150
- currentDelta: state.deltaX,
151
- currentSize: state.current.width,
152
- prevDelta: this._prevDeltaX,
153
- gridEntries: this._columns.entries,
154
- startIndex: this._position.column.start,
155
- prevSnapped: this._prevSnappedWidth,
156
- };
157
- }
158
- getResizeSpanProps(rect, isRow = false) {
159
- return isRow
160
- ? {
161
- targetSize: rect.height,
162
- tilePosition: this.position.row,
163
- tileGridDimension: this.rows,
164
- gap: this.gap,
165
- isRow,
166
- }
167
- : {
168
- targetSize: rect.width,
169
- tilePosition: this.position.column,
170
- tileGridDimension: this.columns,
171
- gap: this.gap,
172
- isRow,
173
- };
109
+ if (column.start < 0) {
110
+ column.start = calculatePosition(tileRect.left - gridRect.left - Number.parseFloat(computed.paddingLeft), this._axes.column.dimension.entries, this._gap);
111
+ }
112
+ if (row.start < 0) {
113
+ row.start = calculatePosition(tileRect.top - gridRect.top - Number.parseFloat(computed.paddingTop), this._axes.row.dimension.entries, this._gap);
114
+ }
174
115
  }
175
116
  }
176
117
  export function createTileResizeState() {
@@ -1 +1 @@
1
- {"version":3,"file":"resize-state.js","sourceRoot":"","sources":["../../../src/components/tile-manager/resize-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAU9C,MAAM,SAAS,GAAG,+CAA+C,CAAC;AAElE,SAAS,iBAAiB,CAAC,IAAsB;IAC/C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;IAEzC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QACpB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAO;QAC3D,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAO;KACzD,CAAC;IAEF,OAAO;QACL,MAAM,EAAE;YACN,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACjC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;SAChC;QACD,GAAG,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC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ACN;YACH,CAAC,CAAC;gBACE,UAAU,EAAE,IAAI,CAAC,KAAK;gBACtB,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM;gBAClC,iBAAiB,EAAE,IAAI,CAAC,OAAO;gBAC/B,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,KAAK;aACN,CAAC;IACR,CAAC;CACF;AAED,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,eAAe,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["import { firstOf } from '#internals/utils/arrays.js';\nimport { asNumber } from '#internals/utils/math.js';\nimport type { ResizeState } from '../resize-container/types.js';\nimport { ResizeUtil } from './resize-util.js';\nimport type IgcTileComponent from './tile.js';\nimport type {\n ResizeProps,\n ResizeSpanProps,\n TileGridDimension,\n TileGridPosition,\n TileResizeDimensions,\n} from './types.js';\n\nconst CssValues = /(?<start>\\d+)?\\s*\\/?\\s*span\\s*(?<span>\\d+)?/gi;\n\nfunction parseTileGridRect(tile: IgcTileComponent): TileGridPosition {\n const computed = getComputedStyle(tile);\n const { gridColumn, gridRow } = computed;\n\n const [column, row] = [\n firstOf(Array.from(gridColumn.matchAll(CssValues))).groups!,\n firstOf(Array.from(gridRow.matchAll(CssValues))).groups!,\n ];\n\n return {\n column: {\n start: asNumber(column.start, -1),\n span: asNumber(column.span, -1),\n },\n row: { start: asNumber(row.start, -1), span: asNumber(row.span, -1) },\n };\n}\n\nfunction parseTileParentGrid(gridContainer: HTMLElement) {\n const computed = getComputedStyle(gridContainer);\n const { gap, gridTemplateColumns, gridTemplateRows } = computed;\n\n const columns = gridTemplateColumns.split(' ').map(asNumber);\n const rows = gridTemplateRows.split(' ').map(asNumber);\n\n return {\n gap: asNumber(gap),\n columns: {\n count: columns.length,\n entries: columns,\n minSize: asNumber(computed.getPropertyValue('--min-col-width')),\n },\n rows: {\n count: rows.length,\n entries: rows,\n minSize: asNumber(computed.getPropertyValue('--min-row-height')),\n },\n };\n}\n\nclass TileResizeState {\n private _initialPosition!: TileGridPosition;\n private _resizeUtil!: ResizeUtil;\n\n protected _gap = 0;\n protected _prevDeltaX = 0;\n protected _prevDeltaY = 0;\n\n protected _prevSnappedWidth = 0;\n protected _prevSnappedHeight = 0;\n\n protected _position: TileGridPosition = {\n column: { start: 0, span: 0 },\n row: { start: 0, span: 0 },\n };\n\n protected _columns: TileGridDimension = {\n count: 0,\n entries: [],\n minSize: 0,\n };\n\n protected _rows: TileGridDimension = {\n count: 0,\n entries: [],\n minSize: 0,\n };\n\n public resizedDimensions: TileResizeDimensions = {\n width: null,\n height: null,\n };\n\n public get gap(): number {\n return this._gap;\n }\n\n public get position(): TileGridPosition {\n return structuredClone(this._position);\n }\n\n public get columns(): TileGridDimension {\n return structuredClone(this._columns);\n }\n\n public get rows(): TileGridDimension {\n return structuredClone(this._rows);\n }\n\n public calculateSnappedWidth(state: ResizeState): number {\n const resizeProps = this.getResizeProps(state);\n const snappedDimension =\n this._resizeUtil.calculateSnappedDimension(resizeProps);\n\n this._prevDeltaX = snappedDimension.newDelta;\n this._prevSnappedWidth = snappedDimension.snappedSize;\n return snappedDimension.snappedSize;\n }\n\n public calculateSnappedHeight(state: ResizeState): number {\n const resizeProps = this.getResizeProps(state, true);\n const snappedDimension =\n this._resizeUtil.calculateSnappedDimension(resizeProps);\n\n this._prevDeltaY = snappedDimension.newDelta;\n this._prevSnappedHeight = snappedDimension.snappedSize;\n return snappedDimension.snappedSize;\n }\n\n public updateState(\n tileRect: DOMRect,\n tile: IgcTileComponent,\n grid: HTMLElement\n ): void {\n this.initState(grid, tile);\n this.calculateTileStartPosition(grid, tileRect);\n }\n\n /**\n * Calculates and returns the CSS column and row properties of a tile after resizing,\n * based on its new dimensions and starting position.\n */\n public calculateResizedGridPosition(rect: DOMRect) {\n const colProps = this.getResizeSpanProps(rect);\n const rowProps = this.getResizeSpanProps(rect, true);\n\n // REVIEW pass col minSize and allowOverflow?\n this._position.column.span =\n this._resizeUtil.calculateResizedSpan(colProps);\n this._position.row.span = this._resizeUtil.calculateResizedSpan(rowProps);\n\n return {\n colSpan: this._position.column.span,\n rowSpan: this._position.row.span,\n };\n }\n\n private initState(grid: HTMLElement, tile: IgcTileComponent): void {\n const { gap, columns, rows } = parseTileParentGrid(grid);\n\n this._resizeUtil = new ResizeUtil(gap);\n this._initialPosition = parseTileGridRect(tile);\n this._position = structuredClone(this._initialPosition);\n\n this._gap = gap;\n this._columns = columns;\n this._rows = rows;\n this._prevDeltaX = 0;\n this._prevDeltaY = 0;\n this._prevSnappedWidth = 0;\n this._prevSnappedHeight = 0;\n }\n\n private calculateTileStartPosition(\n grid: HTMLElement,\n tileRect: DOMRect\n ): void {\n if (this._position.column.start < 0) {\n const offsetX = this.getGridOffset(grid, 'horizontal');\n\n this._position.column.start = this._resizeUtil.calculatePosition(\n tileRect.left + window.scrollX + grid.scrollLeft - offsetX,\n this._columns.entries\n );\n }\n\n if (this._position.row.start < 0) {\n const offsetY = this.getGridOffset(grid, 'vertical');\n\n this._position.row.start = this._resizeUtil.calculatePosition(\n tileRect.top + window.scrollY - offsetY,\n this._rows.entries\n );\n }\n }\n\n private getGridOffset(\n grid: HTMLElement,\n axis: 'horizontal' | 'vertical'\n ): number {\n const gridRect = grid.getBoundingClientRect();\n const computed = getComputedStyle(grid);\n\n return axis === 'horizontal'\n ? gridRect.left +\n window.scrollX +\n grid.scrollLeft +\n Number.parseFloat(computed.paddingLeft)\n : gridRect.top + window.scrollY + Number.parseFloat(computed.paddingTop);\n }\n\n private getResizeProps(state: ResizeState, isRow = false): ResizeProps {\n return isRow\n ? {\n currentDelta: state.deltaY,\n currentSize: state.current.height,\n prevDelta: this._prevDeltaY,\n gridEntries: this._rows.entries,\n startIndex: this._position.row.start,\n prevSnapped: this._prevSnappedHeight,\n }\n : {\n currentDelta: state.deltaX,\n currentSize: state.current.width,\n prevDelta: this._prevDeltaX,\n gridEntries: this._columns.entries,\n startIndex: this._position.column.start,\n prevSnapped: this._prevSnappedWidth,\n };\n }\n\n private getResizeSpanProps(rect: DOMRect, isRow = false): ResizeSpanProps {\n return isRow\n ? {\n targetSize: rect.height,\n tilePosition: this.position.row,\n tileGridDimension: this.rows,\n gap: this.gap,\n isRow,\n }\n : {\n targetSize: rect.width,\n tilePosition: this.position.column,\n tileGridDimension: this.columns,\n gap: this.gap,\n isRow,\n };\n }\n}\n\nexport function createTileResizeState(): TileResizeState {\n return new TileResizeState();\n}\n"]}
1
+ {"version":3,"file":"resize-state.js","sourceRoot":"","sources":["../../../src/components/tile-manager/resize-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAI1B,MAAM,SAAS,GAAG,+CAA+C,CAAC;AAUlE,SAAS,eAAe,CACtB,YAA+B,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;IAE1D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;AACrD,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAsB;IAC/C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;IAEzC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QACpB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAO;QAC3D,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAO;KACzD,CAAC;IAEF,OAAO;QACL,MAAM,EAAE;YACN,KAAK,EAAE,QAAQ,CAAC,MAAM,CAA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AqB,EAAE,CAAC;QAC9C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAExC,IAAI,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;YACrB,MAAM,CAAC,KAAK,GAAG,iBAAiB,CAC9B,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,EACvE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EACnC,IAAI,CAAC,IAAI,CACV,CAAC;QACJ,CAAC;QAED,IAAI,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;YAClB,GAAG,CAAC,KAAK,GAAG,iBAAiB,CAC3B,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,EACpE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,EAChC,IAAI,CAAC,IAAI,CACV,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,eAAe,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["import type { ResizeState } from '#internals/directives/resize.js';\nimport { firstOf } from '#internals/utils/arrays.js';\nimport { asNumber } from '#internals/utils/math.js';\nimport {\n calculatePosition,\n calculateResizedSpan,\n calculateSnappedDimension,\n} from './resize-util.js';\nimport type IgcTileComponent from './tile.js';\nimport type { TileGridDimension, TileGridPosition } from './types.js';\n\nconst CssValues = /(?<start>\\d+)?\\s*\\/?\\s*span\\s*(?<span>\\d+)?/gi;\n\ntype ResizeAxis = 'column' | 'row';\n\ntype ResizeAxisState = {\n dimension: TileGridDimension;\n prevDelta: number;\n prevSnapped: number;\n};\n\nfunction createAxisState(\n dimension: TileGridDimension = { entries: [], minSize: 0 }\n): ResizeAxisState {\n return { dimension, prevDelta: 0, prevSnapped: 0 };\n}\n\nfunction parseTileGridRect(tile: IgcTileComponent): TileGridPosition {\n const computed = getComputedStyle(tile);\n const { gridColumn, gridRow } = computed;\n\n const [column, row] = [\n firstOf(Array.from(gridColumn.matchAll(CssValues))).groups!,\n firstOf(Array.from(gridRow.matchAll(CssValues))).groups!,\n ];\n\n return {\n column: {\n start: asNumber(column.start, -1),\n span: asNumber(column.span, -1),\n },\n row: { start: asNumber(row.start, -1), span: asNumber(row.span, -1) },\n };\n}\n\nfunction parseTileParentGrid(gridContainer: HTMLElement) {\n const computed = getComputedStyle(gridContainer);\n const { gap, gridTemplateColumns, gridTemplateRows } = computed;\n\n return {\n gap: asNumber(gap),\n columns: {\n entries: gridTemplateColumns.split(' ').map(asNumber),\n minSize: asNumber(computed.getPropertyValue('--min-col-width')),\n },\n rows: {\n entries: gridTemplateRows.split(' ').map(asNumber),\n minSize: asNumber(computed.getPropertyValue('--min-row-height')),\n },\n };\n}\n\nclass TileResizeState {\n private _gap = 0;\n\n private _position: TileGridPosition = {\n column: { start: 0, span: 0 },\n row: { start: 0, span: 0 },\n };\n\n private _axes: Record<ResizeAxis, ResizeAxisState> = {\n column: createAxisState(),\n row: createAxisState(),\n };\n\n public calculateSnappedWidth(state: ResizeState): number {\n return this._calculateSnappedSize(\n 'column',\n state.deltaX,\n state.current.width\n );\n }\n\n public calculateSnappedHeight(state: ResizeState): number {\n return this._calculateSnappedSize(\n 'row',\n state.deltaY,\n state.current.height\n );\n }\n\n public updateState(\n tileRect: DOMRect,\n tile: IgcTileComponent,\n grid: HTMLElement\n ): void {\n this._initState(grid, tile);\n this._calculateTileStartPosition(grid, tileRect);\n }\n\n /**\n * Calculates and returns the CSS column and row properties of a tile after resizing,\n * based on its new dimensions and starting position.\n */\n public calculateResizedGridPosition(rect: DOMRect) {\n const { column, row } = this._position;\n\n // REVIEW pass col minSize and allowOverflow?\n column.span = calculateResizedSpan({\n targetSize: rect.width,\n tilePosition: column,\n tileGridDimension: this._axes.column.dimension,\n gap: this._gap,\n isRow: false,\n });\n\n row.span = calculateResizedSpan({\n targetSize: rect.height,\n tilePosition: row,\n tileGridDimension: this._axes.row.dimension,\n gap: this._gap,\n isRow: true,\n });\n\n return { colSpan: column.span, rowSpan: row.span };\n }\n\n private _calculateSnappedSize(\n axis: ResizeAxis,\n currentDelta: number,\n currentSize: number\n ): number {\n const axisState = this._axes[axis];\n\n const { snappedSize, newDelta } = calculateSnappedDimension({\n currentDelta,\n currentSize,\n prevDelta: axisState.prevDelta,\n prevSnapped: axisState.prevSnapped,\n gridEntries: axisState.dimension.entries,\n startIndex: this._position[axis].start,\n gap: this._gap,\n });\n\n axisState.prevDelta = newDelta;\n axisState.prevSnapped = snappedSize;\n return snappedSize;\n }\n\n private _initState(grid: HTMLElement, tile: IgcTileComponent): void {\n const { gap, columns, rows } = parseTileParentGrid(grid);\n\n this._gap = gap;\n this._position = parseTileGridRect(tile);\n this._axes = {\n column: createAxisState(columns),\n row: createAxisState(rows),\n };\n }\n\n /**\n * Resolves the tile's implicit grid start lines from its offset inside the\n * grid container when the tile has no explicit `colStart`/`rowStart`.\n */\n private _calculateTileStartPosition(\n grid: HTMLElement,\n tileRect: DOMRect\n ): void {\n const { column, row } = this._position;\n\n if (column.start >= 0 && row.start >= 0) {\n return;\n }\n\n const gridRect = grid.getBoundingClientRect();\n const computed = getComputedStyle(grid);\n\n if (column.start < 0) {\n column.start = calculatePosition(\n tileRect.left - gridRect.left - Number.parseFloat(computed.paddingLeft),\n this._axes.column.dimension.entries,\n this._gap\n );\n }\n\n if (row.start < 0) {\n row.start = calculatePosition(\n tileRect.top - gridRect.top - Number.parseFloat(computed.paddingTop),\n this._axes.row.dimension.entries,\n this._gap\n );\n }\n }\n}\n\nexport function createTileResizeState(): TileResizeState {\n return new TileResizeState();\n}\n"]}
@@ -1,8 +1,4 @@
1
1
  import type { ResizeProps, ResizeSpanProps, SnappedDimension } from './types.js';
2
- export declare class ResizeUtil {
3
- private gap;
4
- constructor(gap: number);
5
- calculateSnappedDimension(resizeProps: ResizeProps): SnappedDimension;
6
- calculateResizedSpan(props: ResizeSpanProps): number;
7
- calculatePosition(targetPosition: number, sizes: number[]): number;
8
- }
2
+ export declare function calculateSnappedDimension(props: ResizeProps): SnappedDimension;
3
+ export declare function calculateResizedSpan(props: ResizeSpanProps): number;
4
+ export declare function calculatePosition(targetPosition: number, sizes: number[], gap: number): number;
@@ -1,84 +1,77 @@
1
- export class ResizeUtil {
2
- constructor(gap) {
3
- this.gap = gap;
1
+ export function calculateSnappedDimension(props) {
2
+ const { currentDelta, prevDelta, currentSize, gridEntries, startIndex, prevSnapped, gap, } = props;
3
+ const effectiveDelta = currentDelta - prevDelta;
4
+ let snappedSize = currentSize;
5
+ if (Math.trunc(currentSize) < gridEntries[startIndex - 1]) {
6
+ return {
7
+ snappedSize: gridEntries[startIndex - 1],
8
+ newDelta: currentDelta,
9
+ };
4
10
  }
5
- calculateSnappedDimension(resizeProps) {
6
- const { currentDelta, prevDelta, currentSize, gridEntries, startIndex, prevSnapped, } = resizeProps;
7
- const effectiveDelta = currentDelta - prevDelta;
8
- let snappedSize = currentSize;
9
- if (Math.trunc(currentSize) < gridEntries[startIndex - 1]) {
10
- return {
11
- snappedSize: gridEntries[startIndex - 1],
12
- newDelta: currentDelta,
13
- };
14
- }
15
- if (effectiveDelta === 0 && prevSnapped) {
16
- return { snappedSize: prevSnapped, newDelta: currentDelta };
17
- }
18
- let accumulated = 0;
19
- for (let i = startIndex - 1; i < gridEntries.length; i++) {
20
- const currentEntry = gridEntries[i];
21
- const nextEntry = gridEntries[i + 1] ?? currentEntry;
22
- const prevEntry = i > 0 ? gridEntries[i - 1] : currentEntry;
23
- const halfwayExpand = accumulated + currentEntry + this.gap + nextEntry / 2;
24
- const halfwayShrink = accumulated + prevEntry / 2;
25
- const entryEnd = accumulated + currentEntry + this.gap;
26
- if (effectiveDelta > 0) {
27
- if (currentSize >= halfwayExpand &&
28
- currentSize <= entryEnd + nextEntry) {
29
- snappedSize = entryEnd + nextEntry;
30
- }
11
+ if (effectiveDelta === 0 && prevSnapped) {
12
+ return { snappedSize: prevSnapped, newDelta: currentDelta };
13
+ }
14
+ let accumulated = 0;
15
+ for (let i = startIndex - 1; i < gridEntries.length; i++) {
16
+ const currentEntry = gridEntries[i];
17
+ const nextEntry = gridEntries[i + 1] ?? currentEntry;
18
+ const prevEntry = i > 0 ? gridEntries[i - 1] : currentEntry;
19
+ const halfwayExpand = accumulated + currentEntry + gap + nextEntry / 2;
20
+ const halfwayShrink = accumulated + prevEntry / 2;
21
+ const entryEnd = accumulated + currentEntry + gap;
22
+ if (effectiveDelta > 0) {
23
+ if (currentSize >= halfwayExpand && currentSize <= entryEnd + nextEntry) {
24
+ snappedSize = entryEnd + nextEntry;
31
25
  }
32
- else if (effectiveDelta < 0) {
33
- if (currentSize <= halfwayShrink &&
34
- currentSize > accumulated - this.gap) {
35
- snappedSize = accumulated - this.gap;
36
- }
26
+ }
27
+ else if (effectiveDelta < 0) {
28
+ if (currentSize <= halfwayShrink && currentSize > accumulated - gap) {
29
+ snappedSize = accumulated - gap;
37
30
  }
38
- accumulated += currentEntry + this.gap;
39
31
  }
40
- return { snappedSize, newDelta: currentDelta };
32
+ accumulated += currentEntry + gap;
41
33
  }
42
- calculateResizedSpan(props) {
43
- const { targetSize, tilePosition, tileGridDimension, gap, isRow } = props;
44
- const { entries, minSize } = tileGridDimension;
45
- let accumulatedSize = 0;
46
- let newSpan = tilePosition.span;
47
- const sizesAfterStart = entries.slice(tilePosition.start - 1);
48
- const availableSize = sizesAfterStart.reduce((sum, s) => sum + s, 0) +
49
- (sizesAfterStart.length - 1) * gap;
50
- if (targetSize <= sizesAfterStart[0] + gap) {
51
- return 1;
52
- }
53
- if (Math.trunc(targetSize) > Math.trunc(availableSize)) {
54
- const remainingSize = targetSize - availableSize;
55
- const additionalSpan = Math.ceil(remainingSize / (minSize + gap));
56
- newSpan = sizesAfterStart.length + additionalSpan;
57
- return isRow ? newSpan : Math.min(entries.length, newSpan);
34
+ return { snappedSize, newDelta: currentDelta };
35
+ }
36
+ export function calculateResizedSpan(props) {
37
+ const { targetSize, tilePosition, tileGridDimension, gap, isRow } = props;
38
+ const { entries, minSize } = tileGridDimension;
39
+ let accumulatedSize = 0;
40
+ let newSpan = tilePosition.span;
41
+ const sizesAfterStart = entries.slice(tilePosition.start - 1);
42
+ const availableSize = sizesAfterStart.reduce((sum, s) => sum + s, 0) +
43
+ (sizesAfterStart.length - 1) * gap;
44
+ if (targetSize <= sizesAfterStart[0] + gap) {
45
+ return 1;
46
+ }
47
+ if (Math.trunc(targetSize) > Math.trunc(availableSize)) {
48
+ const remainingSize = targetSize - availableSize;
49
+ const additionalSpan = Math.ceil(remainingSize / (minSize + gap));
50
+ newSpan = sizesAfterStart.length + additionalSpan;
51
+ return isRow ? newSpan : Math.min(entries.length, newSpan);
52
+ }
53
+ for (let i = tilePosition.start - 1; i < entries.length; i++) {
54
+ const currentSize = entries[i];
55
+ const nextSize = entries[i + 1] ?? currentSize;
56
+ const halfwayPoint = accumulatedSize + currentSize + gap + nextSize / 2;
57
+ if (targetSize > halfwayPoint) {
58
+ newSpan = i + 3 - tilePosition.start;
58
59
  }
59
- for (let i = tilePosition.start - 1; i < entries.length; i++) {
60
- const currentSize = entries[i];
61
- const nextSize = entries[i + 1] ?? currentSize;
62
- const halfwayPoint = accumulatedSize + currentSize + gap + nextSize / 2;
63
- if (targetSize > halfwayPoint) {
64
- newSpan = i + 3 - tilePosition.start;
65
- }
66
- else {
67
- break;
68
- }
69
- accumulatedSize += currentSize + gap;
60
+ else {
61
+ break;
70
62
  }
71
- return newSpan;
63
+ accumulatedSize += currentSize + gap;
72
64
  }
73
- calculatePosition(targetPosition, sizes) {
74
- let accumulatedSize = 0;
75
- for (const [i, size] of sizes.entries()) {
76
- accumulatedSize += size + this.gap;
77
- if (Math.trunc(targetPosition) < Math.trunc(accumulatedSize - this.gap)) {
78
- return i + 1;
79
- }
65
+ return newSpan;
66
+ }
67
+ export function calculatePosition(targetPosition, sizes, gap) {
68
+ let accumulatedSize = 0;
69
+ for (const [i, size] of sizes.entries()) {
70
+ accumulatedSize += size + gap;
71
+ if (Math.trunc(targetPosition) < Math.trunc(accumulatedSize - gap)) {
72
+ return i + 1;
80
73
  }
81
- return 1;
82
74
  }
75
+ return 1;
83
76
  }
84
77
  //# sourceMappingURL=resize-util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resize-util.js","sourceRoot":"","sources":["../../../src/components/tile-manager/resize-util.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,UAAU;IAGrB,YAAY,GAAW;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAEM,yBAAyB,CAAC,WAAwB;QACvD,MAAM,EACJ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,WAAW,EACX,UAAU,EACV,WAAW,GACZ,GAAG,WAAW,CAAC;QAEhB,MAAM,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC;QAChD,IAAI,WAAW,GAAG,WAAW,CAAC;QAG9B,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC;YAC1D,OAAO;gBACL,WAAW,EAAE,WAAW,CAAC,UAAU,GAAG,CAAC,CAAC;gBACxC,QAAQ,EAAE,YAAY;aACvB,CAAC;QACJ,CAAC;QAGD,IAAI,cAAc,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC;YACxC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;QAC9D,CAAC;QAED,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,KAAK,IAAI,CAAC,GAAG,UAAU,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACzD,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;YACpC,MAAM,SAAS,GAA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C;gBAC9B,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC;YACvC,CAAC;iBAAM,CAAC;gBACN,MAAM;YACR,CAAC;YAED,eAAe,IAAI,WAAW,GAAG,GAAG,CAAC;QACvC,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAEM,iBAAiB,CAAC,cAAsB,EAAE,KAAe;QAC9D,IAAI,eAAe,GAAG,CAAC,CAAC;QAExB,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YACxC,eAAe,IAAI,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC;YAEnC,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxE,OAAO,CAAC,GAAG,CAAC,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF","sourcesContent":["import type {\n ResizeProps,\n ResizeSpanProps,\n SnappedDimension,\n} from './types.js';\n\nexport class ResizeUtil {\n private gap: number;\n\n constructor(gap: number) {\n this.gap = gap;\n }\n\n public calculateSnappedDimension(resizeProps: ResizeProps): SnappedDimension {\n const {\n currentDelta,\n prevDelta,\n currentSize,\n gridEntries,\n startIndex,\n prevSnapped,\n } = resizeProps;\n\n const effectiveDelta = currentDelta - prevDelta;\n let snappedSize = currentSize;\n\n // If current size is below minimum, force to the size of the starting cell.\n if (Math.trunc(currentSize) < gridEntries[startIndex - 1]) {\n return {\n snappedSize: gridEntries[startIndex - 1],\n newDelta: currentDelta,\n };\n }\n\n // If no change in delta and we have a snapped value, reuse it.\n if (effectiveDelta === 0 && prevSnapped) {\n return { snappedSize: prevSnapped, newDelta: currentDelta };\n }\n\n let accumulated = 0;\n for (let i = startIndex - 1; i < gridEntries.length; i++) {\n const currentEntry = gridEntries[i];\n const nextEntry = gridEntries[i + 1] ?? currentEntry;\n const prevEntry = i > 0 ? gridEntries[i - 1] : currentEntry;\n\n // Thresholds for snapping to the next or previous tile boundary.\n const halfwayExpand =\n accumulated + currentEntry + this.gap + nextEntry / 2;\n const halfwayShrink = accumulated + prevEntry / 2;\n const entryEnd = accumulated + currentEntry + this.gap;\n\n if (effectiveDelta > 0) {\n // Expanding: snap when passing the halfway threshold.\n if (\n currentSize >= halfwayExpand &&\n currentSize <= entryEnd + nextEntry\n ) {\n snappedSize = entryEnd + nextEntry;\n }\n } else if (effectiveDelta < 0) {\n // Shrinking: snap when falling below the halfway threshold.\n if (\n currentSize <= halfwayShrink &&\n currentSize > accumulated - this.gap\n ) {\n snappedSize = accumulated - this.gap;\n }\n }\n\n accumulated += currentEntry + this.gap;\n }\n\n return { snappedSize, newDelta: currentDelta };\n }\n\n public calculateResizedSpan(props: ResizeSpanProps): number {\n const { targetSize, tilePosition, tileGridDimension, gap, isRow } = props;\n const { entries, minSize } = tileGridDimension;\n\n let accumulatedSize = 0;\n let newSpan = tilePosition.span;\n\n const sizesAfterStart = entries.slice(tilePosition.start - 1);\n const availableSize =\n sizesAfterStart.reduce((sum, s) => sum + s, 0) +\n (sizesAfterStart.length - 1) * gap;\n\n if (targetSize <= sizesAfterStart[0] + gap) {\n return 1;\n }\n\n if (Math.trunc(targetSize) > Math.trunc(availableSize)) {\n const remainingSize = targetSize - availableSize;\n\n const additionalSpan = Math.ceil(remainingSize / (minSize + gap));\n newSpan = sizesAfterStart.length + additionalSpan;\n return isRow ? newSpan : Math.min(entries.length, newSpan);\n }\n\n for (let i = tilePosition.start - 1; i < entries.length; i++) {\n const currentSize = entries[i];\n const nextSize = entries[i + 1] ?? currentSize;\n\n const halfwayPoint = accumulatedSize + currentSize + gap + nextSize / 2;\n\n if (targetSize > halfwayPoint) {\n newSpan = i + 3 - tilePosition.start;\n } else {\n break;\n }\n\n accumulatedSize += currentSize + gap;\n }\n\n return newSpan;\n }\n\n public calculatePosition(targetPosition: number, sizes: number[]): number {\n let accumulatedSize = 0;\n\n for (const [i, size] of sizes.entries()) {\n accumulatedSize += size + this.gap;\n\n if (Math.trunc(targetPosition) < Math.trunc(accumulatedSize - this.gap)) {\n return i + 1;\n }\n }\n\n return 1;\n }\n}\n"]}
1
+ {"version":3,"file":"resize-util.js","sourceRoot":"","sources":["../../../src/components/tile-manager/resize-util.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,yBAAyB,CACvC,KAAkB;IAElB,MAAM,EACJ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,WAAW,EACX,UAAU,EACV,WAAW,EACX,GAAG,GACJ,GAAG,KAAK,CAAC;IAEV,MAAM,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC;IAChD,IAAI,WAAW,GAAG,WAAW,CAAC;IAG9B,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC;QAC1D,OAAO;YACL,WAAW,EAAE,WAAW,CAAC,UAAU,GAAG,CAAC,CAAC;YACxC,QAAQ,EAAE,YAAY;SACvB,CAAC;IACJ,CAAC;IAGD,IAAI,cAAc,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC;QACxC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IAC9D,CAAC;IAED,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,KAAK,IAAI,CAAC,GAAG,UAAU,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzD,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,YAAY,CAAC;QACrD,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,C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AED,MAAM,UAAU,iBAAiB,CAC/B,cAAsB,EACtB,KAAe,EACf,GAAW;IAEX,IAAI,eAAe,GAAG,CAAC,CAAC;IAExB,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;QACxC,eAAe,IAAI,IAAI,GAAG,GAAG,CAAC;QAE9B,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC,EAAE,CAAC;YACnE,OAAO,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["import type {\n ResizeProps,\n ResizeSpanProps,\n SnappedDimension,\n} from './types.js';\n\nexport function calculateSnappedDimension(\n props: ResizeProps\n): SnappedDimension {\n const {\n currentDelta,\n prevDelta,\n currentSize,\n gridEntries,\n startIndex,\n prevSnapped,\n gap,\n } = props;\n\n const effectiveDelta = currentDelta - prevDelta;\n let snappedSize = currentSize;\n\n // If current size is below minimum, force to the size of the starting cell.\n if (Math.trunc(currentSize) < gridEntries[startIndex - 1]) {\n return {\n snappedSize: gridEntries[startIndex - 1],\n newDelta: currentDelta,\n };\n }\n\n // If no change in delta and we have a snapped value, reuse it.\n if (effectiveDelta === 0 && prevSnapped) {\n return { snappedSize: prevSnapped, newDelta: currentDelta };\n }\n\n let accumulated = 0;\n for (let i = startIndex - 1; i < gridEntries.length; i++) {\n const currentEntry = gridEntries[i];\n const nextEntry = gridEntries[i + 1] ?? currentEntry;\n const prevEntry = i > 0 ? gridEntries[i - 1] : currentEntry;\n\n // Thresholds for snapping to the next or previous tile boundary.\n const halfwayExpand = accumulated + currentEntry + gap + nextEntry / 2;\n const halfwayShrink = accumulated + prevEntry / 2;\n const entryEnd = accumulated + currentEntry + gap;\n\n if (effectiveDelta > 0) {\n // Expanding: snap when passing the halfway threshold.\n if (currentSize >= halfwayExpand && currentSize <= entryEnd + nextEntry) {\n snappedSize = entryEnd + nextEntry;\n }\n } else if (effectiveDelta < 0) {\n // Shrinking: snap when falling below the halfway threshold.\n if (currentSize <= halfwayShrink && currentSize > accumulated - gap) {\n snappedSize = accumulated - gap;\n }\n }\n\n accumulated += currentEntry + gap;\n }\n\n return { snappedSize, newDelta: currentDelta };\n}\n\nexport function calculateResizedSpan(props: ResizeSpanProps): number {\n const { targetSize, tilePosition, tileGridDimension, gap, isRow } = props;\n const { entries, minSize } = tileGridDimension;\n\n let accumulatedSize = 0;\n let newSpan = tilePosition.span;\n\n const sizesAfterStart = entries.slice(tilePosition.start - 1);\n const availableSize =\n sizesAfterStart.reduce((sum, s) => sum + s, 0) +\n (sizesAfterStart.length - 1) * gap;\n\n if (targetSize <= sizesAfterStart[0] + gap) {\n return 1;\n }\n\n if (Math.trunc(targetSize) > Math.trunc(availableSize)) {\n const remainingSize = targetSize - availableSize;\n\n const additionalSpan = Math.ceil(remainingSize / (minSize + gap));\n newSpan = sizesAfterStart.length + additionalSpan;\n return isRow ? newSpan : Math.min(entries.length, newSpan);\n }\n\n for (let i = tilePosition.start - 1; i < entries.length; i++) {\n const currentSize = entries[i];\n const nextSize = entries[i + 1] ?? currentSize;\n\n const halfwayPoint = accumulatedSize + currentSize + gap + nextSize / 2;\n\n if (targetSize > halfwayPoint) {\n newSpan = i + 3 - tilePosition.start;\n } else {\n break;\n }\n\n accumulatedSize += currentSize + gap;\n }\n\n return newSpan;\n}\n\nexport function calculatePosition(\n targetPosition: number,\n sizes: number[],\n gap: number\n): number {\n let accumulatedSize = 0;\n\n for (const [i, size] of sizes.entries()) {\n accumulatedSize += size + gap;\n\n if (Math.trunc(targetPosition) < Math.trunc(accumulatedSize - gap)) {\n return i + 1;\n }\n }\n\n return 1;\n}\n"]}
@@ -12,7 +12,7 @@ export interface SerializedTile {
12
12
  id: string | null;
13
13
  }
14
14
  declare class TileManagerSerializer {
15
- tileManager: IgcTileManagerComponent;
15
+ private readonly _tileManager;
16
16
  constructor(tileManager: IgcTileManagerComponent);
17
17
  save(): SerializedTile[];
18
18
  saveAsJSON(): string;
@@ -1,9 +1,9 @@
1
1
  class TileManagerSerializer {
2
2
  constructor(tileManager) {
3
- this.tileManager = tileManager;
3
+ this._tileManager = tileManager;
4
4
  }
5
5
  save() {
6
- return this.tileManager.tiles.map((tile) => {
6
+ return this._tileManager.tiles.map((tile) => {
7
7
  return {
8
8
  colSpan: tile.colSpan,
9
9
  colStart: tile.colStart,
@@ -23,18 +23,17 @@ class TileManagerSerializer {
23
23
  }
24
24
  load(tiles) {
25
25
  const mapped = new Map(tiles.map((tile) => [tile.id, tile]));
26
- for (const tile of this.tileManager.tiles) {
27
- if (!mapped.has(tile.id)) {
28
- continue;
29
- }
26
+ for (const tile of this._tileManager.tiles) {
30
27
  const serialized = mapped.get(tile.id);
31
- Object.assign(tile, serialized);
28
+ if (serialized) {
29
+ Object.assign(tile, serialized);
30
+ }
32
31
  }
33
32
  }
34
33
  loadFromJSON(data) {
35
- if (!data)
36
- return;
37
- this.load(JSON.parse(data));
34
+ if (data) {
35
+ this.load(JSON.parse(data));
36
+ }
38
37
  }
39
38
  }
40
39
  export function createSerializer(host) {
@@ -1 +1 @@
1
- {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../../src/components/tile-manager/serializer.ts"],"names":[],"mappings":"AAeA,MAAM,qBAAqB;IAGzB,YAAY,WAAoC;QAC9C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACzC,OAAO;gBACL,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;gBACzC,eAAe,EAAE,IAAI,CAAC,eAAe;gBACrC,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,EAAE,EAAE,IAAI,CAAC,EAAE;aACZ,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,UAAU;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACrC,CAAC;IAEM,IAAI,CAAC,KAAuB;QACjC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAE7D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;gBACzB,SAAS;YACX,CAAC;YAED,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAE,CAAC;YAExC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAEM,YAAY,CAAC,IAAY;QAC9B,IAAI,CAAC,IAAI;YAAE,OAAO;QAElB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,UAAU,gBAAgB,CAAC,IAA6B;IAC5D,OAAO,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import type IgcTileManagerComponent from './tile-manager.js';\n\nexport interface SerializedTile {\n colSpan: number;\n colStart: number | null;\n disableFullscreen: boolean;\n disableMaximize: boolean;\n disableResize: boolean;\n maximized: boolean;\n position: number;\n rowSpan: number;\n rowStart: number | null;\n id: string | null;\n}\n\nclass TileManagerSerializer {\n public tileManager: IgcTileManagerComponent;\n\n constructor(tileManager: IgcTileManagerComponent) {\n this.tileManager = tileManager;\n }\n\n public save(): SerializedTile[] {\n return this.tileManager.tiles.map((tile) => {\n return {\n colSpan: tile.colSpan,\n colStart: tile.colStart,\n disableFullscreen: tile.disableFullscreen,\n disableMaximize: tile.disableMaximize,\n disableResize: tile.disableResize,\n maximized: tile.maximized,\n position: tile.position,\n rowSpan: tile.rowSpan,\n rowStart: tile.rowStart,\n id: tile.id,\n };\n });\n }\n\n public saveAsJSON(): string {\n return JSON.stringify(this.save());\n }\n\n public load(tiles: SerializedTile[]): void {\n const mapped = new Map(tiles.map((tile) => [tile.id, tile]));\n\n for (const tile of this.tileManager.tiles) {\n if (!mapped.has(tile.id)) {\n continue;\n }\n\n const serialized = mapped.get(tile.id)!;\n\n Object.assign(tile, serialized);\n }\n }\n\n public loadFromJSON(data: string): void {\n if (!data) return;\n\n this.load(JSON.parse(data));\n }\n}\n\nexport function createSerializer(host: IgcTileManagerComponent) {\n return new TileManagerSerializer(host);\n}\n"]}
1
+ {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../../src/components/tile-manager/serializer.ts"],"names":[],"mappings":"AAeA,MAAM,qBAAqB;IAGzB,YAAY,WAAoC;QAC9C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAC1C,OAAO;gBACL,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;gBACzC,eAAe,EAAE,IAAI,CAAC,eAAe;gBACrC,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,EAAE,EAAE,IAAI,CAAC,EAAE;aACZ,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,UAAU;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACrC,CAAC;IAEM,IAAI,CAAC,KAAuB;QACjC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAE7D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YAC3C,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAEvC,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;IACH,CAAC;IAEM,YAAY,CAAC,IAAY;QAC9B,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,gBAAgB,CAAC,IAA6B;IAC5D,OAAO,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import type IgcTileManagerComponent from './tile-manager.js';\n\nexport interface SerializedTile {\n colSpan: number;\n colStart: number | null;\n disableFullscreen: boolean;\n disableMaximize: boolean;\n disableResize: boolean;\n maximized: boolean;\n position: number;\n rowSpan: number;\n rowStart: number | null;\n id: string | null;\n}\n\nclass TileManagerSerializer {\n private readonly _tileManager: IgcTileManagerComponent;\n\n constructor(tileManager: IgcTileManagerComponent) {\n this._tileManager = tileManager;\n }\n\n public save(): SerializedTile[] {\n return this._tileManager.tiles.map((tile) => {\n return {\n colSpan: tile.colSpan,\n colStart: tile.colStart,\n disableFullscreen: tile.disableFullscreen,\n disableMaximize: tile.disableMaximize,\n disableResize: tile.disableResize,\n maximized: tile.maximized,\n position: tile.position,\n rowSpan: tile.rowSpan,\n rowStart: tile.rowStart,\n id: tile.id,\n };\n });\n }\n\n public saveAsJSON(): string {\n return JSON.stringify(this.save());\n }\n\n public load(tiles: SerializedTile[]): void {\n const mapped = new Map(tiles.map((tile) => [tile.id, tile]));\n\n for (const tile of this._tileManager.tiles) {\n const serialized = mapped.get(tile.id);\n\n if (serialized) {\n Object.assign(tile, serialized);\n }\n }\n }\n\n public loadFromJSON(data: string): void {\n if (data) {\n this.load(JSON.parse(data));\n }\n }\n}\n\nexport function createSerializer(host: IgcTileManagerComponent) {\n return new TileManagerSerializer(host);\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  import { css } from 'lit';
2
- export const styles = css `[part~=drag-over]::after,[part~=base]::after{content:"";position:absolute;pointer-events:none;inset:0;width:100%;height:100%;border-radius:inherit}:host{--component-size: var(--ig-size, var(--default-size));--_border-radius: var(--border-radius)}[part~=base]{background:var(--tile-background);border-radius:var(--_border-radius);box-shadow:var(--resting-elevation)}[part~=base]::after{border:.0625rem solid var(--border-color)}[part~=base]:not([part~=resizable]):hover::after{border:.0625rem solid var(--hover-border-color)}:host([part=resizing]),:host([part=dragging]){border-radius:var(--border-radius)}:host([part=dragging]){background:var(--placeholder-background);border:.0625rem solid var(--ghost-border)}[part~=base][part~=resizing]{opacity:.3}[part=content-container]{background:var(--content-background);color:var(--content-color)}[part=ghost]{border-radius:var(--border-radius);border:.0625rem solid var(--ghost-border);background:var(--overlay-background)}[part~=drag-over]::after{z-index:1000;border:.0625rem solid var(--ghost-border);background:var(--overlay-background)}[part=header]{background:var(--header-background);border-top-left-radius:var(--_border-radius);border-top-right-radius:var(--_border-radius)}[part=title]{color:var(--title-color)}igc-divider{--color: var(--divider-color)}igc-resize{--resize-indicator: var(--ghost-border)}igc-resize[part~=side-adorner]::part(trigger-side){background-color:rgba(0,0,0,0);right:0}igc-resize[part~=corner-adorner]::part(trigger){background-color:rgba(0,0,0,0);right:0;bottom:0}igc-resize[part~=bottom-adorner]::part(trigger-bottom){background-color:rgba(0,0,0,0);bottom:0}`;
2
+ export const styles = css `[part~=active]::after,[part~=drag-over]::after,[part~=base]::after{content:"";position:absolute;pointer-events:none;inset:0;width:100%;height:100%;border-radius:inherit}:host{--component-size: var(--ig-size, var(--default-size));--_border-radius: var(--border-radius)}[part~=base]{background:var(--tile-background);border-radius:var(--_border-radius);box-shadow:var(--resting-elevation)}[part~=base]::after{border:.0625rem solid var(--border-color)}[part~=base]:not([part~=resizable]):hover::after{border:.0625rem solid var(--hover-border-color)}:host([part=resizing]),:host([part=dragging]){border-radius:var(--border-radius)}:host([part=dragging]){background:var(--placeholder-background);border:.0625rem solid var(--ghost-border)}[part~=base][part~=resizing]{opacity:.3}[part=content-container]{background:var(--content-background);color:var(--content-color)}[part=ghost]{border-radius:var(--border-radius);border:.0625rem solid var(--ghost-border);background:var(--overlay-background)}[part~=drag-over]::after{z-index:1000;border:.0625rem solid var(--ghost-border);background:var(--overlay-background)}[part=header]{background:var(--header-background);border-top-left-radius:var(--_border-radius);border-top-right-radius:var(--_border-radius)}[part=title]{color:var(--title-color)}igc-divider{--color: var(--divider-color)}[part~=active]::after{border-radius:var(--_border-radius);border:.0625rem solid var(--ghost-border)}[part~=trigger-side],[part~=trigger],[part~=trigger-bottom]{width:var(--_size);aspect-ratio:1;border-radius:50%;z-index:11111;background-color:var(--ghost-border)}[part~=custom]{background-color:rgba(0,0,0,0)}[part~=trigger-side][part~=custom],[part~=trigger][part~=custom]{right:0}[part~=trigger][part~=custom],[part~=trigger-bottom][part~=custom]{bottom:0}`;
3
3
  //# sourceMappingURL=tile.common.css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tile.common.css.js","sourceRoot":"","sources":["../../../../../../src/components/tile-manager/themes/shared/tile/tile.common.css.ts"],"names":[],"mappings":"AACE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,umDAAumD,CAAC","sourcesContent":["\n import { css } from 'lit';\n export const styles = css`[part~=drag-over]::after,[part~=base]::after{content:\"\";position:absolute;pointer-events:none;inset:0;width:100%;height:100%;border-radius:inherit}:host{--component-size: var(--ig-size, var(--default-size));--_border-radius: var(--border-radius)}[part~=base]{background:var(--tile-background);border-radius:var(--_border-radius);box-shadow:var(--resting-elevation)}[part~=base]::after{border:.0625rem solid var(--border-color)}[part~=base]:not([part~=resizable]):hover::after{border:.0625rem solid var(--hover-border-color)}:host([part=resizing]),:host([part=dragging]){border-radius:var(--border-radius)}:host([part=dragging]){background:var(--placeholder-background);border:.0625rem solid var(--ghost-border)}[part~=base][part~=resizing]{opacity:.3}[part=content-container]{background:var(--content-background);color:var(--content-color)}[part=ghost]{border-radius:var(--border-radius);border:.0625rem solid var(--ghost-border);background:var(--overlay-background)}[part~=drag-over]::after{z-index:1000;border:.0625rem solid var(--ghost-border);background:var(--overlay-background)}[part=header]{background:var(--header-background);border-top-left-radius:var(--_border-radius);border-top-right-radius:var(--_border-radius)}[part=title]{color:var(--title-color)}igc-divider{--color: var(--divider-color)}igc-resize{--resize-indicator: var(--ghost-border)}igc-resize[part~=side-adorner]::part(trigger-side){background-color:rgba(0,0,0,0);right:0}igc-resize[part~=corner-adorner]::part(trigger){background-color:rgba(0,0,0,0);right:0;bottom:0}igc-resize[part~=bottom-adorner]::part(trigger-bottom){background-color:rgba(0,0,0,0);bottom:0}`;\n "]}
1
+ {"version":3,"file":"tile.common.css.js","sourceRoot":"","sources":["../../../../../../src/components/tile-manager/themes/shared/tile/tile.common.css.ts"],"names":[],"mappings":"AACE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,2vDAA2vD,CAAC","sourcesContent":["\n import { css } from 'lit';\n export const styles = css`[part~=active]::after,[part~=drag-over]::after,[part~=base]::after{content:\"\";position:absolute;pointer-events:none;inset:0;width:100%;height:100%;border-radius:inherit}:host{--component-size: var(--ig-size, var(--default-size));--_border-radius: var(--border-radius)}[part~=base]{background:var(--tile-background);border-radius:var(--_border-radius);box-shadow:var(--resting-elevation)}[part~=base]::after{border:.0625rem solid var(--border-color)}[part~=base]:not([part~=resizable]):hover::after{border:.0625rem solid var(--hover-border-color)}:host([part=resizing]),:host([part=dragging]){border-radius:var(--border-radius)}:host([part=dragging]){background:var(--placeholder-background);border:.0625rem solid var(--ghost-border)}[part~=base][part~=resizing]{opacity:.3}[part=content-container]{background:var(--content-background);color:var(--content-color)}[part=ghost]{border-radius:var(--border-radius);border:.0625rem solid var(--ghost-border);background:var(--overlay-background)}[part~=drag-over]::after{z-index:1000;border:.0625rem solid var(--ghost-border);background:var(--overlay-background)}[part=header]{background:var(--header-background);border-top-left-radius:var(--_border-radius);border-top-right-radius:var(--_border-radius)}[part=title]{color:var(--title-color)}igc-divider{--color: var(--divider-color)}[part~=active]::after{border-radius:var(--_border-radius);border:.0625rem solid var(--ghost-border)}[part~=trigger-side],[part~=trigger],[part~=trigger-bottom]{width:var(--_size);aspect-ratio:1;border-radius:50%;z-index:11111;background-color:var(--ghost-border)}[part~=custom]{background-color:rgba(0,0,0,0)}[part~=trigger-side][part~=custom],[part~=trigger][part~=custom]{right:0}[part~=trigger][part~=custom],[part~=trigger-bottom][part~=custom]{bottom:0}`;\n "]}
@@ -1,3 +1,3 @@
1
1
  import { css } from 'lit';
2
- export const styles = css `:host{--is-large: clamp(0, (var(--component-size, 1) + 1) - var(--ig-size-large, 3), 1);--is-medium: min( clamp(0, (var(--component-size, 1) + 1) - var(--ig-size-medium, 2), 1), clamp(0, var(--ig-size-large, 3) - var(--component-size, 1), 1) );--is-small: clamp(0, var(--ig-size-medium) - var(--component-size, 1), 1);position:relative;box-sizing:border-box;scrollbar-width:var(--ig-scrollbar-size, var(--sb-size));scrollbar-color:var(--ig-scrollbar-thumb-background, var(--sb-thumb-bg-color)) var(--ig-scrollbar-track-background, var(--sb-track-bg-color))}:host ::-webkit-scrollbar{width:var(--ig-scrollbar-size, var(--sb-size));height:var(--ig-scrollbar-size, var(--sb-size));background:var(--ig-scrollbar-track-background, var(--sb-track-bg-color))}:host ::-webkit-scrollbar-thumb{background:var(--ig-scrollbar-thumb-background, var(--sb-thumb-bg-color))}:host *,:host *::before,:host *::after{box-sizing:border-box}:host([hidden]),[hidden]{display:none !important}:host{--pad-block: max(var(--is-large, 1) * max(0.8125rem, -1 * 0.8125rem), var(--is-medium, 1) * max(0.8125rem, -1 * 0.8125rem), var(--is-small, 1) * max(0.5rem, -1 * 0.5rem));--pad-inline: max(var(--is-large, 1) * max(1.25rem, -1 * 1.25rem), var(--is-medium, 1) * max(1rem, -1 * 1rem), var(--is-small, 1) * max(0.75rem, -1 * 0.75rem));display:block;position:relative;grid-column:var(--ig-col-start, auto)/span var(--ig-col-span, 1);grid-row:var(--ig-row-start, auto)/span var(--ig-row-span, 1)}:host([part=resizing]) igc-resize,:host([part=dragging]) igc-resize{--resize-visibility: hidden}:host([part=resizing]) igc-resize::part(active)::after,:host([part=dragging]) igc-resize::part(active)::after{border:none}[part~=tile-container]{width:100%;height:100%}[part~=base]{width:100%;height:100%;overflow:hidden}[part=content-container]{display:block;border-radius:inherit}[part=content-container] ::slotted(*){font-family:var(--ig-body-1-font-family, var(--ig-font-family));font-size:var(--ig-body-1-font-size);font-weight:var(--ig-body-1-font-weight);font-style:var(--ig-body-1-font-style);line-height:var(--ig-body-1-line-height);letter-spacing:var(--ig-body-1-letter-spacing);text-transform:var(--ig-body-1-text-transform);margin-top:var(--ig-body-1-margin-top);margin-bottom:var(--ig-body-1-margin-bottom);margin:0}:host([maximized]){position:absolute;inset:0;width:100%;height:100%;z-index:10;grid-column:unset;grid-row:unset}:host([maximized]) [part~=base]{width:100%;height:100%}[part=ghost]{position:absolute;top:0;left:0;width:100%;height:100%;transform:scale(0);z-index:10}[part=header]{display:flex;align-items:center;gap:max(var(--is-large, 1)*max(1rem, -1 * 1rem),var(--is-medium, 1)*max(1rem, -1 * 1rem),var(--is-small, 1)*max(0.75rem, -1 * 0.75rem));width:100%;padding-block:var(--pad-block);padding-inline:var(--pad-inline)}:host([disable-fullscreen][disable-maximize]) igc-divider{display:none}[part=title]{display:flex;flex-direction:column;justify-content:center;flex:1 0 0%;overflow:hidden;min-width:2ch}::slotted([slot=title]){font-family:var(--ig-h6-font-family, var(--ig-font-family));font-size:var(--ig-h6-font-size);font-weight:var(--ig-h6-font-weight);font-style:var(--ig-h6-font-style);line-height:var(--ig-h6-line-height);letter-spacing:var(--ig-h6-letter-spacing);text-transform:var(--ig-h6-text-transform);margin-top:var(--ig-h6-margin-top);margin-bottom:var(--ig-h6-margin-bottom);white-space:nowrap;text-overflow:ellipsis;overflow:hidden;width:100%;min-width:2ch;margin-bottom:0;display:block}[part=actions]{display:flex;gap:.5rem;margin-inline-start:auto;flex-shrink:0}`;
2
+ export const styles = css `:host{--is-large: clamp(0, (var(--component-size, 1) + 1) - var(--ig-size-large, 3), 1);--is-medium: min( clamp(0, (var(--component-size, 1) + 1) - var(--ig-size-medium, 2), 1), clamp(0, var(--ig-size-large, 3) - var(--component-size, 1), 1) );--is-small: clamp(0, var(--ig-size-medium) - var(--component-size, 1), 1);position:relative;box-sizing:border-box;scrollbar-width:var(--ig-scrollbar-size, var(--sb-size));scrollbar-color:var(--ig-scrollbar-thumb-background, var(--sb-thumb-bg-color)) var(--ig-scrollbar-track-background, var(--sb-track-bg-color))}:host ::-webkit-scrollbar{width:var(--ig-scrollbar-size, var(--sb-size));height:var(--ig-scrollbar-size, var(--sb-size));background:var(--ig-scrollbar-track-background, var(--sb-track-bg-color))}:host ::-webkit-scrollbar-thumb{background:var(--ig-scrollbar-thumb-background, var(--sb-thumb-bg-color))}:host *,:host *::before,:host *::after{box-sizing:border-box}:host([hidden]),[hidden]{display:none !important}:host{--pad-block: max(var(--is-large, 1) * max(0.8125rem, -1 * 0.8125rem), var(--is-medium, 1) * max(0.8125rem, -1 * 0.8125rem), var(--is-small, 1) * max(0.5rem, -1 * 0.5rem));--pad-inline: max(var(--is-large, 1) * max(1.25rem, -1 * 1.25rem), var(--is-medium, 1) * max(1rem, -1 * 1rem), var(--is-small, 1) * max(0.75rem, -1 * 0.75rem));display:block;position:relative;grid-column:var(--ig-col-start, auto)/span var(--ig-col-span, 1);grid-row:var(--ig-row-start, auto)/span var(--ig-row-span, 1)}:host([part=resizing]) [part~=trigger-side],:host([part=resizing]) [part~=trigger],:host([part=resizing]) [part~=trigger-bottom],:host([part=dragging]) [part~=trigger-side],:host([part=dragging]) [part~=trigger],:host([part=dragging]) [part~=trigger-bottom]{visibility:hidden}:host([part=resizing]) [part~=active]::after,:host([part=dragging]) [part~=active]::after{border:none}[part~=tile-container]{position:relative;width:100%;height:100%}[part~=trigger-side],[part~=trigger],[part~=trigger-bottom]{--_size: 0.6875rem;display:inline-flex;position:absolute;z-index:1}[part~=trigger-side]{top:calc(50% - var(--_size));right:calc(var(--_size)/2*-1);cursor:e-resize}[part~=trigger]{bottom:calc(var(--_size)/2*-1);right:calc(var(--_size)/2*-1);cursor:se-resize}[part~=trigger-bottom]{left:calc(50% - var(--_size));bottom:calc(var(--_size)/2*-1);cursor:s-resize}[part~=trigger]:focus{outline:none}[part~=base]{width:100%;height:100%;overflow:hidden}[part=content-container]{display:block;border-radius:inherit}[part=content-container] ::slotted(*){font-family:var(--ig-body-1-font-family, var(--ig-font-family));font-size:var(--ig-body-1-font-size);font-weight:var(--ig-body-1-font-weight);font-style:var(--ig-body-1-font-style);line-height:var(--ig-body-1-line-height);letter-spacing:var(--ig-body-1-letter-spacing);text-transform:var(--ig-body-1-text-transform);margin-top:var(--ig-body-1-margin-top);margin-bottom:var(--ig-body-1-margin-bottom);margin:0}:host([maximized]){position:absolute;inset:0;width:100%;height:100%;z-index:10;grid-column:unset;grid-row:unset}:host([maximized]) [part~=base]{width:100%;height:100%}[part=ghost]{position:absolute;top:0;left:0;width:100%;height:100%;transform:scale(0);z-index:10}[part=header]{display:flex;align-items:center;gap:max(var(--is-large, 1)*max(1rem, -1 * 1rem),var(--is-medium, 1)*max(1rem, -1 * 1rem),var(--is-small, 1)*max(0.75rem, -1 * 0.75rem));width:100%;padding-block:var(--pad-block);padding-inline:var(--pad-inline)}:host([disable-fullscreen][disable-maximize]) igc-divider{display:none}[part=title]{display:flex;flex-direction:column;justify-content:center;flex:1 0 0%;overflow:hidden;min-width:2ch}::slotted([slot=title]){font-family:var(--ig-h6-font-family, var(--ig-font-family));font-size:var(--ig-h6-font-size);font-weight:var(--ig-h6-font-weight);font-style:var(--ig-h6-font-style);line-height:var(--ig-h6-line-height);letter-spacing:var(--ig-h6-letter-spacing);text-transform:var(--ig-h6-text-transform);margin-top:var(--ig-h6-margin-top);margin-bottom:var(--ig-h6-margin-bottom);white-space:nowrap;text-overflow:ellipsis;overflow:hidden;width:100%;min-width:2ch;margin-bottom:0;display:block}[part=actions]{display:flex;gap:.5rem;margin-inline-start:auto;flex-shrink:0}`;
3
3
  //# sourceMappingURL=tile.base.css.js.map