@neovici/cosmoz-omnitable 14.18.0 → 14.20.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.
@@ -1,2 +1,2 @@
1
- export function genericSorter(a: any, b: any): number;
1
+ export declare const genericSorter: (a: unknown, b: unknown) => number;
2
2
  //# sourceMappingURL=generic-sorter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generic-sorter.d.ts","sourceRoot":"","sources":["../../src/lib/generic-sorter.js"],"names":[],"mappings":"AACO,sDAiCN"}
1
+ {"version":3,"file":"generic-sorter.d.ts","sourceRoot":"","sources":["../../src/lib/generic-sorter.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,EAAE,GAAG,OAAO,WAoCnD,CAAC"}
@@ -12,21 +12,23 @@ const genericSorter = (a, b) => {
12
12
  if (b == null) {
13
13
  return 1;
14
14
  }
15
- if (typeof a === 'object' && typeof b === 'object') {
15
+ const typeA = typeof a;
16
+ const typeB = typeof b;
17
+ if (typeA === 'object' && typeB === 'object') {
16
18
  // HACK(pasleq): worst case, compare using values converted to string
17
19
  return a.toString() < b.toString() ? -1 : 1;
18
20
  }
19
- if (typeof a === 'number' && typeof b === 'number') {
21
+ if (typeA === 'number' && typeB === 'number') {
20
22
  return a - b;
21
23
  }
22
- if (typeof a === 'string' && typeof b === 'string') {
24
+ if (typeA === 'string' && typeB === 'string') {
23
25
  return a < b ? -1 : 1;
24
26
  }
25
- if (typeof a === 'boolean' && typeof b === 'boolean') {
27
+ if (typeA === 'boolean' && typeB === 'boolean') {
26
28
  return a ? -1 : 1;
27
29
  }
28
30
  // eslint-disable-next-line no-console
29
- console.warn('unsupported sort', typeof a, a, typeof b, b);
31
+ console.warn('unsupported sort', typeA, a, typeB, b);
30
32
  return 0;
31
33
  };
32
34
  exports.genericSorter = genericSorter;
@@ -1,2 +1,13 @@
1
- export function layout(columns: any, container: any): any[];
1
+ interface Column {
2
+ flex: number;
3
+ index: number;
4
+ minWidth: number;
5
+ width: number;
6
+ priority: number;
7
+ name: string;
8
+ }
9
+ type Columns = Column[];
10
+ export declare const // eslint-disable-next-line max-statements
11
+ layout: (columns: Columns, container: number) => number[];
12
+ export {};
2
13
  //# sourceMappingURL=layout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/lib/layout.js"],"names":[],"mappings":"AACO,4DA2DL"}
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/lib/layout.ts"],"names":[],"mappings":"AAAA,UAAU,MAAM;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,KAAK,OAAO,GAAG,MAAM,EAAE,CAAC;AAGxB,eAAO,MAAM,0CAA0C;AACtD,MAAM,GAAI,SAAS,OAAO,EAAE,WAAW,MAAM,aA0D5C,CAAC"}
@@ -5,12 +5,15 @@ export interface Amount {
5
5
  currency: Currency | string;
6
6
  }
7
7
  export type GetPath = string | (string | number)[];
8
- export interface NumberColumn {
8
+ export interface Column {
9
9
  valuePath?: GetPath;
10
10
  locale?: string;
11
+ }
12
+ export interface NumberColumn extends Column {
11
13
  minimumFractionDigits?: number | null;
12
14
  maximumFractionDigits?: number | null;
13
15
  }
16
+ export type DateColumn = Column;
14
17
  export interface Limit<T> {
15
18
  min: T;
16
19
  max: T;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAEzE,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAErD,MAAM,WAAW,MAAM;IACtB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;AAEnD,MAAM,WAAW,YAAY;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,KAAK,CAAC,CAAC;IACvB,GAAG,EAAE,CAAC,CAAC;IACP,GAAG,EAAE,CAAC,CAAC;CACP;AACD,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAExC,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAEzE,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAErD,MAAM,WAAW,MAAM;IACtB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;AAEnD,MAAM,WAAW,MAAM;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAa,SAAQ,MAAM;IAC3C,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,MAAM,WAAW,KAAK,CAAC,CAAC;IACvB,GAAG,EAAE,CAAC,CAAC;IACP,GAAG,EAAE,CAAC,CAAC;CACP;AACD,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAExC,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC"}
@@ -1,25 +1,16 @@
1
- export function getTimezoneString(localISOString: any): string;
2
- export function getAbsoluteISOString(localISOString: any): any;
3
- export function parseDate(value: any): any;
4
- export function getComparableValue({ valuePath }: {
5
- valuePath: any;
6
- }, item: any): number | undefined;
7
- export function toDate(value: any, limit: any, limitFunc: any): any;
8
- export function renderValue(value: any, formatter: any): any;
9
- export const formatters: {};
10
- export function getFormatter(locale: any): any;
11
- export function getString({ valuePath, locale }: {
12
- valuePath: any;
13
- locale: any;
14
- }, item: any): any;
15
- export function toInputString(value: any): string | null;
16
- export function getInputString({ valuePath }: {
17
- valuePath: any;
18
- }, item: any): string | null;
19
- export function fromInputString(value: any, property: any): any;
20
- export function toHashString(value: any): string;
21
- export function toXlsxValue({ valuePath }: {
22
- valuePath: any;
23
- }, item: any): any;
24
- export function applySingleFilter(column: any, filter: any): (item: any) => boolean;
1
+ import { DateColumn, Item, LimitFunction, Limit } from './types';
2
+ export declare const getTimezoneString: (localISOString: string) => string;
3
+ export declare const getAbsoluteISOString: (localISOString: string) => string;
4
+ export declare const parseDate: (value: unknown) => Date | null | undefined;
5
+ export declare const getComparableValue: <T extends DateColumn>({ valuePath }: T, item: Item) => number | undefined;
6
+ export declare const toDate: (value: unknown, limit?: unknown, limitFunc?: LimitFunction) => Date | null;
7
+ export declare const renderValue: (value: unknown, formatter?: Intl.DateTimeFormat) => string | undefined;
8
+ export declare const getFormatter: (locale?: string) => Intl.DateTimeFormat;
9
+ export declare const getString: <T extends DateColumn>({ valuePath, locale }: T, item: unknown) => string | undefined;
10
+ export declare const toInputString: (value: unknown) => string | null;
11
+ export declare const getInputString: ({ valuePath }: DateColumn, item: unknown) => string | null;
12
+ export declare const fromInputString: (value: unknown, property?: keyof Limit<Date>) => Date | undefined;
13
+ export declare const toHashString: (value: unknown) => string;
14
+ export declare const toXlsxValue: <T extends DateColumn>({ valuePath }: T, item: Item) => "" | Date;
15
+ export declare const applySingleFilter: (column: DateColumn, filter: Limit<Date | undefined>) => (item: Item) => boolean;
25
16
  //# sourceMappingURL=utils-date.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils-date.d.ts","sourceRoot":"","sources":["../../src/lib/utils-date.js"],"names":[],"mappings":"AAIO,+DA6LL;AA7LK,+DA6LL;AA7LK,2CA6LL;AA7LK;;kCA6LL;AA7LK,oEA6LL;AA7LK,6DA6LL;AA7ED,4BAAe;AAhHT,+CA6LL;AA7LK;;;mBA6LL;AA7LK,yDA6LL;AA7LK;;6BA6LL;AA7LK,gEA6LL;AA7LK,iDA6LL;AA7LK;;mBA6LL;AA7LK,8DAkLmC,SAAI,aAW5C"}
1
+ {"version":3,"file":"utils-date.d.ts","sourceRoot":"","sources":["../../src/lib/utils-date.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEjE,eAAO,MAAM,iBAAiB,GAAI,gBAAgB,MAAM,WAMvD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,gBAAgB,MAAM,WAS1D,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,IAAI,GAAG,IAAI,GAAG,SA4BxD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,UAAU,EACtD,eAAe,CAAC,EAChB,MAAM,IAAI,KACR,MAAM,GAAG,SAkBX,CAAC;AAEF,eAAO,MAAM,MAAM,GAClB,OAAO,OAAO,EACd,QAAQ,OAAO,EACf,YAAY,aAAa,KACvB,IAAI,GAAG,IA2BT,CAAC;AAEF,eAAO,MAAM,WAAW,GACvB,OAAO,OAAO,EACd,YAAY,IAAI,CAAC,cAAc,KAC7B,MAAM,GAAG,SAYX,CAAC;AAIF,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,IAAI,CAAC,cAUnD,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,UAAU,EAC7C,uBAAuB,CAAC,EACxB,MAAM,OAAO,KACX,MAAM,GAAG,SAcX,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,kBAc3C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,eAAe,UAAU,EAAE,MAAM,OAAO,kBACnB,CAAC;AAErD,eAAO,MAAM,eAAe,GAC3B,OAAO,OAAO,EACd,WAAW,MAAM,KAAK,CAAC,IAAI,CAAC,KAC1B,IAAI,GAAG,SAgBT,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,WAQ1C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,UAAU,EAC/C,eAAe,CAAC,EAChB,MAAM,IAAI,cAqBV,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,UAAU,EAAE,QAAQ,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC,MAAM,MAAM,IAAI,YAqBnE,CAAC"}
@@ -1,19 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applySingleFilter = exports.toXlsxValue = exports.toHashString = exports.fromInputString = exports.getInputString = exports.toInputString = exports.getString = exports.getFormatter = exports.formatters = exports.renderValue = exports.toDate = exports.getComparableValue = exports.parseDate = exports.getAbsoluteISOString = exports.getTimezoneString = void 0;
3
+ exports.applySingleFilter = exports.toXlsxValue = exports.toHashString = exports.fromInputString = exports.getInputString = exports.toInputString = exports.getString = exports.getFormatter = exports.renderValue = exports.toDate = exports.getComparableValue = exports.parseDate = exports.getAbsoluteISOString = exports.getTimezoneString = void 0;
4
4
  const date_1 = require("@neovici/cosmoz-utils/date");
5
5
  const path_1 = require("@polymer/polymer/lib/utils/path");
6
6
  const utils_number_1 = require("./utils-number");
7
7
  const getTimezoneString = (localISOString) => {
8
8
  const off = -new Date(localISOString).getTimezoneOffset() / 60;
9
9
  return ((off < 0 ? '-' : '+') + ['0', Math.abs(off)].join('').substr(-2) + ':00');
10
- },
11
- /**
12
- * Computes the local timezone and adds it to a local ISO string
13
- * @param {String} localISOString an ISO date string, without timezone info
14
- * @return {String} an ISO date string, with timezone info
15
- */
16
- getAbsoluteISOString = (localISOString) => {
10
+ };
11
+ exports.getTimezoneString = getTimezoneString;
12
+ const getAbsoluteISOString = (localISOString) => {
17
13
  // Most browsers use local timezone when no timezone is specified
18
14
  // but Safari uses UTC, so we set it implicitly
19
15
  // TODO: Consider removing this when/if Safari handles local timezone correctly
@@ -21,13 +17,16 @@ getAbsoluteISOString = (localISOString) => {
21
17
  return localISOString + (0, exports.getTimezoneString)(localISOString);
22
18
  }
23
19
  return localISOString;
24
- }, parseDate = (value) => {
20
+ };
21
+ exports.getAbsoluteISOString = getAbsoluteISOString;
22
+ const parseDate = (value) => {
25
23
  if (value == null || value === '') {
26
24
  return;
27
25
  }
28
26
  // convert value to Date
29
27
  let date = value;
30
- if (!(date instanceof Date)) {
28
+ const isDate = date instanceof Date;
29
+ if (!isDate) {
31
30
  // if the value is an ISO string, make sure that it has an explicit timezone
32
31
  if (typeof value === 'string') {
33
32
  date = (0, exports.getAbsoluteISOString)(date);
@@ -41,15 +40,9 @@ getAbsoluteISOString = (localISOString) => {
41
40
  return null;
42
41
  }
43
42
  return date;
44
- },
45
- /**
46
- * Get comparable number from date
47
- *
48
- * @param {String} valuePath Property path
49
- * @param {Object} item Item to be processed
50
- * @returns {Number|void} Valid value or void
51
- */
52
- getComparableValue = ({ valuePath }, item) => {
43
+ };
44
+ exports.parseDate = parseDate;
45
+ const getComparableValue = ({ valuePath }, item) => {
53
46
  if (item == null) {
54
47
  return;
55
48
  }
@@ -57,21 +50,14 @@ getComparableValue = ({ valuePath }, item) => {
57
50
  if (valuePath != null) {
58
51
  value = (0, path_1.get)(item, valuePath);
59
52
  }
60
- value = (0, exports.parseDate)(value);
61
- if (value == null) {
53
+ const date = (0, exports.parseDate)(value);
54
+ if (date == null) {
62
55
  return;
63
56
  }
64
- return (0, utils_number_1.toNumber)(value.getTime());
65
- },
66
- /**
67
- * Converts an value to date optionaly limiting it.
68
- *
69
- * @param {Date|String} value Value to convert to date
70
- * @param {Date|String} limit Value used to limit the date
71
- * @param {Function} limitFunc Function used to limit the date (Math.min|Math.max)
72
- * @returns {Date|void} Value converted to date optionaly limitated
73
- */
74
- toDate = (value, limit, limitFunc) => {
57
+ return (0, utils_number_1.toNumber)(date.getTime());
58
+ };
59
+ exports.getComparableValue = getComparableValue;
60
+ const toDate = (value, limit, limitFunc) => {
75
61
  const date = (0, exports.parseDate)(value);
76
62
  if (date == null) {
77
63
  return null;
@@ -83,9 +69,15 @@ toDate = (value, limit, limitFunc) => {
83
69
  if (lDate == null) {
84
70
  return date;
85
71
  }
86
- const comparableDate = (0, exports.getComparableValue)({}, date), comparableLDate = (0, exports.getComparableValue)({}, lDate), limitedValue = limitFunc(comparableDate, comparableLDate);
72
+ const comparableDate = (0, exports.getComparableValue)({}, date), comparableLDate = (0, exports.getComparableValue)({}, lDate);
73
+ if (comparableDate == null || comparableLDate == null) {
74
+ return date;
75
+ }
76
+ const limitedValue = limitFunc(comparableDate, comparableLDate);
87
77
  return limitedValue === comparableDate ? date : lDate;
88
- }, renderValue = (value, formatter) => {
78
+ };
79
+ exports.toDate = toDate;
80
+ const renderValue = (value, formatter) => {
89
81
  if (formatter == null) {
90
82
  return;
91
83
  }
@@ -94,15 +86,20 @@ toDate = (value, limit, limitFunc) => {
94
86
  return;
95
87
  }
96
88
  return formatter.format(date);
97
- }, getFormatter = (locale) => {
89
+ };
90
+ exports.renderValue = renderValue;
91
+ const formatters = {};
92
+ const getFormatter = (locale) => {
98
93
  const key = locale || '';
99
- if (exports.formatters[key]) {
100
- return exports.formatters[key];
94
+ if (formatters[key]) {
95
+ return formatters[key];
101
96
  }
102
- exports.formatters[key] = new Intl.DateTimeFormat(locale || undefined);
103
- return exports.formatters[key];
104
- }, getString = ({ valuePath, locale }, item) => {
105
- let value = (0, path_1.get)(item, valuePath);
97
+ formatters[key] = new Intl.DateTimeFormat(locale || undefined);
98
+ return formatters[key];
99
+ };
100
+ exports.getFormatter = getFormatter;
101
+ const getString = ({ valuePath, locale }, item) => {
102
+ let value = (0, path_1.get)(item, valuePath || '');
106
103
  if (value === undefined) {
107
104
  return '';
108
105
  }
@@ -111,13 +108,23 @@ toDate = (value, limit, limitFunc) => {
111
108
  return 'Invalid Date';
112
109
  }
113
110
  return (0, exports.renderValue)(value, (0, exports.getFormatter)(locale));
114
- }, toInputString = (value) => {
111
+ };
112
+ exports.getString = getString;
113
+ const toInputString = (value) => {
115
114
  const date = (0, exports.toDate)(value);
116
115
  if (date == null) {
117
116
  return null;
118
117
  }
119
- return (0, date_1.toLocalISOString)(date).slice(0, 10);
120
- }, getInputString = ({ valuePath }, item) => (0, exports.toInputString)((0, path_1.get)(item, valuePath)), fromInputString = (value, property) => {
118
+ const local = (0, date_1.toLocalISOString)(date);
119
+ if (local == null) {
120
+ return null;
121
+ }
122
+ return local.slice(0, 10);
123
+ };
124
+ exports.toInputString = toInputString;
125
+ const getInputString = ({ valuePath }, item) => (0, exports.toInputString)((0, path_1.get)(item, valuePath || ''));
126
+ exports.getInputString = getInputString;
127
+ const fromInputString = (value, property) => {
121
128
  const date = (0, exports.toDate)(value);
122
129
  if (date == null) {
123
130
  return;
@@ -129,13 +136,17 @@ toDate = (value, limit, limitFunc) => {
129
136
  date.setHours(23, 59, 59);
130
137
  }
131
138
  return date;
132
- }, toHashString = (value) => {
139
+ };
140
+ exports.fromInputString = fromInputString;
141
+ const toHashString = (value) => {
133
142
  const string = (0, exports.toInputString)(value);
134
143
  if (string == null) {
135
144
  return '';
136
145
  }
137
146
  return string;
138
- }, toXlsxValue = ({ valuePath }, item) => {
147
+ };
148
+ exports.toHashString = toHashString;
149
+ const toXlsxValue = ({ valuePath }, item) => {
139
150
  if (!valuePath) {
140
151
  return '';
141
152
  }
@@ -149,36 +160,18 @@ toDate = (value, limit, limitFunc) => {
149
160
  }
150
161
  localDate.setHours(0, 0, 0, 0);
151
162
  return localDate;
152
- }, applySingleFilter = (column, filter) => (item) => {
163
+ };
164
+ exports.toXlsxValue = toXlsxValue;
165
+ const applySingleFilter = (column, filter) => (item) => {
153
166
  const value = (0, exports.getComparableValue)(column, item);
154
167
  if (value == null) {
155
168
  return false;
156
169
  }
157
170
  const min = (0, exports.getComparableValue)({ ...column, valuePath: 'min' }, filter), max = (0, exports.getComparableValue)({ ...column, valuePath: 'max' }, filter);
171
+ if (min == null || max == null) {
172
+ return false;
173
+ }
158
174
  return !(value < min || value > max);
159
175
  };
160
- exports.getTimezoneString = getTimezoneString,
161
- /**
162
- * Computes the local timezone and adds it to a local ISO string
163
- * @param {String} localISOString an ISO date string, without timezone info
164
- * @return {String} an ISO date string, with timezone info
165
- */
166
- exports.getAbsoluteISOString = getAbsoluteISOString, exports.parseDate = parseDate,
167
- /**
168
- * Get comparable number from date
169
- *
170
- * @param {String} valuePath Property path
171
- * @param {Object} item Item to be processed
172
- * @returns {Number|void} Valid value or void
173
- */
174
- exports.getComparableValue = getComparableValue,
175
- /**
176
- * Converts an value to date optionaly limiting it.
177
- *
178
- * @param {Date|String} value Value to convert to date
179
- * @param {Date|String} limit Value used to limit the date
180
- * @param {Function} limitFunc Function used to limit the date (Math.min|Math.max)
181
- * @returns {Date|void} Value converted to date optionaly limitated
182
- */
183
- exports.toDate = toDate, exports.renderValue = renderValue, exports.formatters = {}, exports.getFormatter = getFormatter, exports.getString = getString, exports.toInputString = toInputString, exports.getInputString = getInputString, exports.fromInputString = fromInputString, exports.toHashString = toHashString, exports.toXlsxValue = toXlsxValue, exports.applySingleFilter = applySingleFilter;
176
+ exports.applySingleFilter = applySingleFilter;
184
177
  //# sourceMappingURL=utils-date.js.map
@@ -1,16 +1,10 @@
1
- export const formatters: {};
2
- export function getFormatter(locale: any): any;
3
- export function getString({ valuePath, locale }: {
4
- valuePath: any;
5
- locale: any;
6
- }, item: any): any;
7
- export function toXlsxValue({ valuePath }: {
8
- valuePath: any;
9
- }, item: any): any;
10
- export function toHashString(value: any): any;
11
- export function fromHashString(value: any): any;
12
- export function toInputString(value: any): string | null;
13
- export function getInputString({ valuePath }: {
14
- valuePath: any;
15
- }, item: any): string | null;
1
+ import { DateColumn, Item } from './types';
2
+ export declare const formatters: Record<string, Intl.DateTimeFormat>;
3
+ export declare const getFormatter: (locale?: string) => Intl.DateTimeFormat;
4
+ export declare const getString: <T extends DateColumn>({ valuePath, locale }: T, item: Item) => string | undefined;
5
+ export declare const toXlsxValue: <T extends DateColumn>({ valuePath }: T, item: Item) => any;
6
+ export declare const toHashString: (value: unknown) => string;
7
+ export declare const fromHashString: (value: unknown) => Date | null | undefined;
8
+ export declare const toInputString: (value: unknown) => string | null;
9
+ export declare const getInputString: ({ valuePath }: DateColumn, item: Item) => string | null;
16
10
  //# sourceMappingURL=utils-datetime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils-datetime.d.ts","sourceRoot":"","sources":["../../src/lib/utils-datetime.js"],"names":[],"mappings":"AAIa,4BAAe;AAArB,+CA6DuE;AA7DvE;;;mBA6DuE;AA7DvE;;mBA6DuE;AA7DvE,8CA6DuE;AA7DvE,gDA6DuE;AA7DvE,yDA6DuE;AA7DvE;;6BA6DuE"}
1
+ {"version":3,"file":"utils-datetime.d.ts","sourceRoot":"","sources":["../../src/lib/utils-datetime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAM,CAAC;AAElE,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,wBAqB3C,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,UAAU,EAC7C,uBAAuB,CAAC,EACxB,MAAM,IAAI,uBAWV,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,UAAU,EAC/C,eAAe,CAAC,EAChB,MAAM,IAAI,QAOV,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,WAO1C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,4BAS5C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,kBAS3C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,eAAe,UAAU,EAAE,MAAM,IAAI,kBAC1B,CAAC"}
@@ -4,6 +4,7 @@ exports.getInputString = exports.toInputString = exports.fromHashString = export
4
4
  const date_1 = require("@neovici/cosmoz-utils/date");
5
5
  const path_1 = require("@polymer/polymer/lib/utils/path");
6
6
  const utils_date_1 = require("./utils-date");
7
+ exports.formatters = {};
7
8
  const getFormatter = (locale) => {
8
9
  const key = locale || '';
9
10
  if (exports.formatters[key]) {
@@ -18,8 +19,10 @@ const getFormatter = (locale) => {
18
19
  };
19
20
  exports.formatters[key] = new Intl.DateTimeFormat(locale || undefined, timeFormatOption);
20
21
  return exports.formatters[key];
21
- }, getString = ({ valuePath, locale }, item) => {
22
- const value = (0, utils_date_1.toDate)((0, path_1.get)(item, valuePath));
22
+ };
23
+ exports.getFormatter = getFormatter;
24
+ const getString = ({ valuePath, locale }, item) => {
25
+ const value = (0, utils_date_1.toDate)((0, path_1.get)(item, valuePath || ''));
23
26
  if (value === undefined) {
24
27
  return '';
25
28
  }
@@ -27,30 +30,44 @@ const getFormatter = (locale) => {
27
30
  return 'Invalid Date';
28
31
  }
29
32
  return (0, utils_date_1.renderValue)(value, (0, exports.getFormatter)(locale));
30
- }, toXlsxValue = ({ valuePath }, item) => {
33
+ };
34
+ exports.getString = getString;
35
+ const toXlsxValue = ({ valuePath }, item) => {
31
36
  if (!valuePath) {
32
37
  return '';
33
38
  }
34
39
  return (0, path_1.get)(item, valuePath);
35
- }, toHashString = (value) => {
40
+ };
41
+ exports.toXlsxValue = toXlsxValue;
42
+ const toHashString = (value) => {
36
43
  const date = (0, utils_date_1.toDate)(value);
37
44
  if (date == null) {
38
45
  return '';
39
46
  }
40
47
  //Use utc in hash
41
48
  return date.toISOString().slice(0, 19).replace(/:/gu, '.');
42
- }, fromHashString = (value) => {
49
+ };
50
+ exports.toHashString = toHashString;
51
+ const fromHashString = (value) => {
43
52
  if (value == null || value === '') {
44
53
  return;
45
54
  }
46
55
  //Parse utc from hash string
56
+ if (typeof value !== 'string') {
57
+ return;
58
+ }
47
59
  return (0, utils_date_1.toDate)(value.replace(/\./gu, ':') + 'Z');
48
- }, toInputString = (value) => {
60
+ };
61
+ exports.fromHashString = fromHashString;
62
+ const toInputString = (value) => {
49
63
  const date = (0, utils_date_1.toDate)(value);
50
64
  if (date == null) {
51
65
  return null;
52
66
  }
53
- return (0, date_1.toLocalISOString)(date).slice(0, 19);
54
- }, getInputString = ({ valuePath }, item) => (0, exports.toInputString)((0, path_1.get)(item, valuePath));
55
- exports.formatters = {}, exports.getFormatter = getFormatter, exports.getString = getString, exports.toXlsxValue = toXlsxValue, exports.toHashString = toHashString, exports.fromHashString = fromHashString, exports.toInputString = toInputString, exports.getInputString = getInputString;
67
+ const localISOString = (0, date_1.toLocalISOString)(date);
68
+ return localISOString ? localISOString.slice(0, 19) : localISOString;
69
+ };
70
+ exports.toInputString = toInputString;
71
+ const getInputString = ({ valuePath }, item) => (0, exports.toInputString)((0, path_1.get)(item, valuePath || ''));
72
+ exports.getInputString = getInputString;
56
73
  //# sourceMappingURL=utils-datetime.js.map
@@ -1,17 +1,13 @@
1
- export const _fixedDate: "1970-01-01";
2
- export function toDate(value: any, limit: any, limitFunc: any): any;
3
- export const formatters: {};
4
- export function getFormatter(locale: any): any;
5
- export function getString({ valuePath, locale }: {
6
- valuePath: any;
7
- locale: any;
8
- }, item: any): any;
9
- export function toXlsxValue(column: any, item: any): any;
10
- export function toInputString(value: any): string | null;
11
- export function getComparableValue({ valuePath }: {
12
- valuePath: any;
13
- }, item: any): number | undefined;
14
- export function applySingleFilter(column: any, filter: any): (item: any) => boolean;
15
- export function toHashString(value: any): any;
16
- export function fromHashString(value: any): any;
1
+ import { Limit, LimitFunction, DateColumn, Item } from './types';
2
+ export declare const _fixedDate: "1970-01-01";
3
+ export declare const toDate: (value: unknown, limit?: Limit<unknown>, limitFunc?: LimitFunction) => Date | null;
4
+ export declare const formatters: Record<string, Intl.DateTimeFormat>;
5
+ export declare const getFormatter: (locale?: string) => Intl.DateTimeFormat;
6
+ export declare const getString: <T extends DateColumn>({ valuePath, locale }: T, item: Item) => string | undefined;
7
+ export declare const toXlsxValue: (column: DateColumn, item: Item) => string | undefined;
8
+ export declare const toInputString: (value: unknown) => string | null;
9
+ export declare const getComparableValue: <T extends DateColumn>({ valuePath }: T, item: Item) => number | null | undefined;
10
+ export declare const applySingleFilter: (column: DateColumn, filter: Limit<Date>) => (item: Item) => boolean;
11
+ export declare const toHashString: (value: unknown) => string;
12
+ export declare const fromHashString: (value: unknown) => Date | null | undefined;
17
13
  //# sourceMappingURL=utils-time.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils-time.d.ts","sourceRoot":"","sources":["../../src/lib/utils-time.js"],"names":[],"mappings":"AASa,yBAAa,YAAY,CAAA;AAA/B,oEAsGL;AAnFD,4BAAe;AAnBT,+CAsGL;AAtGK;;;mBAsGL;AAtGK,yDAsGL;AAtGK,yDAsGL;AAtGK;;kCAsGL;AAtGK,8DA4EmC,SAAI,aA0B5C;AAtGK,8CAsGL;AAtGK,gDAsGL"}
1
+ {"version":3,"file":"utils-time.d.ts","sourceRoot":"","sources":["../../src/lib/utils-time.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEjE,eAAO,MAAM,UAAU,EAAG,YAAqB,CAAC;AAEhD,eAAO,MAAM,MAAM,GAClB,OAAO,OAAO,EACd,QAAQ,KAAK,CAAC,OAAO,CAAC,EACtB,YAAY,aAAa,gBAUzB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAM,CAAC;AAElE,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,IAAI,CAAC,cAmBnD,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,UAAU,EAC7C,uBAAuB,CAAC,EACxB,MAAM,IAAI,uBAUV,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,QAAQ,UAAU,EAAE,MAAM,IAAI,uBAKzD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,kBAU3C,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,UAAU,EACtD,eAAe,CAAC,EAChB,MAAM,IAAI,8BAmBV,CAAC;AACF,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,UAAU,EAAE,QAAQ,KAAK,CAAC,IAAI,CAAC,MAAM,MAAM,IAAI,YAevD,CAAC;AAEH,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,WAS1C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,4BAQ5C,CAAC"}
@@ -5,16 +5,8 @@ const date_1 = require("@neovici/cosmoz-utils/date");
5
5
  const path_1 = require("@polymer/polymer/lib/utils/path");
6
6
  const utils_date_1 = require("./utils-date");
7
7
  const utils_number_1 = require("./utils-number");
8
- const
9
- /**
10
- * Converts time to date optionaly limiting it.
11
- *
12
- * @param {Date|Number} value Date or Timestamp ( miliseconds since property _fixedDate ) to be converted
13
- * @param {Date|Number} limit Optional value to limit the date.
14
- * @param {Function} limitFunc Function used to limit the date (Math.min|Math.max)
15
- * @returns {Date|void} Value converted to date optionaly limitated
16
- */
17
- toDate = (value, limit, limitFunc) => {
8
+ exports._fixedDate = '1970-01-01';
9
+ const toDate = (value, limit, limitFunc) => {
18
10
  // Most browsers use local timezone when no timezone is specified
19
11
  // but Safari uses UTC, so we set it implicitly
20
12
  // TODO: Consider removing this when/if Safari handles local timezone correctly
@@ -22,7 +14,10 @@ toDate = (value, limit, limitFunc) => {
22
14
  ? (0, utils_date_1.getAbsoluteISOString)(exports._fixedDate + 'T' + value)
23
15
  : value;
24
16
  return (0, utils_date_1.toDate)(date, limit, limitFunc);
25
- }, getFormatter = (locale) => {
17
+ };
18
+ exports.toDate = toDate;
19
+ exports.formatters = {};
20
+ const getFormatter = (locale) => {
26
21
  const key = locale || '';
27
22
  if (exports.formatters[key]) {
28
23
  return exports.formatters[key];
@@ -34,8 +29,10 @@ toDate = (value, limit, limitFunc) => {
34
29
  };
35
30
  exports.formatters[key] = new Intl.DateTimeFormat(locale || undefined, timeFormatOption);
36
31
  return exports.formatters[key];
37
- }, getString = ({ valuePath, locale }, item) => {
38
- const value = (0, exports.toDate)((0, path_1.get)(item, valuePath));
32
+ };
33
+ exports.getFormatter = getFormatter;
34
+ const getString = ({ valuePath, locale }, item) => {
35
+ const value = (0, exports.toDate)((0, path_1.get)(item, valuePath || ''));
39
36
  if (value === undefined) {
40
37
  return '';
41
38
  }
@@ -43,59 +40,68 @@ toDate = (value, limit, limitFunc) => {
43
40
  return 'Invalid Date';
44
41
  }
45
42
  return (0, utils_date_1.renderValue)(value, (0, exports.getFormatter)(locale));
46
- }, toXlsxValue = (column, item) => {
43
+ };
44
+ exports.getString = getString;
45
+ const toXlsxValue = (column, item) => {
47
46
  if (!column.valuePath) {
48
47
  return '';
49
48
  }
50
49
  return (0, exports.getString)(column, item);
51
- }, toInputString = (value) => {
50
+ };
51
+ exports.toXlsxValue = toXlsxValue;
52
+ const toInputString = (value) => {
52
53
  const date = (0, exports.toDate)(value);
53
54
  if (date == null) {
54
55
  return null;
55
56
  }
56
- return (0, date_1.toLocalISOString)(date).slice(11, 19);
57
- }, getComparableValue = ({ valuePath }, item) => {
57
+ const localISOString = (0, date_1.toLocalISOString)(date);
58
+ return localISOString ? localISOString.slice(11, 19) : localISOString;
59
+ };
60
+ exports.toInputString = toInputString;
61
+ const getComparableValue = ({ valuePath }, item) => {
58
62
  if (item == null) {
59
63
  return;
60
64
  }
61
- let value = (0, exports.toInputString)(valuePath == null ? item : (0, path_1.get)(item, valuePath));
65
+ const value = (0, exports.toInputString)(valuePath == null ? item : (0, path_1.get)(item, valuePath));
62
66
  if (value == null) {
63
67
  return;
64
68
  }
65
- value = (0, exports.toDate)((0, utils_date_1.getAbsoluteISOString)(exports._fixedDate + 'T' + value));
66
- if (value == null) {
67
- return;
69
+ const dateValue = (0, exports.toDate)((0, utils_date_1.getAbsoluteISOString)(exports._fixedDate + 'T' + value));
70
+ if (dateValue == null) {
71
+ return dateValue;
68
72
  }
69
- return (0, utils_number_1.toNumber)(value.getTime());
70
- }, applySingleFilter = (column, filter) => (item) => {
73
+ return (0, utils_number_1.toNumber)(dateValue.getTime());
74
+ };
75
+ exports.getComparableValue = getComparableValue;
76
+ const applySingleFilter = (column, filter) => (item) => {
71
77
  const value = (0, exports.getComparableValue)(column, item);
72
78
  if (value == null) {
73
79
  return false;
74
80
  }
75
81
  const min = (0, exports.getComparableValue)({ ...column, valuePath: 'min' }, filter), max = (0, exports.getComparableValue)({ ...column, valuePath: 'max' }, filter);
82
+ if (min == null || max == null) {
83
+ return false;
84
+ }
76
85
  return !(value < min || value > max);
77
- }, toHashString = (value) => {
86
+ };
87
+ exports.applySingleFilter = applySingleFilter;
88
+ const toHashString = (value) => {
78
89
  const date = (0, exports.toDate)(value);
79
90
  if (date == null) {
80
91
  return '';
81
92
  }
82
93
  //Use utc in hash
83
94
  return date.toISOString().slice(11, 19).replace(/:/gu, '.');
84
- }, fromHashString = (value) => {
95
+ };
96
+ exports.toHashString = toHashString;
97
+ const fromHashString = (value) => {
85
98
  if (value == null || value === '') {
86
99
  return;
87
100
  }
88
101
  //Parse utc from hash string
89
- return (0, exports.toDate)(value.replace(/\./gu, ':') + 'Z');
102
+ return typeof value === 'string'
103
+ ? (0, exports.toDate)(value.replace(/\./gu, ':') + 'Z')
104
+ : (0, exports.toDate)(value);
90
105
  };
91
- exports._fixedDate = '1970-01-01',
92
- /**
93
- * Converts time to date optionaly limiting it.
94
- *
95
- * @param {Date|Number} value Date or Timestamp ( miliseconds since property _fixedDate ) to be converted
96
- * @param {Date|Number} limit Optional value to limit the date.
97
- * @param {Function} limitFunc Function used to limit the date (Math.min|Math.max)
98
- * @returns {Date|void} Value converted to date optionaly limitated
99
- */
100
- exports.toDate = toDate, exports.formatters = {}, exports.getFormatter = getFormatter, exports.getString = getString, exports.toXlsxValue = toXlsxValue, exports.toInputString = toInputString, exports.getComparableValue = getComparableValue, exports.applySingleFilter = applySingleFilter, exports.toHashString = toHashString, exports.fromHashString = fromHashString;
106
+ exports.fromHashString = fromHashString;
101
107
  //# sourceMappingURL=utils-time.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "14.18.0",
3
+ "version": "14.20.0",
4
4
  "description": "[![Build Status](https://travis-ci.org/Neovici/cosmoz-omnitable.svg?branch=master)](https://travis-ci.org/Neovici/cosmoz-omnitable)",
5
5
  "keywords": [
6
6
  "web-components"