impact-ui 4.0.1-alpha.22 → 4.0.1-alpha.24

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.
@@ -0,0 +1,33 @@
1
+ import { Locale } from '../../i18n/types';
2
+ import { MutableRefObject } from 'react';
3
+
4
+ export type AgGridLocaleText = Record<string, string>;
5
+ /**
6
+ * AG Grid bakes these pagination labels into the panel HTML at create time.
7
+ * Updating localeText/getLocaleText alone will not refresh them — we patch
8
+ * these keys into the DOM after setAgGridLocaleText().
9
+ */
10
+ export declare const AG_GRID_PAGINATION_LOCALE_KEYS: readonly ["page", "to", "of", "firstPage", "previousPage", "nextPage", "lastPage"];
11
+ export declare function getAgGridLocaleTextForLocale(locale: Locale): AgGridLocaleText;
12
+ /**
13
+ * Update the mutable key→value object that getLocaleText reads from.
14
+ * Call this when the app locale changes (instead of remounting the grid).
15
+ */
16
+ export declare function setAgGridLocaleText(localeTextRef: MutableRefObject<AgGridLocaleText>, locale: Locale): AgGridLocaleText;
17
+ interface GetLocaleTextParams {
18
+ key: string;
19
+ defaultValue: string;
20
+ variableValues?: string[];
21
+ }
22
+ /**
23
+ * AG Grid getLocaleText callback — looks up one key at a time from the
24
+ * object managed by setAgGridLocaleText.
25
+ */
26
+ export declare function createAgGridGetLocaleText(localeTextRef: MutableRefObject<AgGridLocaleText>): (params: GetLocaleTextParams) => string;
27
+ /**
28
+ * Apply the pagination keys from the current localeText object onto the
29
+ * already-rendered AG Grid paging panel (no grid remount).
30
+ */
31
+ export declare function syncAgGridPaginationLocale(container: HTMLElement | null, localeText: AgGridLocaleText | null | undefined): void;
32
+ export {};
33
+ //# sourceMappingURL=agGridLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agGridLocale.d.ts","sourceRoot":"","sources":["../../../src/components/Table/agGridLocale.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,oFAQjC,CAAC;AAEX,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAE7E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,EACjD,MAAM,EAAE,MAAM,GACb,gBAAgB,CAGlB;AAED,UAAU,mBAAmB;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,IAEzC,QAAQ,mBAAmB,KAAG,MAAM,CAuB7C;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,UAAU,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,GAC9C,IAAI,CA8BN"}
@@ -0,0 +1,63 @@
1
+ import { AGLocaleMap, BASE_LOCALE } from "../../locales/index.js";
2
+ function getAgGridLocaleTextForLocale(locale) {
3
+ var _a, _b;
4
+ return ((_a = AGLocaleMap) == null ? void 0 : _a[locale]) || ((_b = AGLocaleMap) == null ? void 0 : _b[BASE_LOCALE]) || {};
5
+ }
6
+ function setAgGridLocaleText(localeTextRef, locale) {
7
+ localeTextRef.current = getAgGridLocaleTextForLocale(locale);
8
+ return localeTextRef.current;
9
+ }
10
+ function createAgGridGetLocaleText(localeTextRef) {
11
+ return (params) => {
12
+ var _a;
13
+ let localisedText = (_a = localeTextRef.current) == null ? void 0 : _a[params.key];
14
+ if (localisedText == null) {
15
+ return params.defaultValue;
16
+ }
17
+ const variableValues = params.variableValues;
18
+ if (variableValues == null ? void 0 : variableValues.length) {
19
+ let found = 0;
20
+ while (found < variableValues.length) {
21
+ const idx = localisedText.indexOf("${variable}");
22
+ if (idx === -1) break;
23
+ localisedText = localisedText.slice(0, idx) + variableValues[found] + localisedText.slice(idx + "${variable}".length);
24
+ found += 1;
25
+ }
26
+ }
27
+ return localisedText;
28
+ };
29
+ }
30
+ function syncAgGridPaginationLocale(container, localeText) {
31
+ if (!container || !localeText) return;
32
+ container.querySelectorAll(".ag-paging-panel").forEach((panel) => {
33
+ const setByIdSuffix = (suffix, text) => {
34
+ if (text == null) return;
35
+ const el = panel.querySelector(`[id$="-${suffix}"]`);
36
+ if (el) el.textContent = text;
37
+ };
38
+ setByIdSuffix("to", localeText.to);
39
+ setByIdSuffix("of", localeText.of);
40
+ setByIdSuffix("start-page", localeText.page);
41
+ setByIdSuffix("of-page", localeText.of);
42
+ const buttons = panel.querySelectorAll(
43
+ ".ag-paging-page-summary-panel .ag-paging-button"
44
+ );
45
+ const buttonLabels = [
46
+ localeText.firstPage,
47
+ localeText.previousPage,
48
+ localeText.nextPage,
49
+ localeText.lastPage
50
+ ];
51
+ buttons.forEach((button, index) => {
52
+ if (buttonLabels[index]) {
53
+ button.setAttribute("aria-label", buttonLabels[index]);
54
+ }
55
+ });
56
+ });
57
+ }
58
+ export {
59
+ createAgGridGetLocaleText,
60
+ getAgGridLocaleTextForLocale,
61
+ setAgGridLocaleText,
62
+ syncAgGridPaginationLocale
63
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Table/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,sCAAsC,CAAC;AAC9C,OAAO,8CAA8C,CAAC;AACtD,OAAO,qBAAqB,CAAC;AAsmD7B,eAAO,MAAM,KAAK,mFAUhB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Table/index.tsx"],"names":[],"mappings":"AAuBA,OAAO,sCAAsC,CAAC;AAC9C,OAAO,8CAA8C,CAAC;AACtD,OAAO,qBAAqB,CAAC;AAsnD7B,eAAO,MAAM,KAAK,mFAUhB,CAAC"}