@mk-kit/ui 0.43.0 → 0.45.0
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.
- package/README.md +11 -0
- package/fesm2022/mk-kit-ui-core.mjs +30 -13
- package/fesm2022/mk-kit-ui-core.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-data.mjs +1 -1
- package/fesm2022/mk-kit-ui-data.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-directives.mjs +27 -8
- package/fesm2022/mk-kit-ui-directives.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-dnd.mjs +43 -8
- package/fesm2022/mk-kit-ui-dnd.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-forms.mjs +1 -1
- package/fesm2022/mk-kit-ui-forms.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-locales-pl.mjs +503 -0
- package/fesm2022/mk-kit-ui-locales-pl.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-media.mjs +1 -1
- package/fesm2022/mk-kit-ui-media.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-table.mjs +658 -22
- package/fesm2022/mk-kit-ui-table.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-testing.mjs +54 -0
- package/fesm2022/mk-kit-ui-testing.mjs.map +1 -1
- package/package.json +5 -1
- package/types/mk-kit-ui-core.d.ts +36 -10
- package/types/mk-kit-ui-directives.d.ts +12 -6
- package/types/mk-kit-ui-dnd.d.ts +32 -4
- package/types/mk-kit-ui-locales-pl.d.ts +42 -0
- package/types/mk-kit-ui-table.d.ts +234 -8
- package/types/mk-kit-ui-testing.d.ts +16 -0
|
@@ -1889,30 +1889,37 @@ const formatters = new MkIntlCache((locale, options) => new Intl.RelativeTimeFor
|
|
|
1889
1889
|
* The pipe picks the largest unit whose magnitude is at least 1 (seconds →
|
|
1890
1890
|
* minutes → hours → days → weeks → months → years) and rounds. Pass `now`
|
|
1891
1891
|
* for deterministic output in tests, or bind a ticking signal to keep a
|
|
1892
|
-
* list live — a pure pipe only re-runs when an argument changes
|
|
1892
|
+
* list live — a pure pipe only re-runs when an argument changes. The second
|
|
1893
|
+
* argument is either that `now` or the options object, so options alone
|
|
1894
|
+
* need no `null` placeholder; the three-argument form (`now`, then options)
|
|
1895
|
+
* works too:
|
|
1893
1896
|
*
|
|
1894
1897
|
* ```html
|
|
1895
1898
|
* {{ comment.createdAt | mkRelativeTime }} <!-- 3 minutes ago -->
|
|
1896
1899
|
* {{ due | mkRelativeTime:now() }} <!-- in 2 days (now() ticks) -->
|
|
1897
|
-
* {{ due | mkRelativeTime:
|
|
1898
|
-
* {{ ts | mkRelativeTime:
|
|
1900
|
+
* {{ due | mkRelativeTime:{ style: 'short' } }} <!-- in 2 days -->
|
|
1901
|
+
* {{ ts | mkRelativeTime:{ locale: 'pl', numeric: 'always' } }} <!-- 3 minuty temu -->
|
|
1902
|
+
* {{ due | mkRelativeTime:now():{ style: 'short' } }} <!-- in 2 days (ticking) -->
|
|
1899
1903
|
* ```
|
|
1900
1904
|
*/
|
|
1901
1905
|
class MkRelativeTimePipe {
|
|
1902
1906
|
i18n = inject(MK_I18N);
|
|
1903
1907
|
/**
|
|
1904
1908
|
* @param value The instant to describe.
|
|
1905
|
-
* @param
|
|
1906
|
-
*
|
|
1909
|
+
* @param nowOrOptions Reference instant (defaults to `Date.now()` at call
|
|
1910
|
+
* time), or — when only options are wanted — the options object itself.
|
|
1911
|
+
* @param options Locale, numeric mode, style and unit cap (three-argument
|
|
1912
|
+
* form, after an explicit `now`).
|
|
1907
1913
|
*/
|
|
1908
|
-
transform(value,
|
|
1914
|
+
transform(value, nowOrOptions, options) {
|
|
1909
1915
|
const target = mkToTimestamp(value);
|
|
1910
1916
|
if (target === null)
|
|
1911
1917
|
return '';
|
|
1918
|
+
const [now, opts] = splitArgs(nowOrOptions, options);
|
|
1912
1919
|
const reference = mkToTimestamp(now) ?? Date.now();
|
|
1913
1920
|
const diff = target - reference;
|
|
1914
|
-
const [unit, amount] = pickUnit(diff,
|
|
1915
|
-
const { locale, maxUnit: _maxUnit, ...rest } =
|
|
1921
|
+
const [unit, amount] = pickUnit(diff, opts.maxUnit ?? 'year');
|
|
1922
|
+
const { locale, maxUnit: _maxUnit, ...rest } = opts;
|
|
1916
1923
|
return formatters
|
|
1917
1924
|
.get(mkResolveLocale(this.i18n, locale), {
|
|
1918
1925
|
numeric: 'auto',
|
|
@@ -1928,6 +1935,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
1928
1935
|
type: Pipe,
|
|
1929
1936
|
args: [{ name: 'mkRelativeTime', pure: true }]
|
|
1930
1937
|
}] });
|
|
1938
|
+
/**
|
|
1939
|
+
* Resolve the overloaded second argument: a plain object (not a `Date`) is
|
|
1940
|
+
* the options and `now` is left to default; anything else is `now`.
|
|
1941
|
+
*/
|
|
1942
|
+
function splitArgs(nowOrOptions, options) {
|
|
1943
|
+
if (nowOrOptions !== null &&
|
|
1944
|
+
typeof nowOrOptions === 'object' &&
|
|
1945
|
+
!(nowOrOptions instanceof Date)) {
|
|
1946
|
+
return [undefined, { ...nowOrOptions, ...options }];
|
|
1947
|
+
}
|
|
1948
|
+
return [nowOrOptions, options ?? {}];
|
|
1949
|
+
}
|
|
1931
1950
|
/** Choose the largest unit (≤ `maxUnit`) whose rounded magnitude is ≥ 1; seconds otherwise. */
|
|
1932
1951
|
function pickUnit(diffMs, maxUnit) {
|
|
1933
1952
|
const cap = UNITS.findIndex(([u]) => u === maxUnit || `${u}s` === maxUnit);
|