eru-grid 0.0.42 → 0.0.44

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.
@@ -126,6 +126,46 @@ function normalizeDatatype(datatype) {
126
126
  const key = String(datatype ?? '');
127
127
  return DATATYPE_ALIASES[key] ?? key;
128
128
  }
129
+ /** Shown when a value has no colour of its own. */
130
+ const STATUS_PILL_FALLBACK = {
131
+ background: 'white',
132
+ border: 'black',
133
+ text: 'black',
134
+ };
135
+ /**
136
+ * The colours for a status pill, from the single colour the data model gives it.
137
+ *
138
+ * The fill is lightened 90% toward white and the text darkened 30%, with the
139
+ * border left at full saturation. That is what keeps a pale palette entry
140
+ * readable: using the raw colour as text on a tint of itself puts same-hue on
141
+ * same-hue, and the pale half of a palette becomes unreadable.
142
+ *
143
+ * Exported from here — rather than living in the grid's status cell where it
144
+ * started — because eru-studio's status badge and chip list paint the same
145
+ * values, and three copies of this arithmetic is three ways for one field to
146
+ * look different depending on which control renders it.
147
+ */
148
+ function statusPillColors(color) {
149
+ const hex = String(color ?? '').replace('#', '');
150
+ const expanded = hex.length === 3 ? hex.split('').map(c => c + c).join('') : hex;
151
+ if (expanded.length !== 6)
152
+ return { ...STATUS_PILL_FALLBACK };
153
+ const value = parseInt(expanded, 16);
154
+ if (isNaN(value))
155
+ return { ...STATUS_PILL_FALLBACK };
156
+ const r = (value >> 16) & 255;
157
+ const g = (value >> 8) & 255;
158
+ const b = value & 255;
159
+ const lighten = 0.9;
160
+ const darken = 0.3;
161
+ const lit = (channel) => Math.min(255, Math.round(channel + (255 - channel) * lighten));
162
+ const dark = (channel) => Math.round(channel * (1 - darken));
163
+ return {
164
+ background: `rgb(${lit(r)}, ${lit(g)}, ${lit(b)})`,
165
+ border: `#${expanded}`,
166
+ text: `rgb(${dark(r)}, ${dark(g)}, ${dark(b)})`,
167
+ };
168
+ }
129
169
  /** Short month names, for the `MMM` token. */
130
170
  const MONTH_SHORT_NAMES = [
131
171
  'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
@@ -4632,21 +4672,21 @@ function abbreviateNumber$1(num, system, decimals) {
4632
4672
  };
4633
4673
  if (system === 'lacs') {
4634
4674
  if (abs >= 1e7)
4635
- return `${sign}${trim(abs / 1e7)}Cr`;
4675
+ return `${sign}${trim(abs / 1e7)} Cr`;
4636
4676
  if (abs >= 1e5)
4637
- return `${sign}${trim(abs / 1e5)}L`;
4677
+ return `${sign}${trim(abs / 1e5)} L`;
4638
4678
  if (abs >= 1e3)
4639
- return `${sign}${trim(abs / 1e3)}k`;
4679
+ return `${sign}${trim(abs / 1e3)} k`;
4640
4680
  return `${sign}${trim(abs)}`;
4641
4681
  }
4642
4682
  if (abs >= 1e12)
4643
- return `${sign}${trim(abs / 1e12)}tn`;
4683
+ return `${sign}${trim(abs / 1e12)} tn`;
4644
4684
  if (abs >= 1e9)
4645
- return `${sign}${trim(abs / 1e9)}bn`;
4685
+ return `${sign}${trim(abs / 1e9)} bn`;
4646
4686
  if (abs >= 1e6)
4647
- return `${sign}${trim(abs / 1e6)}mn`;
4687
+ return `${sign}${trim(abs / 1e6)} mn`;
4648
4688
  if (abs >= 1e3)
4649
- return `${sign}${trim(abs / 1e3)}k`;
4689
+ return `${sign}${trim(abs / 1e3)} k`;
4650
4690
  return `${sign}${trim(abs)}`;
4651
4691
  }
4652
4692
  class CurrencyComponent {
@@ -4870,21 +4910,21 @@ function abbreviateNumber(num, system, decimals) {
4870
4910
  };
4871
4911
  if (system === 'lacs') {
4872
4912
  if (abs >= 1e7)
4873
- return `${sign}${trim(abs / 1e7)}Cr`;
4913
+ return `${sign}${trim(abs / 1e7)} Cr`;
4874
4914
  if (abs >= 1e5)
4875
- return `${sign}${trim(abs / 1e5)}L`;
4915
+ return `${sign}${trim(abs / 1e5)} L`;
4876
4916
  if (abs >= 1e3)
4877
- return `${sign}${trim(abs / 1e3)}k`;
4917
+ return `${sign}${trim(abs / 1e3)} k`;
4878
4918
  return `${sign}${trim(abs)}`;
4879
4919
  }
4880
4920
  if (abs >= 1e12)
4881
- return `${sign}${trim(abs / 1e12)}tn`;
4921
+ return `${sign}${trim(abs / 1e12)} tn`;
4882
4922
  if (abs >= 1e9)
4883
- return `${sign}${trim(abs / 1e9)}bn`;
4923
+ return `${sign}${trim(abs / 1e9)} bn`;
4884
4924
  if (abs >= 1e6)
4885
- return `${sign}${trim(abs / 1e6)}mn`;
4925
+ return `${sign}${trim(abs / 1e6)} mn`;
4886
4926
  if (abs >= 1e3)
4887
- return `${sign}${trim(abs / 1e3)}k`;
4927
+ return `${sign}${trim(abs / 1e3)} k`;
4888
4928
  return `${sign}${trim(abs)}`;
4889
4929
  }
4890
4930
  class NumberComponent {
@@ -8244,51 +8284,12 @@ class StatusComponent {
8244
8284
  }
8245
8285
  }
8246
8286
  getStatusColor(statusName) {
8247
- const cfg = this.config();
8248
- if (!cfg || !cfg.options) {
8249
- return {
8250
- background: 'white',
8251
- border: 'black',
8252
- text: 'black'
8253
- };
8254
- }
8255
- const options = cfg.options || [];
8256
- // Find option by name (status value matches option.name)
8257
- const statusOption = options.find((opt) => {
8258
- return opt.name === statusName;
8259
- });
8260
- if (!statusOption || !statusOption.color) {
8261
- return {
8262
- background: 'white',
8263
- border: 'black',
8264
- text: 'black'
8265
- };
8266
- }
8267
- // Advanced color manipulation function for rounded rectangle display
8268
- const manipulateColor = (color) => {
8269
- // Convert hex to RGB
8270
- const hex = color.replace('#', '');
8271
- const bigint = parseInt(hex, 16);
8272
- const r = (bigint >> 16) & 255;
8273
- const g = (bigint >> 8) & 255;
8274
- const b = bigint & 255;
8275
- // Create lighter background
8276
- const lightenFactor = 0.9; // 90% lighter
8277
- const bgR = Math.min(255, Math.round(r + (255 - r) * lightenFactor));
8278
- const bgG = Math.min(255, Math.round(g + (255 - g) * lightenFactor));
8279
- const bgB = Math.min(255, Math.round(b + (255 - b) * lightenFactor));
8280
- // Darken text color
8281
- const darkenFactor = 0.3; // 30% darker
8282
- const textR = Math.round(r * (1 - darkenFactor));
8283
- const textG = Math.round(g * (1 - darkenFactor));
8284
- const textB = Math.round(b * (1 - darkenFactor));
8285
- return {
8286
- background: `rgb(${bgR}, ${bgG}, ${bgB})`,
8287
- border: color,
8288
- text: `rgb(${textR}, ${textG}, ${textB})`
8289
- };
8290
- };
8291
- return manipulateColor(statusOption.color);
8287
+ const options = this.config()?.options || [];
8288
+ // Status value matches option.name.
8289
+ const statusOption = options.find((opt) => opt.name === statusName);
8290
+ // statusPillColors returns the neutral fallback for a missing colour, so the
8291
+ // no-option and no-colour cases need no separate handling here.
8292
+ return statusPillColors(statusOption?.color);
8292
8293
  }
8293
8294
  getStatusButtonDisplay(statusName) {
8294
8295
  const cfg = this.config();
@@ -14720,5 +14721,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImpor
14720
14721
  * Generated bundle index. Do not edit.
14721
14722
  */
14722
14723
 
14723
- export { AttachmentComponent, CheckboxComponent, ColumnConstraintsService, CurrencyComponent, CustomVirtualScrollStrategy, DATA_TYPES, DATETIME_FORMATS, DATE_FORMATS, DateComponent, DatetimeComponent, DurationComponent, EmailComponent, EruGridComponent, EruGridService, EruGridStore, INHERITED_FIELD_KEYS, LocationComponent, MATERIAL_MODULES, MATERIAL_PROVIDERS, MONTH_SHORT_NAMES, NumberComponent, PRESET_CONFIG_DEFAULTS, PRESET_MANAGED_FIELDS, PeopleComponent, PhoneComponent, PriorityComponent, ProgressComponent, RatingComponent, SelectComponent, StatusComponent, TagComponent, TextareaComponent, TextboxComponent, ThemeService, ThemeToggleComponent, WebsiteComponent, evaluateRowCondition, formatDateWithPattern, matchColorRange, normalizeDatatype, normalizeDateFormat, normalizeDateTimeFormat, parseDateWithPattern, resolveRowValue };
14724
+ export { AttachmentComponent, CheckboxComponent, ColumnConstraintsService, CurrencyComponent, CustomVirtualScrollStrategy, DATA_TYPES, DATETIME_FORMATS, DATE_FORMATS, DateComponent, DatetimeComponent, DurationComponent, EmailComponent, EruGridComponent, EruGridService, EruGridStore, INHERITED_FIELD_KEYS, LocationComponent, MATERIAL_MODULES, MATERIAL_PROVIDERS, MONTH_SHORT_NAMES, NumberComponent, PRESET_CONFIG_DEFAULTS, PRESET_MANAGED_FIELDS, PeopleComponent, PhoneComponent, PriorityComponent, ProgressComponent, RatingComponent, SelectComponent, StatusComponent, TagComponent, TextareaComponent, TextboxComponent, ThemeService, ThemeToggleComponent, WebsiteComponent, evaluateRowCondition, formatDateWithPattern, matchColorRange, normalizeDatatype, normalizeDateFormat, normalizeDateTimeFormat, parseDateWithPattern, resolveRowValue, statusPillColors };
14724
14725
  //# sourceMappingURL=eru-grid.mjs.map