@ng-atomic/common 1.1.0 → 1.3.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.
Files changed (112) hide show
  1. package/bundles/ng-atomic-common-directives-ios-safari-scroll-buggyfill.umd.js +94 -0
  2. package/bundles/ng-atomic-common-directives-ios-safari-scroll-buggyfill.umd.js.map +1 -0
  3. package/bundles/ng-atomic-common-directives-ios-safari-scroll-buggyfill.umd.min.js +2 -0
  4. package/bundles/ng-atomic-common-directives-ios-safari-scroll-buggyfill.umd.min.js.map +1 -0
  5. package/bundles/ng-atomic-common-directives.umd.js +3 -4
  6. package/bundles/ng-atomic-common-directives.umd.js.map +1 -1
  7. package/bundles/ng-atomic-common-directives.umd.min.js +1 -1
  8. package/bundles/ng-atomic-common-directives.umd.min.js.map +1 -1
  9. package/bundles/ng-atomic-common-pipes.umd.js +170 -26
  10. package/bundles/ng-atomic-common-pipes.umd.js.map +1 -1
  11. package/bundles/ng-atomic-common-pipes.umd.min.js +1 -1
  12. package/bundles/ng-atomic-common-pipes.umd.min.js.map +1 -1
  13. package/bundles/ng-atomic-common-services.umd.js +104 -4
  14. package/bundles/ng-atomic-common-services.umd.js.map +1 -1
  15. package/bundles/ng-atomic-common-services.umd.min.js +2 -2
  16. package/bundles/ng-atomic-common-services.umd.min.js.map +1 -1
  17. package/bundles/ng-atomic-common-store.umd.js +32 -7
  18. package/bundles/ng-atomic-common-store.umd.js.map +1 -1
  19. package/bundles/ng-atomic-common-store.umd.min.js +2 -2
  20. package/bundles/ng-atomic-common-store.umd.min.js.map +1 -1
  21. package/bundles/ng-atomic-common-utils.umd.js +59 -23
  22. package/bundles/ng-atomic-common-utils.umd.js.map +1 -1
  23. package/bundles/ng-atomic-common-utils.umd.min.js +16 -1
  24. package/bundles/ng-atomic-common-utils.umd.min.js.map +1 -1
  25. package/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.d.ts +1 -3
  26. package/directives/ios-safari-scroll-buggyfill/ng-atomic-common-directives-ios-safari-scroll-buggyfill.d.ts +5 -0
  27. package/directives/ios-safari-scroll-buggyfill/package.json +10 -0
  28. package/esm2015/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.js +3 -6
  29. package/esm2015/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.js.map +1 -1
  30. package/esm2015/directives/ios-safari-scroll-buggyfill/ng-atomic-common-directives-ios-safari-scroll-buggyfill.js +5 -0
  31. package/esm2015/directives/ios-safari-scroll-buggyfill/ng-atomic-common-directives-ios-safari-scroll-buggyfill.js.map +1 -0
  32. package/esm2015/pipes/index.js +2 -0
  33. package/esm2015/pipes/index.js.map +1 -1
  34. package/esm2015/pipes/smart-clamp/index.js +3 -0
  35. package/esm2015/pipes/smart-clamp/index.js.map +1 -0
  36. package/esm2015/pipes/smart-clamp/smart-clamp.module.js +27 -0
  37. package/esm2015/pipes/smart-clamp/smart-clamp.module.js.map +1 -0
  38. package/esm2015/pipes/smart-clamp/smart-clamp.pipe.js +45 -0
  39. package/esm2015/pipes/smart-clamp/smart-clamp.pipe.js.map +1 -0
  40. package/esm2015/pipes/smart-exp/smart-exp.pipe.js +15 -15
  41. package/esm2015/pipes/smart-exp/smart-exp.pipe.js.map +1 -1
  42. package/esm2015/pipes/smart-sort-by/index.js +3 -0
  43. package/esm2015/pipes/smart-sort-by/index.js.map +1 -0
  44. package/esm2015/pipes/smart-sort-by/smart-sort-by.module.js +27 -0
  45. package/esm2015/pipes/smart-sort-by/smart-sort-by.module.js.map +1 -0
  46. package/esm2015/pipes/smart-sort-by/smart-sort-by.pipe.js +32 -0
  47. package/esm2015/pipes/smart-sort-by/smart-sort-by.pipe.js.map +1 -0
  48. package/esm2015/pipes/yen/yen.pipe.js +2 -2
  49. package/esm2015/pipes/yen/yen.pipe.js.map +1 -1
  50. package/esm2015/services/form/form.service.js +33 -0
  51. package/esm2015/services/form/form.service.js.map +1 -0
  52. package/esm2015/services/form/index.js +2 -0
  53. package/esm2015/services/form/index.js.map +1 -0
  54. package/esm2015/services/index.js +2 -0
  55. package/esm2015/services/index.js.map +1 -1
  56. package/esm2015/services/query-resolver/index.js +2 -0
  57. package/esm2015/services/query-resolver/index.js.map +1 -0
  58. package/esm2015/services/query-resolver/query-resolver.service.js +28 -0
  59. package/esm2015/services/query-resolver/query-resolver.service.js.map +1 -0
  60. package/esm2015/store/entities.page.store.js +19 -5
  61. package/esm2015/store/entities.page.store.js.map +1 -1
  62. package/esm2015/store/entity.page.store.js +1 -1
  63. package/esm2015/store/entity.page.store.js.map +1 -1
  64. package/esm2015/utils/date-utils/date-utils.js +13 -0
  65. package/esm2015/utils/date-utils/date-utils.js.map +1 -0
  66. package/esm2015/utils/date-utils/index.js +2 -0
  67. package/esm2015/utils/date-utils/index.js.map +1 -0
  68. package/esm2015/utils/index.js +3 -1
  69. package/esm2015/utils/index.js.map +1 -1
  70. package/esm2015/utils/query/query.resolver.js +16 -8
  71. package/esm2015/utils/query/query.resolver.js.map +1 -1
  72. package/esm2015/utils/smart-exp-transformer/index.js +2 -0
  73. package/esm2015/utils/smart-exp-transformer/index.js.map +1 -0
  74. package/esm2015/utils/smart-exp-transformer/smart-exp-transformer.js +18 -0
  75. package/esm2015/utils/smart-exp-transformer/smart-exp-transformer.js.map +1 -0
  76. package/fesm2015/ng-atomic-common-directives-ios-safari-scroll-buggyfill.js +55 -0
  77. package/fesm2015/ng-atomic-common-directives-ios-safari-scroll-buggyfill.js.map +1 -0
  78. package/fesm2015/ng-atomic-common-directives.js +3 -6
  79. package/fesm2015/ng-atomic-common-directives.js.map +1 -1
  80. package/fesm2015/ng-atomic-common-pipes.js +140 -23
  81. package/fesm2015/ng-atomic-common-pipes.js.map +1 -1
  82. package/fesm2015/ng-atomic-common-services.js +60 -2
  83. package/fesm2015/ng-atomic-common-services.js.map +1 -1
  84. package/fesm2015/ng-atomic-common-store.js +21 -5
  85. package/fesm2015/ng-atomic-common-store.js.map +1 -1
  86. package/fesm2015/ng-atomic-common-utils.js +46 -19
  87. package/fesm2015/ng-atomic-common-utils.js.map +1 -1
  88. package/package.json +3 -3
  89. package/pipes/index.d.ts +2 -0
  90. package/pipes/smart-clamp/index.d.ts +2 -0
  91. package/pipes/smart-clamp/smart-clamp.module.d.ts +8 -0
  92. package/pipes/smart-clamp/smart-clamp.pipe.d.ts +14 -0
  93. package/pipes/smart-exp/smart-exp.pipe.d.ts +4 -1
  94. package/pipes/smart-sort-by/index.d.ts +2 -0
  95. package/pipes/smart-sort-by/smart-sort-by.module.d.ts +8 -0
  96. package/pipes/smart-sort-by/smart-sort-by.pipe.d.ts +12 -0
  97. package/services/form/form.service.d.ts +7 -0
  98. package/services/form/index.d.ts +1 -0
  99. package/services/index.d.ts +2 -0
  100. package/services/query-resolver/index.d.ts +1 -0
  101. package/services/query-resolver/query-resolver.service.d.ts +9 -0
  102. package/store/entities.page.store.d.ts +11 -3
  103. package/store/entity.page.store.d.ts +2 -1
  104. package/utils/date-utils/date-utils.d.ts +10 -0
  105. package/utils/date-utils/index.d.ts +1 -0
  106. package/utils/index.d.ts +2 -1
  107. package/utils/query/query.resolver.d.ts +2 -1
  108. package/utils/smart-exp-transformer/index.d.ts +1 -0
  109. package/utils/smart-exp-transformer/smart-exp-transformer.d.ts +6 -0
  110. package/esm2015/utils/define-element.js +0 -10
  111. package/esm2015/utils/define-element.js.map +0 -1
  112. package/utils/define-element.d.ts +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/common/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './comma';\nexport * from './compare-by-id';\nexport * from './mat-dayjs-date';\nexport * from './to-object';\nexport * from './query';\nexport * from './define-element';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/common/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,oCAAoC","sourcesContent":["export * from './comma';\nexport * from './compare-by-id';\nexport * from './date-utils';\nexport * from './mat-dayjs-date';\nexport * from './smart-exp-transformer';\nexport * from './to-object';\nexport * from './query';\n// export * from './define-element';\n"]}
@@ -1,24 +1,26 @@
1
- import { toObject } from '../to-object';
2
1
  import { flatten } from 'flat';
3
- export const filterByQuery = (items, queryString, dlm = {}) => {
4
- return new QueryResolver(dlm).resolve(items, queryString);
2
+ import { smartExpTransformer } from '../smart-exp-transformer';
3
+ import { toObject } from '../to-object';
4
+ export const filterByQuery = (items, queryString, dlm = {}, transformer = smartExpTransformer) => {
5
+ return new QueryResolver(dlm, transformer).resolve(items, queryString);
5
6
  };
6
7
  class QueryResolver {
7
- constructor(map) {
8
+ constructor(map, transformer) {
9
+ this.transformer = transformer;
8
10
  this.inQueryByKey = (items, query) => {
9
11
  var _a, _b;
10
12
  const [not, _key, value] = this.parseQuery(query);
11
13
  const key = (_b = (_a = this.REVERSED_MAP) === null || _a === void 0 ? void 0 : _a[_key]) !== null && _b !== void 0 ? _b : _key;
12
- return items.filter(item => { var _a; return _not(_in((_a = flatten(toObject(item))) === null || _a === void 0 ? void 0 : _a[key], value), not); });
14
+ return items.filter(item => { var _a; return _not(this.in(key, (_a = flatten(toObject(item))) === null || _a === void 0 ? void 0 : _a[key], value), not); });
13
15
  };
14
16
  this.gtQueryByKey = (items, query) => {
15
17
  var _a, _b;
16
18
  const [_key, value] = query.split('>');
17
19
  const key = (_b = (_a = this.REVERSED_MAP) === null || _a === void 0 ? void 0 : _a[_key]) !== null && _b !== void 0 ? _b : _key;
18
- return items.filter(item => { var _a; return _gt((_a = flatten(toObject(item))) === null || _a === void 0 ? void 0 : _a[key], value); });
20
+ return items.filter(item => { var _a; return this.gt(key, (_a = flatten(toObject(item))) === null || _a === void 0 ? void 0 : _a[key], value); });
19
21
  };
20
- this.inQuery = (items, query) => {
21
- return items.filter(item => Object.values(flatten(toObject(item))).some(value => _in(value, query)));
22
+ this.inQuery = (items, q) => {
23
+ return items.filter(item => Object.entries(flatten(toObject(item))).some(([k, v]) => this.in(k, v, q)));
22
24
  };
23
25
  this.REVERSED_MAP = Object.entries(map).reduce((p, [k, v]) => (Object.assign(Object.assign({}, p), { [v]: k })), {});
24
26
  }
@@ -42,6 +44,12 @@ class QueryResolver {
42
44
  const [_key, value] = query.split(':');
43
45
  return [_key.startsWith('-'), _key.startsWith('-') ? _key.slice(1) : _key, value];
44
46
  }
47
+ in(k, v, q) {
48
+ return _in(this.transformer(v, k), q);
49
+ }
50
+ gt(k, v, q) {
51
+ return _gt(this.transformer(v, k), q);
52
+ }
45
53
  }
46
54
  const _not = (bool, not) => {
47
55
  return not ? !bool : bool;
@@ -1 +1 @@
1
- {"version":3,"file":"query.resolver.js","sourceRoot":"","sources":["../../../../../../libs/common/utils/query/query.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,MAAM,CAAC,MAAM,aAAa,GAAG,CAAI,KAAU,EAAE,WAAmB,EAAE,MAA8B,EAAE,EAAO,EAAE;IACzG,OAAO,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAC5D,CAAC,CAAA;AAID,MAAM,aAAa;IAGjB,YAAY,GAA2B;QAuB/B,iBAAY,GAAwB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;;YAC3D,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CA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,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACpF,CAAC;CAiBF;AAED,MAAM,IAAI,GAAG,CAAC,IAAa,EAAE,GAAY,EAAW,EAAE;IACpD,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5B,CAAC,CAAA;AAED,MAAM,GAAG,GAAG,CAAC,KAAU,EAAE,KAAa,EAAE,EAAE;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC;AACpE,CAAC,CAAA;AAED,MAAM,GAAG,GAAG,CAAC,KAAU,EAAE,KAAa,EAAE,EAAE;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ;QAC9B,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC;QACvC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ;YAC3B,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;YAC3B,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC,CAAA","sourcesContent":["import { toObject } from '../to-object';\nimport { flatten } from 'flat';\n\nexport const filterByQuery = <T>(items: T[], queryString: string, dlm: Record<string, string> = {}): T[] => {\n return new QueryResolver(dlm).resolve(items, queryString);\n}\n\ntype QueryResolveFunc<T> = (items: T[], query: string) => T[];\n\nclass QueryResolver<T extends object = any> {\n REVERSED_MAP: Record<string, string>;\n\n constructor(map: Record<string, string>) {\n this.REVERSED_MAP = Object.entries(map).reduce((p, [k, v]) => ({...p, [v]: k}), {} as Record<string, string>);\n }\n\n resolve(items: T[], queryString: string): T[] {\n return this.resolveQueries(items, queryString.split(' ').filter(q => q.length));\n }\n\n resolveQueries(items: T[], queries: string[]): T[] {\n return queries.reduce((_items, query: string) => {\n if (query.includes(':')) return this.inQueryByKey(_items, query);\n if (query.includes('=')) return this.inQueryByKey(_items, query);\n if (query.includes('>')) return this.gtQueryByKey(_items, query);\n if (query.includes('<')) return this.inQueryByKey(_items, query);\n return this.inQuery(_items, query);\n }, items);\n }\n\n private parseQuery(query: string): [boolean, string, string] {\n const [_key, value] = query.split(':');\n return [_key.startsWith('-'), _key.startsWith('-') ? _key.slice(1) : _key, value];\n }\n\n private inQueryByKey: QueryResolveFunc<T> = (items, query) => {\n const [not, _key, value] = this.parseQuery(query);\n const key = this.REVERSED_MAP?.[_key] ?? _key;\n return items.filter(item => _not(_in(flatten(toObject(item as any))?.[key], value), not));\n }\n\n private gtQueryByKey: QueryResolveFunc<T> = (items, query) => {\n const [_key, value] = query.split('>');\n const key = this.REVERSED_MAP?.[_key] ?? _key;\n return items.filter(item => _gt(flatten(toObject(item as any))?.[key], value));\n }\n\n private inQuery: QueryResolveFunc<T> = (items, query) => {\n return items.filter(item => Object.values(flatten(toObject(item as T))).some(value => _in(value, query)));\n }\n}\n\nconst _not = (bool: boolean, not: boolean): boolean => {\n return not ? !bool : bool;\n}\n\nconst _in = (value: any, query: string) => {\n return typeof value === 'string' ? value?.includes(query) : false;\n}\n\nconst _gt = (value: any, query: string) => {\n return typeof value === 'string' \n ? parseFloat(value) > parseFloat(query) \n : typeof value === 'number'\n ? value > parseFloat(query)\n : false;\n}"]}
1
+ {"version":3,"file":"query.resolver.js","sourceRoot":"","sources":["../../../../../../libs/common/utils/query/query.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAuB,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAU,EACV,WAAmB,EACnB,MAA8B,EAAE,EAChC,cAAmC,mBAAmB,EACjD,EAAE;IACP,OAAO,IA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AAW,EAAE;IACjD,OAAO,OAAO,KAAK,KAAK,QAAQ;QAC9B,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC;QACvC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ;YAC3B,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;YAC3B,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC,CAAA","sourcesContent":["import { flatten } from 'flat';\nimport { smartExpTransformer, SmartExpTransformer } from '../smart-exp-transformer';\nimport { toObject } from '../to-object';\n\nexport const filterByQuery = <T>(\n items: T[], \n queryString: string, \n dlm: Record<string, string> = {},\n transformer: SmartExpTransformer = smartExpTransformer,\n): T[] => {\n return new QueryResolver(dlm, transformer).resolve(items, queryString);\n}\n\ntype QueryResolveFunc<T> = (items: T[], query: string) => T[];\n\nclass QueryResolver<T extends object = any> {\n REVERSED_MAP: Record<string, string>;\n\n constructor(\n map: Record<string, string>,\n private transformer: SmartExpTransformer,\n ) {\n this.REVERSED_MAP = Object.entries(map).reduce((p, [k, v]) => ({\n ...p, [v]: k\n }), {} as Record<string, string>);\n }\n\n resolve(items: T[], queryString: string): T[] {\n return this.resolveQueries(items, queryString.split(' ').filter(q => q.length));\n }\n\n resolveQueries(items: T[], queries: string[]): T[] {\n return queries.reduce((_items, query: string) => {\n if (query.includes(':')) return this.inQueryByKey(_items, query);\n if (query.includes('=')) return this.inQueryByKey(_items, query);\n if (query.includes('>')) return this.gtQueryByKey(_items, query);\n if (query.includes('<')) return this.inQueryByKey(_items, query);\n return this.inQuery(_items, query);\n }, items);\n }\n\n private parseQuery(query: string): [boolean, string, string] {\n const [_key, value] = query.split(':');\n return [_key.startsWith('-'), _key.startsWith('-') ? _key.slice(1) : _key, value];\n }\n\n private inQueryByKey: QueryResolveFunc<T> = (items, query) => {\n const [not, _key, value] = this.parseQuery(query);\n const key = this.REVERSED_MAP?.[_key] ?? _key;\n return items.filter(item => _not(this.in(key, flatten(toObject(item as any))?.[key], value), not));\n }\n\n private gtQueryByKey: QueryResolveFunc<T> = (items, query) => {\n const [_key, value] = query.split('>');\n const key = this.REVERSED_MAP?.[_key] ?? _key;\n return items.filter(item => this.gt(key, flatten(toObject(item as any))?.[key], value));\n }\n\n private inQuery: QueryResolveFunc<T> = (items, q) => {\n return items.filter(item => Object.entries(flatten(toObject(item as T))).some(([k, v]) => this.in(k, v, q)));\n }\n\n private in(k: string, v: any, q: string) {\n return _in(this.transformer(v, k), q);\n }\n\n private gt(k: string, v: any, q: string) {\n return _gt(this.transformer(v, k), q);\n }\n}\n\nconst _not = (bool: boolean, not: boolean): boolean => {\n return not ? !bool : bool;\n}\n\nconst _in = (value: any, query: string): boolean => {\n return typeof value === 'string' ? value?.includes(query) : false;\n}\n\nconst _gt = (value: any, query: string): boolean => {\n return typeof value === 'string' \n ? parseFloat(value) > parseFloat(query) \n : typeof value === 'number'\n ? value > parseFloat(query)\n : false;\n}"]}
@@ -0,0 +1,2 @@
1
+ export * from './smart-exp-transformer';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/common/utils/smart-exp-transformer/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC","sourcesContent":["export * from './smart-exp-transformer';"]}
@@ -0,0 +1,18 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import * as dayjs from 'dayjs';
3
+ import { comma } from '../comma';
4
+ export const SMART_EXP_TRANSFORMER = new InjectionToken('[@ng-atomic/common] Smart Transformer');
5
+ // export const yenTransform = (value: number, _unit?: string): string => {
6
+ // return value < 1 ? `${comma(value * 100)}%` : `${comma(value)}円`;
7
+ // }
8
+ export const yenTransform = (value, _unit) => {
9
+ return `${comma(value)}円`;
10
+ };
11
+ export const smartExpTransformer = input => dayjs.isDayjs(input)
12
+ ? input.format('YY/MM/DD')
13
+ : Array.isArray(input)
14
+ ? `${input.length}個のアイテム`
15
+ : typeof input === 'number'
16
+ ? yenTransform(input)
17
+ : input;
18
+ //# sourceMappingURL=smart-exp-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-exp-transformer.js","sourceRoot":"","sources":["../../../../../../libs/common/utils/smart-exp-transformer/smart-exp-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,cAAc,CAAsB,uCAAuC,CAAC,CAAC;AAItH,2EAA2E;AAC3E,sEAAsE;AACtE,IAAI;AAEJ,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,KAAc,EAAU,EAAE;IACpE,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AAC5B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAwB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;IACnF,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;IAC1B,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACtB,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,QAAQ;QACzB,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ;YAC3B,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC;YACrB,CAAC,CAAC,KAAK,CAAC","sourcesContent":["import { InjectionToken } from '@angular/core';\nimport * as dayjs from 'dayjs';\nimport { comma } from '../comma';\n\nexport const SMART_EXP_TRANSFORMER = new InjectionToken<SmartExpTransformer>('[@ng-atomic/common] Smart Transformer');\n\nexport type SmartExpTransformer = (input: string | number | dayjs.Dayjs | any, key?: string) => string;\n\n// export const yenTransform = (value: number, _unit?: string): string => {\n// return value < 1 ? `${comma(value * 100)}%` : `${comma(value)}円`;\n// }\n\nexport const yenTransform = (value: number, _unit?: string): string => {\n return `${comma(value)}円`;\n}\n\nexport const smartExpTransformer: SmartExpTransformer = input => dayjs.isDayjs(input)\n ? input.format('YY/MM/DD')\n : Array.isArray(input) \n ? `${input.length}個のアイテム`\n : typeof input === 'number'\n ? yenTransform(input)\n : input;"]}
@@ -0,0 +1,55 @@
1
+ import * as i0 from '@angular/core';
2
+ import { ɵɵngDeclareDirective, ɵsetClassMetadata, Directive, HostListener, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, NgModule } from '@angular/core';
3
+ import { CommonModule } from '@angular/common';
4
+
5
+ class IosSafariScrollBuggyfillDirective {
6
+ ngAfterViewInit() {
7
+ // this.el.nativeElement.addEventListener('touchmove', (e: Event) => {
8
+ // e.preventDefault();
9
+ // }, {passive: false});
10
+ }
11
+ onTouchmove(event) {
12
+ event.preventDefault();
13
+ }
14
+ }
15
+ IosSafariScrollBuggyfillDirective.ɵfac = function IosSafariScrollBuggyfillDirective_Factory(t) { return new (t || IosSafariScrollBuggyfillDirective)(); };
16
+ IosSafariScrollBuggyfillDirective.ɵdir = ɵɵngDeclareDirective({ version: "11.2.14", type: IosSafariScrollBuggyfillDirective, selector: "[iosSafariScrollBuggyfill]", host: { listeners: { "touchmove": "onTouchmove($event)" } }, ngImport: i0 });
17
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(IosSafariScrollBuggyfillDirective, [{
18
+ type: Directive,
19
+ args: [{
20
+ selector: '[iosSafariScrollBuggyfill]'
21
+ }]
22
+ }], null, { onTouchmove: [{
23
+ type: HostListener,
24
+ args: ['touchmove', ['$event']]
25
+ }] }); })();
26
+
27
+ class IosSafariScrollBuggyfillModule {
28
+ }
29
+ IosSafariScrollBuggyfillModule.ɵfac = function IosSafariScrollBuggyfillModule_Factory(t) { return new (t || IosSafariScrollBuggyfillModule)(); };
30
+ IosSafariScrollBuggyfillModule.ɵmod = ɵɵdefineNgModule({ type: IosSafariScrollBuggyfillModule });
31
+ IosSafariScrollBuggyfillModule.ɵinj = ɵɵdefineInjector({ imports: [[
32
+ CommonModule,
33
+ ]] });
34
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(IosSafariScrollBuggyfillModule, { declarations: [IosSafariScrollBuggyfillDirective], imports: [CommonModule], exports: [IosSafariScrollBuggyfillDirective] }); })();
35
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(IosSafariScrollBuggyfillModule, [{
36
+ type: NgModule,
37
+ args: [{
38
+ declarations: [
39
+ IosSafariScrollBuggyfillDirective,
40
+ ],
41
+ imports: [
42
+ CommonModule,
43
+ ],
44
+ exports: [
45
+ IosSafariScrollBuggyfillDirective,
46
+ ]
47
+ }]
48
+ }], null, null); })();
49
+
50
+ /**
51
+ * Generated bundle index. Do not edit.
52
+ */
53
+
54
+ export { IosSafariScrollBuggyfillDirective, IosSafariScrollBuggyfillModule };
55
+ //# sourceMappingURL=ng-atomic-common-directives-ios-safari-scroll-buggyfill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ng-atomic-common-directives-ios-safari-scroll-buggyfill.js","sources":["../../../../libs/common/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.ts","../../../../libs/common/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.module.ts","../../../../libs/common/directives/ios-safari-scroll-buggyfill/ng-atomic-common-directives-ios-safari-scroll-buggyfill.ts"],"sourcesContent":["import { AfterViewInit, Directive, HostListener } from '@angular/core';\n\n@Directive({\n selector: '[iosSafariScrollBuggyfill]'\n})\nexport class IosSafariScrollBuggyfillDirective implements AfterViewInit {\n\n ngAfterViewInit(): void {\n // this.el.nativeElement.addEventListener('touchmove', (e: Event) => {\n // e.preventDefault();\n // }, {passive: false});\n }\n\n @HostListener('touchmove', ['$event'])\n onTouchmove(event: Event) {\n event.preventDefault();\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { IosSafariScrollBuggyfillDirective } from './ios-safari-scroll-buggyfill.directive';\n\n\n\n@NgModule({\n declarations: [\n IosSafariScrollBuggyfillDirective,\n ],\n imports: [\n CommonModule,\n ],\n exports: [\n IosSafariScrollBuggyfillDirective,\n ]\n})\nexport class IosSafariScrollBuggyfillModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAKa,iCAAiC;IAE5C,eAAe;;;;KAId;IAGD,WAAW,CAAC,KAAY;QACtB,KAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;kHAXU,iCAAiC;0FAAjC,iCAAiC;oFAAjC,iCAAiC;cAH7C,SAAS;eAAC;gBACT,QAAQ,EAAE,4BAA4B;aACvC;gBAUC,WAAW;kBADV,YAAY;mBAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;;;MCI1B,8BAA8B;;4GAA9B,8BAA8B;+DAA9B,8BAA8B;mEAPhC;YACP,YAAY;SACb;qFAKU,8BAA8B,mBATvC,iCAAiC,aAGjC,YAAY,aAGZ,iCAAiC;oFAGxB,8BAA8B;cAX1C,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,iCAAiC;iBAClC;gBACD,OAAO,EAAE;oBACP,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,iCAAiC;iBAClC;aACF;;;AChBD;;;;;;"}
@@ -1,11 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { ɵɵdirectiveInject, ElementRef, ɵɵngDeclareDirective, ɵsetClassMetadata, Directive, HostListener, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, NgModule } from '@angular/core';
2
+ import { ɵɵngDeclareDirective, ɵsetClassMetadata, Directive, HostListener, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, NgModule } from '@angular/core';
3
3
  import { CommonModule } from '@angular/common';
4
4
 
5
5
  class IosSafariScrollBuggyfillDirective {
6
- constructor(el) {
7
- this.el = el;
8
- }
9
6
  ngAfterViewInit() {
10
7
  // this.el.nativeElement.addEventListener('touchmove', (e: Event) => {
11
8
  // e.preventDefault();
@@ -15,14 +12,14 @@ class IosSafariScrollBuggyfillDirective {
15
12
  event.preventDefault();
16
13
  }
17
14
  }
18
- IosSafariScrollBuggyfillDirective.ɵfac = function IosSafariScrollBuggyfillDirective_Factory(t) { return new (t || IosSafariScrollBuggyfillDirective)(ɵɵdirectiveInject(ElementRef)); };
15
+ IosSafariScrollBuggyfillDirective.ɵfac = function IosSafariScrollBuggyfillDirective_Factory(t) { return new (t || IosSafariScrollBuggyfillDirective)(); };
19
16
  IosSafariScrollBuggyfillDirective.ɵdir = ɵɵngDeclareDirective({ version: "11.2.14", type: IosSafariScrollBuggyfillDirective, selector: "[iosSafariScrollBuggyfill]", host: { listeners: { "touchmove": "onTouchmove($event)" } }, ngImport: i0 });
20
17
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(IosSafariScrollBuggyfillDirective, [{
21
18
  type: Directive,
22
19
  args: [{
23
20
  selector: '[iosSafariScrollBuggyfill]'
24
21
  }]
25
- }], function () { return [{ type: ElementRef }]; }, { onTouchmove: [{
22
+ }], null, { onTouchmove: [{
26
23
  type: HostListener,
27
24
  args: ['touchmove', ['$event']]
28
25
  }] }); })();
@@ -1 +1 @@
1
- {"version":3,"file":"ng-atomic-common-directives.js","sources":["../../../../libs/common/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.ts","../../../../libs/common/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.module.ts","../../../../libs/common/directives/ng-atomic-common-directives.ts"],"sourcesContent":["import { AfterViewInit, Directive, ElementRef, HostListener } from '@angular/core';\n\n@Directive({\n selector: '[iosSafariScrollBuggyfill]'\n})\nexport class IosSafariScrollBuggyfillDirective implements AfterViewInit {\n\n constructor(private el: ElementRef) { }\n\n ngAfterViewInit(): void {\n // this.el.nativeElement.addEventListener('touchmove', (e: Event) => {\n // e.preventDefault();\n // }, {passive: false});\n }\n\n @HostListener('touchmove', ['$event'])\n onTouchmove(event: Event) {\n event.preventDefault();\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { IosSafariScrollBuggyfillDirective } from './ios-safari-scroll-buggyfill.directive';\n\n\n\n@NgModule({\n declarations: [\n IosSafariScrollBuggyfillDirective,\n ],\n imports: [\n CommonModule,\n ],\n exports: [\n IosSafariScrollBuggyfillDirective,\n ]\n})\nexport class IosSafariScrollBuggyfillModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAKa,iCAAiC;IAE5C,YAAoB,EAAc;QAAd,OAAE,GAAF,EAAE,CAAY;KAAK;IAEvC,eAAe;;;;KAId;IAGD,WAAW,CAAC,KAAY;QACtB,KAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;kHAbU,iCAAiC;0FAAjC,iCAAiC;oFAAjC,iCAAiC;cAH7C,SAAS;eAAC;gBACT,QAAQ,EAAE,4BAA4B;aACvC;0DAYC,WAAW;kBADV,YAAY;mBAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;;;MCE1B,8BAA8B;;4GAA9B,8BAA8B;+DAA9B,8BAA8B;mEAPhC;YACP,YAAY;SACb;qFAKU,8BAA8B,mBATvC,iCAAiC,aAGjC,YAAY,aAGZ,iCAAiC;oFAGxB,8BAA8B;cAX1C,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,iCAAiC;iBAClC;gBACD,OAAO,EAAE;oBACP,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,iCAAiC;iBAClC;aACF;;;AChBD;;;;;;"}
1
+ {"version":3,"file":"ng-atomic-common-directives.js","sources":["../../../../libs/common/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.ts","../../../../libs/common/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.module.ts","../../../../libs/common/directives/ng-atomic-common-directives.ts"],"sourcesContent":["import { AfterViewInit, Directive, HostListener } from '@angular/core';\n\n@Directive({\n selector: '[iosSafariScrollBuggyfill]'\n})\nexport class IosSafariScrollBuggyfillDirective implements AfterViewInit {\n\n ngAfterViewInit(): void {\n // this.el.nativeElement.addEventListener('touchmove', (e: Event) => {\n // e.preventDefault();\n // }, {passive: false});\n }\n\n @HostListener('touchmove', ['$event'])\n onTouchmove(event: Event) {\n event.preventDefault();\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { IosSafariScrollBuggyfillDirective } from './ios-safari-scroll-buggyfill.directive';\n\n\n\n@NgModule({\n declarations: [\n IosSafariScrollBuggyfillDirective,\n ],\n imports: [\n CommonModule,\n ],\n exports: [\n IosSafariScrollBuggyfillDirective,\n ]\n})\nexport class IosSafariScrollBuggyfillModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAKa,iCAAiC;IAE5C,eAAe;;;;KAId;IAGD,WAAW,CAAC,KAAY;QACtB,KAAK,CAAC,cAAc,EAAE,CAAC;KACxB;;kHAXU,iCAAiC;0FAAjC,iCAAiC;oFAAjC,iCAAiC;cAH7C,SAAS;eAAC;gBACT,QAAQ,EAAE,4BAA4B;aACvC;gBAUC,WAAW;kBADV,YAAY;mBAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;;;MCI1B,8BAA8B;;4GAA9B,8BAA8B;+DAA9B,8BAA8B;mEAPhC;YACP,YAAY;SACb;qFAKU,8BAA8B,mBATvC,iCAAiC,aAGjC,YAAY,aAGZ,iCAAiC;oFAGxB,8BAA8B;cAX1C,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,iCAAiC;iBAClC;gBACD,OAAO,EAAE;oBACP,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,iCAAiC;iBAClC;aACF;;;AChBD;;;;;;"}
@@ -1,8 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, ɵɵdirectiveInject, ɵɵngDeclarePipe, ɵsetClassMetadata, Pipe, Optional, Inject, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, NgModule } from '@angular/core';
3
- import { CommonModule } from '@angular/common';
4
- import { isDayjs } from 'dayjs';
5
- import { comma } from '@ng-atomic/common/utils';
3
+ import { CommonModule, SlicePipe } from '@angular/common';
4
+ import { sortBy } from 'lodash';
5
+ import { smartExpTransformer, SMART_EXP_TRANSFORMER, yenTransform } from '@ng-atomic/common/utils';
6
6
 
7
7
  const DOMAIN_LANG_MAP = new InjectionToken('domain lang map');
8
8
  class DomainPipe {
@@ -54,35 +54,133 @@ DomainModule.ɵinj = ɵɵdefineInjector({ imports: [[
54
54
  }]
55
55
  }], null, null); })();
56
56
 
57
- class YenPipe {
58
- transform(value, _unit) {
59
- return value < 1 ? `${comma(value * 100)}%` : `${comma(value)}円`;
57
+ const SMART_SORT_BY_TRANSFORMER = new InjectionToken('[@ng-atomic/common] Smart Sort By Transformer');
58
+ const smartSortByTransformer = (items, key, order) => {
59
+ return order === 'asc' ? sortBy(items, key) : sortBy(items, key).reverse();
60
+ };
61
+ class SmartSortByPipe {
62
+ constructor(transformer) {
63
+ var _a;
64
+ this.transformer = transformer;
65
+ (_a = this.transformer) !== null && _a !== void 0 ? _a : (this.transformer = smartSortByTransformer);
66
+ }
67
+ transform(items, key, order = 'asc') {
68
+ return this.transformer(items, key, order);
60
69
  }
61
70
  }
62
- YenPipe.ɵfac = function YenPipe_Factory(t) { return new (t || YenPipe)(); };
63
- YenPipe.ɵpipe = ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type: YenPipe, name: "yen" });
64
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(YenPipe, [{
71
+ SmartSortByPipe.ɵfac = function SmartSortByPipe_Factory(t) { return new (t || SmartSortByPipe)(ɵɵdirectiveInject(SMART_SORT_BY_TRANSFORMER, 8)); };
72
+ SmartSortByPipe.ɵpipe = ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type: SmartSortByPipe, name: "smartSortBy" });
73
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(SmartSortByPipe, [{
65
74
  type: Pipe,
66
75
  args: [{
67
- name: 'yen'
76
+ name: 'smartSortBy',
77
+ pure: true,
78
+ }]
79
+ }], function () { return [{ type: undefined, decorators: [{
80
+ type: Optional
81
+ }, {
82
+ type: Inject,
83
+ args: [SMART_SORT_BY_TRANSFORMER]
84
+ }] }]; }, null); })();
85
+
86
+ class SmartSortByModule {
87
+ }
88
+ SmartSortByModule.ɵfac = function SmartSortByModule_Factory(t) { return new (t || SmartSortByModule)(); };
89
+ SmartSortByModule.ɵmod = ɵɵdefineNgModule({ type: SmartSortByModule });
90
+ SmartSortByModule.ɵinj = ɵɵdefineInjector({ imports: [[
91
+ CommonModule
92
+ ]] });
93
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(SmartSortByModule, { declarations: [SmartSortByPipe], imports: [CommonModule], exports: [SmartSortByPipe] }); })();
94
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(SmartSortByModule, [{
95
+ type: NgModule,
96
+ args: [{
97
+ declarations: [
98
+ SmartSortByPipe
99
+ ],
100
+ imports: [
101
+ CommonModule
102
+ ],
103
+ exports: [
104
+ SmartSortByPipe
105
+ ]
106
+ }]
107
+ }], null, null); })();
108
+
109
+ class SmartClampPipe {
110
+ constructor(transformer) {
111
+ var _a;
112
+ this.transformer = transformer;
113
+ this.slicePipe = new SlicePipe();
114
+ this._input = null;
115
+ this._output = [];
116
+ (_a = this.transformer) !== null && _a !== void 0 ? _a : (this.transformer = smartSortByTransformer);
117
+ }
118
+ transform(items, store) {
119
+ const input = {
120
+ items,
121
+ sortKey: store.sortKey,
122
+ sortOrder: store.sortOrder,
123
+ start: store.page.start,
124
+ end: store.page.end,
125
+ };
126
+ if (JSON.stringify(input) === JSON.stringify(this._input)) {
127
+ return this._output;
128
+ }
129
+ this._input = input;
130
+ items = this.transformer(items, store === null || store === void 0 ? void 0 : store.sortKey, store === null || store === void 0 ? void 0 : store.sortOrder);
131
+ items = this.slicePipe.transform(items, store.page.start, store.page.end);
132
+ return this._output = items;
133
+ }
134
+ }
135
+ SmartClampPipe.ɵfac = function SmartClampPipe_Factory(t) { return new (t || SmartClampPipe)(ɵɵdirectiveInject(SMART_SORT_BY_TRANSFORMER, 8)); };
136
+ SmartClampPipe.ɵpipe = ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type: SmartClampPipe, name: "smartClamp", pure: false });
137
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(SmartClampPipe, [{
138
+ type: Pipe,
139
+ args: [{
140
+ name: 'smartClamp',
141
+ pure: false,
142
+ }]
143
+ }], function () { return [{ type: undefined, decorators: [{
144
+ type: Optional
145
+ }, {
146
+ type: Inject,
147
+ args: [SMART_SORT_BY_TRANSFORMER]
148
+ }] }]; }, null); })();
149
+
150
+ class SmartClampModule {
151
+ }
152
+ SmartClampModule.ɵfac = function SmartClampModule_Factory(t) { return new (t || SmartClampModule)(); };
153
+ SmartClampModule.ɵmod = ɵɵdefineNgModule({ type: SmartClampModule });
154
+ SmartClampModule.ɵinj = ɵɵdefineInjector({ imports: [[
155
+ CommonModule,
156
+ ]] });
157
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(SmartClampModule, { declarations: [SmartClampPipe], imports: [CommonModule], exports: [SmartClampPipe] }); })();
158
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(SmartClampModule, [{
159
+ type: NgModule,
160
+ args: [{
161
+ declarations: [
162
+ SmartClampPipe
163
+ ],
164
+ imports: [
165
+ CommonModule,
166
+ ],
167
+ exports: [
168
+ SmartClampPipe
169
+ ]
68
170
  }]
69
171
  }], null, null); })();
70
172
 
71
173
  class SmartExpPipe {
174
+ constructor(transformer) {
175
+ var _a;
176
+ this.transformer = transformer;
177
+ (_a = this.transformer) !== null && _a !== void 0 ? _a : (this.transformer = smartExpTransformer);
178
+ }
72
179
  transform(input, key) {
73
- if (isDayjs(input)) {
74
- return input.format('YY/MM/DD');
75
- }
76
- else if (Array.isArray(input)) {
77
- return `${input.length}個のアイテム`;
78
- }
79
- else if (typeof input === 'number' && input > 10000) {
80
- return new YenPipe().transform(input);
81
- }
82
- return input;
180
+ return this.transformer(input, key);
83
181
  }
84
182
  }
85
- SmartExpPipe.ɵfac = function SmartExpPipe_Factory(t) { return new (t || SmartExpPipe)(); };
183
+ SmartExpPipe.ɵfac = function SmartExpPipe_Factory(t) { return new (t || SmartExpPipe)(ɵɵdirectiveInject(SMART_EXP_TRANSFORMER, 8)); };
86
184
  SmartExpPipe.ɵpipe = ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type: SmartExpPipe, name: "smartExp" });
87
185
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(SmartExpPipe, [{
88
186
  type: Pipe,
@@ -90,7 +188,12 @@ SmartExpPipe.ɵpipe = ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type
90
188
  name: 'smartExp',
91
189
  pure: true,
92
190
  }]
93
- }], null, null); })();
191
+ }], function () { return [{ type: undefined, decorators: [{
192
+ type: Optional
193
+ }, {
194
+ type: Inject,
195
+ args: [SMART_EXP_TRANSFORMER]
196
+ }] }]; }, null); })();
94
197
 
95
198
  class SmartExpModule {
96
199
  }
@@ -160,6 +263,20 @@ SmartFieldModule.ɵinj = ɵɵdefineInjector({ imports: [[
160
263
  }]
161
264
  }], null, null); })();
162
265
 
266
+ class YenPipe {
267
+ transform(value, _unit) {
268
+ return yenTransform(value, _unit);
269
+ }
270
+ }
271
+ YenPipe.ɵfac = function YenPipe_Factory(t) { return new (t || YenPipe)(); };
272
+ YenPipe.ɵpipe = ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type: YenPipe, name: "yen" });
273
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(YenPipe, [{
274
+ type: Pipe,
275
+ args: [{
276
+ name: 'yen'
277
+ }]
278
+ }], null, null); })();
279
+
163
280
  class YenModule {
164
281
  }
165
282
  YenModule.ɵfac = function YenModule_Factory(t) { return new (t || YenModule)(); };
@@ -187,5 +304,5 @@ YenModule.ɵinj = ɵɵdefineInjector({ imports: [[
187
304
  * Generated bundle index. Do not edit.
188
305
  */
189
306
 
190
- export { DOMAIN_LANG_MAP, DomainModule, DomainPipe, FORM_FIELD_MAP, SmartExpModule, SmartExpPipe, SmartFieldModule, SmartFieldPipe, YenModule, YenPipe };
307
+ export { DOMAIN_LANG_MAP, DomainModule, DomainPipe, FORM_FIELD_MAP, SMART_SORT_BY_TRANSFORMER, SmartClampModule, SmartClampPipe, SmartExpModule, SmartExpPipe, SmartFieldModule, SmartFieldPipe, SmartSortByModule, SmartSortByPipe, YenModule, YenPipe, smartSortByTransformer };
191
308
  //# sourceMappingURL=ng-atomic-common-pipes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ng-atomic-common-pipes.js","sources":["../../../../libs/common/pipes/domain/domain.pipe.ts","../../../../libs/common/pipes/domain/domain.module.ts","../../../../libs/common/pipes/yen/yen.pipe.ts","../../../../libs/common/pipes/smart-exp/smart-exp.pipe.ts","../../../../libs/common/pipes/smart-exp/smart-exp.module.ts","../../../../libs/common/pipes/smart-field/smart-field.pipe.ts","../../../../libs/common/pipes/smart-field/smart-field.module.ts","../../../../libs/common/pipes/yen/yen.module.ts","../../../../libs/common/pipes/ng-atomic-common-pipes.ts"],"sourcesContent":["import { Inject, InjectionToken, Optional, Pipe } from '@angular/core';\n\nexport type DomainLangMap = Record<string, string>;\nexport const DOMAIN_LANG_MAP = new InjectionToken<DomainLangMap>('domain lang map');\n\n@Pipe({\n name: 'D',\n pure: true,\n})\nexport class DomainPipe {\n constructor(@Optional() @Inject(DOMAIN_LANG_MAP) private map: DomainLangMap) {\n this.map ??= {};\n }\n\n transform(input: string) {\n return this.map?.[input] ?? input;\n }\n}\n\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { DomainPipe } from './domain.pipe';\n\n\n\n@NgModule({\n declarations: [\n DomainPipe\n ],\n imports: [\n CommonModule\n ],\n exports: [\n DomainPipe\n ]\n})\nexport class DomainModule { }\n","import { Pipe, PipeTransform } from '@angular/core';\nimport { comma } from '@ng-atomic/common/utils';\n\n@Pipe({\n name: 'yen'\n})\nexport class YenPipe implements PipeTransform {\n\n transform(value: number, _unit?: string): string {\n return value < 1 ? `${comma(value * 100)}%` : `${comma(value)}円`;\n }\n\n}\n","import { Pipe } from '@angular/core';\nimport * as dayjs from 'dayjs';\nimport { YenPipe } from '../yen/yen.pipe';\n\n@Pipe({\n name: 'smartExp',\n pure: true,\n})\nexport class SmartExpPipe {\n transform(input: string | number | dayjs.Dayjs | any, key?: string): string {\n if (dayjs.isDayjs(input)) {\n return input.format('YY/MM/DD');\n } else if (Array.isArray(input)) {\n return `${input.length}個のアイテム`;\n } else if (typeof input === 'number' && input > 10_000) {\n return new YenPipe().transform(input);\n }\n return input;\n }\n}","import { NgModule } from \"@angular/core\";\nimport { SmartExpPipe } from \"./smart-exp.pipe\";\n\n@NgModule({\n declarations: [SmartExpPipe],\n exports: [SmartExpPipe]\n})\nexport class SmartExpModule { }","import { Inject, InjectionToken, Optional, Pipe, PipeTransform } from '@angular/core';\n\ninterface Option<T> {\n name: string;\n value: T;\n}\n\ninterface InputField {\n type: 'input';\n}\n\ninterface DateInputField {\n type: 'date';\n}\n\ninterface SelectField<T> {\n type: 'select';\n options: Option<T>[];\n}\n\ninterface MultiSelectField<T> {\n type: 'multi-select';\n options: Option<T>[];\n}\n\ntype FormField<V> = InputField\n | DateInputField\n | SelectField<V>\n | MultiSelectField<V>;\n\nexport type FormFieldMap = Record<string, FormField<any>>;\n\nexport const FORM_FIELD_MAP = new InjectionToken<FormFieldMap>('[@ng-atomic] Smart Form Field');\n\n@Pipe({\n name: 'smartField',\n pure: true,\n})\nexport class SmartFieldPipe implements PipeTransform {\n\n constructor(\n @Optional() @Inject(FORM_FIELD_MAP) private map: Record<string, FormField<any>>\n ) {\n this.map ??= {\n createdAt: { type: 'date' },\n updatedAt: { type: 'date' },\n deletedAt: { type: 'date' },\n };\n }\n\n transform(key: string): FormField<any> {\n return this.map[key] ?? {type: 'input'};\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { SmartFieldPipe } from './smart-field.pipe';\n\n\n\n@NgModule({\n declarations: [\n SmartFieldPipe\n ],\n imports: [\n CommonModule\n ],\n exports: [\n SmartFieldPipe\n ]\n})\nexport class SmartFieldModule { }\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { YenPipe } from './yen.pipe';\n\n\n\n@NgModule({\n declarations: [\n YenPipe\n ],\n imports: [\n CommonModule\n ],\n exports: [\n YenPipe\n ]\n})\nexport class YenModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["dayjs.isDayjs"],"mappings":";;;;;;MAGa,eAAe,GAAG,IAAI,cAAc,CAAgB,iBAAiB,EAAE;MAMvE,UAAU;IACrB,YAAyD,GAAkB;;QAAlB,QAAG,GAAH,GAAG,CAAe;QACzE,MAAA,IAAI,CAAC,GAAG,oCAAR,IAAI,CAAC,GAAG,GAAK,EAAE,EAAC;KACjB;IAED,SAAS,CAAC,KAAa;;QACrB,mBAAO,IAAI,CAAC,GAAG,0CAAG,KAAK,oCAAK,KAAK,CAAC;KACnC;;oEAPU,UAAU,oBACW,eAAe;6EADpC,UAAU;oFAAV,UAAU;cAJtB,IAAI;eAAC;gBACJ,IAAI,EAAE,GAAG;gBACT,IAAI,EAAE,IAAI;aACX;;sBAEc,QAAQ;;sBAAI,MAAM;uBAAC,eAAe;;;MCOpC,YAAY;;wEAAZ,YAAY;6CAAZ,YAAY;iDAPd;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,"file":"ng-atomic-common-pipes.js","sources":["../../../../libs/common/pipes/domain/domain.pipe.ts","../../../../libs/common/pipes/domain/domain.module.ts","../../../../libs/common/pipes/smart-sort-by/smart-sort-by.pipe.ts","../../../../libs/common/pipes/smart-sort-by/smart-sort-by.module.ts","../../../../libs/common/pipes/smart-clamp/smart-clamp.pipe.ts","../../../../libs/common/pipes/smart-clamp/smart-clamp.module.ts","../../../../libs/common/pipes/smart-exp/smart-exp.pipe.ts","../../../../libs/common/pipes/smart-exp/smart-exp.module.ts","../../../../libs/common/pipes/smart-field/smart-field.pipe.ts","../../../../libs/common/pipes/smart-field/smart-field.module.ts","../../../../libs/common/pipes/yen/yen.pipe.ts","../../../../libs/common/pipes/yen/yen.module.ts","../../../../libs/common/pipes/ng-atomic-common-pipes.ts"],"sourcesContent":["import { Inject, InjectionToken, Optional, Pipe } from '@angular/core';\n\nexport type DomainLangMap = Record<string, string>;\nexport const DOMAIN_LANG_MAP = new InjectionToken<DomainLangMap>('domain lang map');\n\n@Pipe({\n name: 'D',\n pure: true,\n})\nexport class DomainPipe {\n constructor(@Optional() @Inject(DOMAIN_LANG_MAP) private map: DomainLangMap) {\n this.map ??= {};\n }\n\n transform(input: string) {\n return this.map?.[input] ?? input;\n }\n}\n\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { DomainPipe } from './domain.pipe';\n\n\n\n@NgModule({\n declarations: [\n DomainPipe\n ],\n imports: [\n CommonModule\n ],\n exports: [\n DomainPipe\n ]\n})\nexport class DomainModule { }\n","import { Inject, InjectionToken, Optional, Pipe, PipeTransform } from '@angular/core';\nimport { sortBy } from 'lodash';\n\nexport const SMART_SORT_BY_TRANSFORMER = new InjectionToken('[@ng-atomic/common] Smart Sort By Transformer');\nexport type SmartSortByTransformer = <T>(items: T[], key: string, order: 'asc' | 'desc') => T[];\nexport const smartSortByTransformer: SmartSortByTransformer = (items, key, order) => {\n return order === 'asc' ? sortBy(items, key) : sortBy(items, key).reverse();\n}\n\n@Pipe({\n name: 'smartSortBy',\n pure: true,\n})\nexport class SmartSortByPipe implements PipeTransform {\n\n constructor(\n @Optional()\n @Inject(SMART_SORT_BY_TRANSFORMER)\n private transformer?: SmartSortByTransformer,\n ) {\n this.transformer ??= smartSortByTransformer;\n }\n\n transform<T>(items: T[], key: string, order: 'asc' | 'desc' = 'asc'): T[] {\n return this.transformer(items, key, order);\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { SmartSortByPipe } from './smart-sort-by.pipe';\n\n\n\n@NgModule({\n declarations: [\n SmartSortByPipe\n ],\n imports: [\n CommonModule\n ],\n exports: [\n SmartSortByPipe\n ]\n})\nexport class SmartSortByModule { }\n","import { SlicePipe } from '@angular/common';\nimport { Inject, Optional, Pipe, PipeTransform } from '@angular/core';\nimport { EntitiesPageStore } from '@ng-atomic/common/store';\nimport { smartSortByTransformer, SmartSortByTransformer, SMART_SORT_BY_TRANSFORMER } from '../smart-sort-by';\n\n@Pipe({\n name: 'smartClamp',\n pure: false,\n})\nexport class SmartClampPipe implements PipeTransform {\n private slicePipe = new SlicePipe();\n private _input = null;\n private _output = [];\n\n constructor(\n @Optional()\n @Inject(SMART_SORT_BY_TRANSFORMER)\n private transformer?: SmartSortByTransformer,\n ) {\n this.transformer ??= smartSortByTransformer;\n }\n\n transform<T>(items: T[], store: EntitiesPageStore<any, any>): T[] {\n const input = {\n items, \n sortKey: store.sortKey, \n sortOrder: store.sortOrder, \n start: store.page.start,\n end: store.page.end,\n };\n \n if (JSON.stringify(input) === JSON.stringify(this._input)) {\n return this._output;\n }\n\n this._input = input;\n items = this.transformer(items, store?.sortKey, store?.sortOrder as 'asc' | 'desc');\n items = this.slicePipe.transform(items, store.page.start, store.page.end);\n return this._output = items;\n }\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { SmartClampPipe } from './smart-clamp.pipe';\n\n\n\n@NgModule({\n declarations: [\n SmartClampPipe\n ],\n imports: [\n CommonModule,\n ],\n exports: [\n SmartClampPipe\n ]\n})\nexport class SmartClampModule { }\n","import { Inject, Optional, Pipe } from '@angular/core';\nimport * as dayjs from 'dayjs';\nimport { SMART_EXP_TRANSFORMER, smartExpTransformer, SmartExpTransformer } from '@ng-atomic/common/utils';\n\n@Pipe({\n name: 'smartExp',\n pure: true,\n})\nexport class SmartExpPipe {\n constructor(\n @Optional() @Inject(SMART_EXP_TRANSFORMER) private transformer: SmartExpTransformer\n ) {\n this.transformer ??= smartExpTransformer;\n }\n\n transform(input: string | number | dayjs.Dayjs | any, key?: string): string {\n return this.transformer(input, key);\n }\n}","import { NgModule } from \"@angular/core\";\nimport { SmartExpPipe } from \"./smart-exp.pipe\";\n\n@NgModule({\n declarations: [SmartExpPipe],\n exports: [SmartExpPipe]\n})\nexport class SmartExpModule { }","import { Inject, InjectionToken, Optional, Pipe, PipeTransform } from '@angular/core';\n\ninterface Option<T> {\n name: string;\n value: T;\n}\n\ninterface InputField {\n type: 'input';\n}\n\ninterface DateInputField {\n type: 'date';\n}\n\ninterface SelectField<T> {\n type: 'select';\n options: Option<T>[];\n}\n\ninterface MultiSelectField<T> {\n type: 'multi-select';\n options: Option<T>[];\n}\n\ntype FormField<V> = InputField\n | DateInputField\n | SelectField<V>\n | MultiSelectField<V>;\n\nexport type FormFieldMap = Record<string, FormField<any>>;\n\nexport const FORM_FIELD_MAP = new InjectionToken<FormFieldMap>('[@ng-atomic] Smart Form Field');\n\n@Pipe({\n name: 'smartField',\n pure: true,\n})\nexport class SmartFieldPipe implements PipeTransform {\n\n constructor(\n @Optional() @Inject(FORM_FIELD_MAP) private map: Record<string, FormField<any>>\n ) {\n this.map ??= {\n createdAt: { type: 'date' },\n updatedAt: { type: 'date' },\n deletedAt: { type: 'date' },\n };\n }\n\n transform(key: string): FormField<any> {\n return this.map[key] ?? {type: 'input'};\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { SmartFieldPipe } from './smart-field.pipe';\n\n\n\n@NgModule({\n declarations: [\n SmartFieldPipe\n ],\n imports: [\n CommonModule\n ],\n exports: [\n SmartFieldPipe\n ]\n})\nexport class SmartFieldModule { }\n","import { Pipe, PipeTransform } from '@angular/core';\nimport { yenTransform } from '@ng-atomic/common/utils';\n\n@Pipe({\n name: 'yen'\n})\nexport class YenPipe implements PipeTransform {\n\n transform(value: number, _unit?: string): string {\n return yenTransform(value, _unit);\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { YenPipe } from './yen.pipe';\n\n\n\n@NgModule({\n declarations: [\n YenPipe\n ],\n imports: [\n CommonModule\n ],\n exports: [\n YenPipe\n ]\n})\nexport class YenModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAGa,eAAe,GAAG,IAAI,cAAc,CAAgB,iBAAiB,EAAE;MAMvE,UAAU;IACrB,YAAyD,GAAkB;;QAAlB,QAAG,GAAH,GAAG,CAAe;QACzE,MAAA,IAAI,CAAC,GAAG,oCAAR,IAAI,CAAC,GAAG,GAAK,EAAE,EAAC;KACjB;IAED,SAAS,CAAC,KAAa;;QACrB,mBAAO,IAAI,CAAC,GAAG,0CAAG,KAAK,oCAAK,KAAK,CAAC;KACnC;;oEAPU,UAAU,oBACW,eAAe;6EADpC,UAAU;oFAAV,UAAU;cAJtB,IAAI;eAAC;gBACJ,IAAI,EAAE,GAAG;gBACT,IAAI,EAAE,IAAI;aACX;;sBAEc,QAAQ;;sBAAI,MAAM;uBAAC,eAAe;;;MCOpC,YAAY;;wEAAZ,YAAY;6CAAZ,YAAY;iDAPd;YACP,YAAY;SACb;qFAKU,YAAY,mBATrB,UAAU,aAGV,YAAY,aAGZ,UAAU;oFAGD,YAAY;cAXxB,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,UAAU;iBACX;gBACD,OAAO,EAAE;oBACP,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,UAAU;iBACX;aACF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;oFAAd,cAAc;cAJ1B,IAAI;eAAC;gBACJ,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,IAAI;aACX;;sBAII,QAAQ;;sBAAI,MAAM;uBAAC,cAAc;;;MCxBzB,gBAAgB;;gFAAhB,gBAAgB;iDAAhB,gBAAgB;qDAPlB;YACP,YAAY;SACb;qFAKU,gBAAgB,mBATzB,cAAc,aAGd,YAAY,aAGZ,cAAc;oFAGL,gBAAgB;cAX5B,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,cAAc;iBACf;gBACD,OAAO,EAAE;oBACP,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,cAAc;iBACf;aACF;;;MCVY,OAAO;IAElB,SAAS,CAAC,KAAa,EAAE,KAAc;QACrC,OAAO,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;KACnC;;8DAJU,OAAO;0EAAP,OAAO;oFAAP,OAAO;cAHnB,IAAI;eAAC;gBACJ,IAAI,EAAE,KAAK;aACZ;;;MCYY,SAAS;;kEAAT,SAAS;0CAAT,SAAS;8CAPX;YACP,YAAY;SACb;qFAKU,SAAS,mBATlB,OAAO,aAGP,YAAY,aAGZ,OAAO;oFAGE,SAAS;cAXrB,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,OAAO;iBACR;gBACD,OAAO,EAAE;oBACP,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,OAAO;iBACR;aACF;;;AChBD;;;;;;"}
@@ -1,9 +1,43 @@
1
- import { ɵɵdefineInjectable, ɵsetClassMetadata, Injectable, ɵɵinject, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, NgModule } from '@angular/core';
1
+ import { isIsoString, toObject, smartExpTransformer, filterByQuery, SMART_EXP_TRANSFORMER } from '@ng-atomic/common/utils';
2
+ import * as dayjs from 'dayjs';
3
+ import { isDayjs } from 'dayjs';
4
+ import { unflatten, flatten } from 'flat';
5
+ import { omit, pick } from 'lodash';
6
+ import { ɵɵdefineInjectable, ɵsetClassMetadata, Injectable, ɵɵinject, Optional, Inject, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, NgModule } from '@angular/core';
2
7
  import { Subject } from 'rxjs';
3
8
  import { scan, map, distinctUntilChanged, delay } from 'rxjs/operators';
4
9
  import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
5
10
  import { CommonModule } from '@angular/common';
6
11
 
12
+ const isNumeric = (v) => !isNaN(Number(v));
13
+ const parseQuery = (v, k) => k.match(/id$/i)
14
+ ? v
15
+ : typeof v === 'string' && isIsoString(v)
16
+ ? dayjs(v)
17
+ : isNumeric(v)
18
+ ? Number(v)
19
+ : v;
20
+ class BaseFormService {
21
+ static fromQueryParams(obj) {
22
+ var _a, _b;
23
+ return Object.entries((_b = (_a = unflatten(obj)) === null || _a === void 0 ? void 0 : _a.form) !== null && _b !== void 0 ? _b : {}).reduce((m, [k, v]) => (Object.assign(Object.assign({}, m), { [k]: parseQuery(v, k) })), {});
24
+ }
25
+ static toQueryParams(obj) {
26
+ return flatten({ form: Object.entries(obj).reduce((m, [k, v]) => (Object.assign(Object.assign({}, m), { [k]: isDayjs(v) ? v.isValid() ? v.toISOString() : null : v })), {}) });
27
+ }
28
+ static dayjsKeys(object) {
29
+ return Object.entries(object).filter(([_, v]) => isDayjs(v)).map(([k]) => k);
30
+ }
31
+ static toValue(object) {
32
+ const keys = this.dayjsKeys(object);
33
+ return Object.assign(Object.assign({}, flatten(omit(toObject(object), keys))), pick(toObject(object), keys));
34
+ }
35
+ static fromValue(value) {
36
+ const keys = this.dayjsKeys(value);
37
+ return Object.assign(Object.assign({}, unflatten(omit(value, keys))), pick(value, keys));
38
+ }
39
+ }
40
+
7
41
  class LoadingService {
8
42
  constructor() {
9
43
  this.loadingEntries$ = new Subject();
@@ -32,6 +66,30 @@ LoadingService.ɵprov = ɵɵdefineInjectable({ token: LoadingService, factory: L
32
66
  }]
33
67
  }], function () { return []; }, null); })();
34
68
 
69
+ class QueryResolverService {
70
+ constructor(transformer) {
71
+ var _a;
72
+ this.transformer = transformer;
73
+ (_a = this.transformer) !== null && _a !== void 0 ? _a : (this.transformer = smartExpTransformer);
74
+ }
75
+ resolve(items, queryString, dlm = {}) {
76
+ return filterByQuery(items, queryString, dlm, this.transformer);
77
+ }
78
+ }
79
+ QueryResolverService.ɵfac = function QueryResolverService_Factory(t) { return new (t || QueryResolverService)(ɵɵinject(SMART_EXP_TRANSFORMER, 8)); };
80
+ QueryResolverService.ɵprov = ɵɵdefineInjectable({ token: QueryResolverService, factory: QueryResolverService.ɵfac, providedIn: 'root' });
81
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(QueryResolverService, [{
82
+ type: Injectable,
83
+ args: [{
84
+ providedIn: 'root'
85
+ }]
86
+ }], function () { return [{ type: undefined, decorators: [{
87
+ type: Optional
88
+ }, {
89
+ type: Inject,
90
+ args: [SMART_EXP_TRANSFORMER]
91
+ }] }]; }, null); })();
92
+
35
93
  class SnackBarService {
36
94
  constructor(snackBar) {
37
95
  this.snackBar = snackBar;
@@ -76,5 +134,5 @@ SnackBarModule.ɵinj = ɵɵdefineInjector({ imports: [[
76
134
  * Generated bundle index. Do not edit.
77
135
  */
78
136
 
79
- export { LoadingService, SnackBarModule, SnackBarService };
137
+ export { BaseFormService, LoadingService, QueryResolverService, SnackBarModule, SnackBarService };
80
138
  //# sourceMappingURL=ng-atomic-common-services.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ng-atomic-common-services.js","sources":["../../../../libs/common/services/loading/loading.service.ts","../../../../libs/common/services/snack-bar/snack-bar.service.ts","../../../../libs/common/services/snack-bar/snack-bar.module.ts","../../../../libs/common/services/ng-atomic-common-services.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { scan, map, distinctUntilChanged, delay } from 'rxjs/operators';\n\ntype LoadingMap = Record<string, boolean>;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class LoadingService {\n private loadingEntries$ = new Subject<[string, boolean]>();\n\n loadingMap: LoadingMap = {};\n loadingMap$ = this.loadingEntries$.pipe(\n scan((pre, [key, value]) => ({ ...pre, [key]: value }), {} as LoadingMap),\n map((m: LoadingMap) => Object.entries(m)\n .filter(([k, v]: [string, boolean]) => v)\n .reduce((p, [k, v]) => ({ ...p, [k]: v }), {} as LoadingMap)),\n distinctUntilChanged((pre, cur) => JSON.stringify(pre) === JSON.stringify(cur)),\n );\n\n isLoading$ = this.loadingMap$.pipe(\n map((m) => !!Object.keys(m).length),\n delay(0),\n );\n\n constructor() {\n this.loadingMap$.subscribe((m) => {\n this.loadingMap = m;\n });\n }\n\n setKey(key: string): void {\n this.loadingEntries$.next([key, true]);\n }\n\n removeKey(key: string): void {\n this.loadingEntries$.next([key, false]);\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { MatSnackBar } from '@angular/material/snack-bar';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class SnackBarService {\n\n constructor(private snackBar: MatSnackBar) {}\n\n openSnackBar(message: string, action?: string) {\n this.snackBar.open(message, action, {\n duration: 2000,\n });\n }\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\nimport { MatSnackBarModule } from '@angular/material/snack-bar';\n\n@NgModule({\n declarations: [],\n imports: [\n CommonModule,\n MatSnackBarModule\n ]\n})\nexport class SnackBarModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MASa,cAAc;IAiBzB;QAhBQ,oBAAe,GAAG,IAAI,OAAO,EAAqB,CAAC;QAE3D,eAAU,GAAe,EAAE,CAAC;QAC5B,gBAAW,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CACrC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,sCAAW,GAAG,KAAE,CAAC,GAAG,GAAG,KAAK,IAAG,EAAE,EAAgB,CAAC,EACzE,GAAG,CAAC,CAAC,CAAa,K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,EAAE;YAClC,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;KACJ;;8EARU,eAAe;oDAAf,eAAe,WAAf,eAAe,mBAFd,MAAM;oFAEP,eAAe;cAH3B,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB;;;MCMY,cAAc;;4EAAd,cAAc;+CAAd,cAAc;mDALhB;YACP,YAAY;YACZ,iBAAiB;SAClB;qFAEU,cAAc,cAJvB,YAAY;QACZ,iBAAiB;oFAGR,cAAc;cAP1B,QAAQ;eAAC;gBACR,YAAY,EAAE,EAAE;gBAChB,OAAO,EAAE;oBACP,YAAY;oBACZ,iBAAiB;iBAClB;aACF;;;ACXD;;;;;;"}
1
+ {"version":3,"file":"ng-atomic-common-services.js","sources":["../../../../libs/common/services/form/form.service.ts","../../../../libs/common/services/loading/loading.service.ts","../../../../libs/common/services/query-resolver/query-resolver.service.ts","../../../../libs/common/services/snack-bar/snack-bar.service.ts","../../../../libs/common/services/snack-bar/snack-bar.module.ts","../../../../libs/common/services/ng-atomic-common-services.ts"],"sourcesContent":["import { toObject, isIsoString } from '@ng-atomic/common/utils';\nimport * as dayjs from 'dayjs';\nimport { unflatten, flatten } from 'flat';\nimport { omit, pick } from 'lodash';\n\nconst isNumeric = (v: string): boolean => !isNaN(Number(v)) \n\nconst parseQuery = (v: string, k: string): any => k.match(/id$/i) \n ? v\n : typeof v === 'string' && isIsoString(v) \n ? dayjs(v) \n : isNumeric(v)\n ? Number(v)\n : v;\n\nexport class BaseFormService {\n static fromQueryParams<T>(obj: T): object {\n return Object.entries((unflatten(obj) as any)?.form ?? {}).reduce((m, [k, v]: [string, string]) => ({\n ...m, [k]: parseQuery(v, k),\n }), {});\n }\n\n static toQueryParams<T>(obj: object): T { \n return flatten({form: Object.entries(obj).reduce((m, [k, v]) => ({\n ...m, [k]: dayjs.isDayjs(v) ? v.isValid() ? v.toISOString() : null : v,\n }), {})});\n }\n\n static dayjsKeys(object: object): string[] {\n return Object.entries(object).filter(([_, v]) => dayjs.isDayjs(v)).map(([k]) => k);\n }\n\n static toValue(object: object): object {\n const keys = this.dayjsKeys(object);\n return {...flatten(omit(toObject(object), keys)), ...pick(toObject(object), keys)};\n }\n\n static fromValue(value: object): object {\n const keys = this.dayjsKeys(value);\n return {...unflatten(omit(value, keys)), ...pick(value, keys)};\n }\n}","import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { scan, map, distinctUntilChanged, delay } from 'rxjs/operators';\n\ntype LoadingMap = Record<string, boolean>;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class LoadingService {\n private loadingEntries$ = new Subject<[string, boolean]>();\n\n loadingMap: LoadingMap = {};\n loadingMap$ = this.loadingEntries$.pipe(\n scan((pre, [key, value]) => ({ ...pre, [key]: value }), {} as LoadingMap),\n map((m: LoadingMap) => Object.entries(m)\n .filter(([k, v]: [string, boolean]) => v)\n .reduce((p, [k, v]) => ({ ...p, [k]: v }), {} as LoadingMap)),\n distinctUntilChanged((pre, cur) => JSON.stringify(pre) === JSON.stringify(cur)),\n );\n\n isLoading$ = this.loadingMap$.pipe(\n map((m) => !!Object.keys(m).length),\n delay(0),\n );\n\n constructor() {\n this.loadingMap$.subscribe((m) => {\n this.loadingMap = m;\n });\n }\n\n setKey(key: string): void {\n this.loadingEntries$.next([key, true]);\n }\n\n removeKey(key: string): void {\n this.loadingEntries$.next([key, false]);\n }\n}\n","import { Inject, Injectable, Optional } from \"@angular/core\";\nimport { filterByQuery } from \"@ng-atomic/common/utils\";\nimport { SmartExpTransformer, smartExpTransformer, SMART_EXP_TRANSFORMER } from '@ng-atomic/common/utils';\n\n\n@Injectable({\n providedIn: 'root'\n})\nexport class QueryResolverService {\n constructor(\n @Optional() @Inject(SMART_EXP_TRANSFORMER) private transformer?: SmartExpTransformer,\n ) {\n this.transformer ??= smartExpTransformer;\n }\n\n resolve<T>(items: T[], queryString: string, dlm: Record<string, string> = {}): T[] {\n return filterByQuery(items, queryString, dlm, this.transformer);\n }\n}","import { Injectable } from '@angular/core';\n\nimport { MatSnackBar } from '@angular/material/snack-bar';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class SnackBarService {\n\n constructor(private snackBar: MatSnackBar) {}\n\n openSnackBar(message: string, action?: string) {\n this.snackBar.open(message, action, {\n duration: 2000,\n });\n }\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\nimport { MatSnackBarModule } from '@angular/material/snack-bar';\n\n@NgModule({\n declarations: [],\n imports: [\n CommonModule,\n MatSnackBarModule\n ]\n})\nexport class SnackBarModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["dayjs.isDayjs"],"mappings":";;;;;;;;;;;AAKA,MAAM,SAAS,GAAG,CAAC,CAAS,KAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAE3D,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,KAAU,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;MAC7D,CAAC;MACD,OAAO,CAAC,KAAK,QAAQ,IAAI,WAAW,CAAC,CAAC,CAAC;UACvC,KAAK,CAAC,CAAC,CAAC;UACR,SAAS,CAAC,CAAC,CAAC;cACZ,MAAM,CAAC,CAAC,CAAC;cACT,CAAC,CAAC;MAEO,eAAe;IAC1B,OAAO,eAAe,CAAI,GAAM;;QAC9B,OAAO,MAAM,CAAC,OAAO,aAAE,SAAS,CAAC,GAAG,CAAS,0CAAE,IAAI,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAmB,sCACzF,CAAC,KAAE,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,IAC3B,EAAE,EAAE,CAAC,CAAC;KACT;IAED,OAAO,aAAa,CAAI,GAAW;QACjC,OAAO,OAAO,CAAC,EAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,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