@idevs/corelib 0.0.35 → 0.0.37

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.
@@ -2,7 +2,7 @@
2
2
  export declare class DateMonthEditor extends SelectEditor {
3
3
  private months;
4
4
  constructor(hidden: JQuery, opt: DateMonthEditorOptions);
5
- getItemsList(): string[];
5
+ get valueAsMonth(): number;
6
6
  getItems(): any[];
7
7
  }
8
8
  export interface DateMonthEditorOptions extends SelectEditorOptions {
@@ -5,14 +5,14 @@
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { Decorators, SelectEditor } from '@serenity-is/corelib';
8
+ import { indexOf } from '@serenity-is/corelib/q';
8
9
  let DateMonthEditor = class DateMonthEditor extends SelectEditor {
9
10
  constructor(hidden, opt) {
10
11
  super(hidden, opt);
11
- this.months = [];
12
12
  this.updateItems();
13
13
  }
14
- getItemsList() {
15
- return this.months;
14
+ get valueAsMonth() {
15
+ return indexOf(this.months, x => x == this.value);
16
16
  }
17
17
  getItems() {
18
18
  var _a, _b;
@@ -20,6 +20,7 @@ let DateMonthEditor = class DateMonthEditor extends SelectEditor {
20
20
  if (opt.items != null && opt.items.length >= 1) {
21
21
  return opt.items;
22
22
  }
23
+ this.months = [];
23
24
  const locale = (_a = opt.locale) !== null && _a !== void 0 ? _a : 'en';
24
25
  const options = { month: (_b = opt.display) !== null && _b !== void 0 ? _b : '2-digit' };
25
26
  for (let i = 11; i >= 0; i--) {
@@ -36,7 +37,7 @@ let DateMonthEditor = class DateMonthEditor extends SelectEditor {
36
37
  }
37
38
  };
38
39
  DateMonthEditor = __decorate([
39
- Decorators.registerEditor('Serenity.DateMonthEditor')
40
+ Decorators.registerEditor('DateMonthEditor')
40
41
  ], DateMonthEditor);
41
42
  export { DateMonthEditor };
42
43
  //# sourceMappingURL=dateMonthEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateMonthEditor.js","sourceRoot":"","sources":["../../src/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AAE,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;SACvE;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF,CAAA;AAtCY,eAAe;IAD3B,UAAU,CAAC,cAAc,CAAC,0BAA0B,CAAC;GACzC,eAAe,CAsC3B;SAtCY,eAAe","sourcesContent":["import { Decorators, SelectEditor, SelectEditorOptions } from '@serenity-is/corelib'\n\n@Decorators.registerEditor('Serenity.DateMonthEditor')\nexport class DateMonthEditor extends SelectEditor {\n private months: string[] = []\n\n constructor(hidden: JQuery, opt: DateMonthEditorOptions) {\n super(hidden, opt)\n\n this.updateItems()\n }\n\n getItemsList() {\n return this.months\n }\n\n getItems() {\n const opt = this.options as DateMonthEditorOptions\n\n if (opt.items != null && opt.items.length >= 1) {\n return opt.items\n }\n\n const locale = opt.locale ?? 'en'\n const options = { month: opt.display ?? '2-digit' }\n\n for (let i = 11; i >= 0; i--) {\n this.months.push(new Date(2000, i, 1).toLocaleDateString(locale, options))\n }\n\n if (opt.descending) {\n return this.months\n }\n\n const months: string[] = []\n for (let i1 = 0; i1 <= 11; i1++) {\n months.push(new Date(2000, i1, 1).toLocaleDateString(locale, options))\n }\n\n return months\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface DateMonthEditorOptions extends SelectEditorOptions {\n display?: '2-digit' | 'short' | 'long'\n locale?: 'en' | 'th'\n descending?: boolean\n}\n"]}
1
+ {"version":3,"file":"dateMonthEditor.js","sourceRoot":"","sources":["../../src/editors/dateMonthEditor.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAuB,MAAM,sBAAsB,CAAA;AACpF,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAGzC,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,YAAY;IAG/C,YAAY,MAAc,EAAE,GAA2B;QACrD,KAAK,CAAC,MAAM,E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,CAAC;CACF,CAAA;AAvCY,eAAe;IAD3B,UAAU,CAAC,cAAc,CAAC,iBAAiB,CAAC;GAChC,eAAe,CAuC3B;SAvCY,eAAe","sourcesContent":["import { Decorators, SelectEditor, SelectEditorOptions } from '@serenity-is/corelib'\nimport { indexOf } from '@serenity-is/corelib/q'\n\n@Decorators.registerEditor('DateMonthEditor')\nexport class DateMonthEditor extends SelectEditor {\n private months: string[]\n\n constructor(hidden: JQuery, opt: DateMonthEditorOptions) {\n super(hidden, opt)\n\n this.updateItems()\n }\n\n get valueAsMonth() {\n return indexOf(this.months, x => x == this.value)\n }\n\n getItems() {\n const opt = this.options as DateMonthEditorOptions\n\n if (opt.items != null && opt.items.length >= 1) {\n return opt.items\n }\n\n this.months = []\n const locale = opt.locale ?? 'en'\n const options = { month: opt.display ?? '2-digit' }\n\n for (let i = 11; i >= 0; i--) {\n this.months.push(new Date(2000, i, 1).toLocaleDateString(locale, options))\n }\n\n if (opt.descending) {\n return this.months\n }\n\n const months: string[] = []\n for (let i1 = 0; i1 <= 11; i1++) {\n months.push(new Date(2000, i1, 1).toLocaleDateString(locale, options))\n }\n\n return months\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface DateMonthEditorOptions extends SelectEditorOptions {\n display?: '2-digit' | 'short' | 'long'\n locale?: 'en' | 'th'\n descending?: boolean\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idevs/corelib",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "Extended library for Serenity Framework",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,8 +1,9 @@
1
1
  import { Decorators, SelectEditor, SelectEditorOptions } from '@serenity-is/corelib'
2
+ import { indexOf } from '@serenity-is/corelib/q'
2
3
 
3
- @Decorators.registerEditor('Serenity.DateMonthEditor')
4
+ @Decorators.registerEditor('DateMonthEditor')
4
5
  export class DateMonthEditor extends SelectEditor {
5
- private months: string[] = []
6
+ private months: string[]
6
7
 
7
8
  constructor(hidden: JQuery, opt: DateMonthEditorOptions) {
8
9
  super(hidden, opt)
@@ -10,8 +11,8 @@ export class DateMonthEditor extends SelectEditor {
10
11
  this.updateItems()
11
12
  }
12
13
 
13
- getItemsList() {
14
- return this.months
14
+ get valueAsMonth() {
15
+ return indexOf(this.months, x => x == this.value)
15
16
  }
16
17
 
17
18
  getItems() {
@@ -21,6 +22,7 @@ export class DateMonthEditor extends SelectEditor {
21
22
  return opt.items
22
23
  }
23
24
 
25
+ this.months = []
24
26
  const locale = opt.locale ?? 'en'
25
27
  const options = { month: opt.display ?? '2-digit' }
26
28