@creative-web-solution/front-library 7.1.1 → 7.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## 7.1.2
5
+
6
+ * Typescript: Fix some type
7
+
8
+
4
9
  ## 7.1.1
5
10
 
6
11
  * Validator: Fix error message generation
@@ -33,7 +33,7 @@
33
33
  * url.removeAll()
34
34
  * ```
35
35
  */
36
- export class UrlParser {
36
+ export class UrlParser implements FLib.Helpers.UrlParser {
37
37
  /** Complete url without userInfo and anchor. Ex: https://demo.domain.com:1337/section/page.html?param=2 */
38
38
  absolute = '';
39
39
  /** Complete url with anchor but without userInfo. Ex: https://demo.domain.com:1337/section/page.html?param=2#anchor */
@@ -5,7 +5,7 @@ import { next } from '../../DOM/Traversing';
5
5
  /**
6
6
  * Tab of an accordion
7
7
  */
8
- export default class Tab {
8
+ export default class Tab implements FLib.Accordion.Tab {
9
9
  #isOpen: boolean;
10
10
  #originalOpenedState: boolean;
11
11
  #$TAB_PANNEL: HTMLElement | null;
@@ -86,9 +86,9 @@ const DEFAULT_OPTIONS = {
86
86
  export default class Accordion {
87
87
  #options: FLib.Accordion.Options;
88
88
  #$tabs: NodeListOf<HTMLElement>;
89
- #tablist: Tab[];
89
+ #tablist: FLib.Accordion.Tab[];
90
90
  #status: string;
91
- #lastOpenedTab: Tab | null = null;
91
+ #lastOpenedTab: FLib.Accordion.Tab | null = null;
92
92
 
93
93
 
94
94
  #STATUS_ON = 'STATUS_ON';
@@ -107,7 +107,7 @@ export default class Accordion {
107
107
  }
108
108
 
109
109
 
110
- #onOpenTab = ( tab: Tab ): void => {
110
+ #onOpenTab = ( tab: FLib.Accordion.Tab ): void => {
111
111
  if ( this.#lastOpenedTab ) {
112
112
  this.#lastOpenedTab.close( true );
113
113
  }
@@ -127,7 +127,7 @@ export default class Accordion {
127
127
  this.#tablist.push( new Tab( $tab, {
128
128
  ...this.#options,
129
129
  index,
130
- "onOpenTab": this.#options.allowMultipleTab ? null : this.#onOpenTab
130
+ "onOpenTab": this.#options.allowMultipleTab ? undefined : this.#onOpenTab
131
131
  } ) );
132
132
  } );
133
133
  }
@@ -4,7 +4,7 @@ import Popin from './Popin';
4
4
  import { CLICK_EVENT_NAME } from './Tools';
5
5
 
6
6
 
7
- export default class PopinBackground {
7
+ export default class PopinBackground implements FLib.Popin.Background {
8
8
 
9
9
  #$bgLayer: HTMLElement;
10
10
  #isOpened: boolean;
@@ -14,7 +14,7 @@ import { CLICK_EVENT_NAME, defaultOptions, toggleTabIndex } from './Tools';
14
14
  * let controller = new PopinController( popinOptions );
15
15
  * popin.loadForm( $form );
16
16
  */
17
- export default class PopinController {
17
+ export default class PopinController implements FLib.Popin.Controller {
18
18
  #options: FLib.Popin.Options;
19
19
  #selectors: FLib.Popin.SelectorsOptions;
20
20
  #background: PopinBackground;
@@ -14,7 +14,7 @@ const defaultOptions: FLib.SkinCheckbox.Options = {
14
14
  * Skin an HTML input checkbox element.
15
15
  * You can access the skin API in the __skinAPI property of the $checkbox HTMLElement or its wrapper.
16
16
  */
17
- export default class SkinCheckbox {
17
+ export default class SkinCheckbox implements FLib.SkinCheckbox.SkinCheckbox {
18
18
 
19
19
  #$checkbox!: FLib.SkinCheckbox.CustomCheckbox;
20
20
  #options!: FLib.SkinCheckbox.Options;
@@ -21,7 +21,7 @@ const defaultOptions: FLib.SkinFile.Options = {
21
21
  /**
22
22
  * Skin an HTML input file element.
23
23
  */
24
- export default class SkinFile {
24
+ export default class SkinFile implements FLib.SkinFile.SkinFile {
25
25
 
26
26
  #options: FLib.SkinFile.Options;
27
27
  #$parent: FLib.SkinFile.CustomInputFileParent;
@@ -26,7 +26,7 @@ const defaultOptions = {
26
26
  * } );
27
27
  * ```
28
28
  */
29
- export default class SkinRadioButton {
29
+ export default class SkinRadioButton implements FLib.SkinRadio.SkinRadio {
30
30
  #$radio!: FLib.SkinRadio.CustomRadioButton;
31
31
  #options!: FLib.SkinRadio.Options;
32
32
  #$parent!: FLib.SkinRadio.CustomRadioButtonParent;
@@ -37,7 +37,7 @@ const defaultOptions: FLib.SkinSelect.Options = {
37
37
  * Skin an HTML select element. If options.full is set to true, also skin the options list.
38
38
  * You can access the skin API in the __skinAPI property of the $select HTMLElement or its wrapper.
39
39
  */
40
- export default class SkinSelect {
40
+ export default class SkinSelect implements FLib.SkinSelect.SkinSelect {
41
41
  #$select: FLib.SkinSelect.CustomSelect;
42
42
  #loading!: boolean;
43
43
  #options!: FLib.SkinSelect.Options;
@@ -4,7 +4,7 @@ import { on, off } from '../../Events/EventsManager';
4
4
  /**
5
5
  * Tab of a tabs list
6
6
  */
7
- export default class Tab {
7
+ export default class Tab implements FLib.Tabs.Tab {
8
8
 
9
9
  #options: FLib.Tabs.TabOptions;
10
10
  #$TAB: HTMLElement;
@@ -98,10 +98,10 @@ export default class Tabs {
98
98
  #options: FLib.Tabs.Options;
99
99
  #$TABS_LIST: HTMLElement;
100
100
  #$TABS: NodeList;
101
- #tablist: Tab[];
101
+ #tablist: FLib.Tabs.Tab[];
102
102
  #status: string;
103
103
  #VERTICAL_MODE: boolean;
104
- #lastOpenedTab: Tab | undefined;
104
+ #lastOpenedTab: FLib.Tabs.Tab | undefined;
105
105
  #keyboard: KeyboardHandler | undefined;
106
106
  #$tabsWrapper: HTMLElement;
107
107
 
@@ -124,7 +124,7 @@ export default class Tabs {
124
124
  }
125
125
 
126
126
 
127
- #onOpenTab = ( tab: Tab ): void => {
127
+ #onOpenTab = ( tab: FLib.Tabs.Tab ): void => {
128
128
  if ( this.#lastOpenedTab ) {
129
129
  this.#lastOpenedTab.close( true );
130
130
  }
@@ -8,7 +8,7 @@ import { getRadioList } from '../Tools/RadioButton';
8
8
  /*
9
9
  * Handle one input
10
10
  */
11
- export default class Input {
11
+ export default class Input implements FLib.Validator.Input {
12
12
  #isRadio: boolean;
13
13
  #inputType: string;
14
14
  #inputId: string;
@@ -5,7 +5,7 @@ import { getValue } from '../../../Helpers/GetValue';
5
5
  * Used to make one validation on one input
6
6
  * Store the state (valid or not) between validations
7
7
  */
8
- export default class InputValidator {
8
+ export default class InputValidator implements FLib.Validator.InputValidator {
9
9
  #$input: HTMLElement;
10
10
  #name: string;
11
11
  #isAsynch: boolean;
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Front Library
2
2
 
3
- @version: 7.1.1
3
+ @version: 7.1.2
4
4
 
5
5
 
6
6
  ## Use
@@ -1,6 +1,11 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace Accordion {
3
3
 
4
+ interface Tab {
5
+ close( autoClose?: boolean ): this;
6
+ destroy(): this;
7
+ }
8
+
4
9
  type AnimationFunction = ( $tab: HTMLElement, $panel: HTMLElement ) => Promise<void>;
5
10
  type Callback = ( $tab: HTMLElement, $panel: HTMLElement ) => void;
6
11
  type CloseCallback = ( $tab: HTMLElement, $panel: HTMLElement, autoclose: boolean ) => void;
@@ -21,7 +26,7 @@ namespace FLib {
21
26
  onOpenAtStart: Callback;
22
27
  onOpen: Callback;
23
28
  onClose: CloseCallback;
24
- animations: AnimationOptions;
29
+ animations: Partial<AnimationOptions>;
25
30
  }
26
31
 
27
32
  interface OptionsInit extends Partial<Options> {
@@ -29,7 +34,7 @@ namespace FLib {
29
34
  }
30
35
 
31
36
  interface TabOptions extends Options {
32
- onOpenTab: (( tab: Tab ) => void) | null;
37
+ onOpenTab?: ( tab: Tab ) => void;
33
38
  index: number;
34
39
  }
35
40
  }
@@ -1,9 +1,8 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace Autocomplete {
3
3
  type Item = {
4
4
  name: string;
5
- [ key: string ]: any;
6
- }
5
+ } & Record<string, any>
7
6
 
8
7
  type LayerPosition = 'top' | 'bottom';
9
8
 
package/Types/DOM.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace DOM {
3
3
  type ClassInput = Element | Element[] | Node | NodeList;
4
4
 
@@ -1,4 +1,4 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace DragSlider {
3
3
  type CallbackParam = {
4
4
  item: any;
@@ -13,7 +13,7 @@ namespace FLib {
13
13
  isFirst: boolean;
14
14
  isLast: boolean;
15
15
  $item: HTMLElement;
16
- info: OffsetType;
16
+ info: FLib.DOM.Offset;
17
17
  }
18
18
 
19
19
  type DeltaMove = {
@@ -1,4 +1,4 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace Events {
3
3
 
4
4
  /**
@@ -26,7 +26,7 @@ namespace FLib {
26
26
  interface DataRegistry {
27
27
  $element: Element;
28
28
  eventName: string;
29
- options: OnOptionsType;
29
+ options: OnOptions;
30
30
  delegate?: ( e ) => void;
31
31
  }
32
32
 
@@ -156,7 +156,7 @@ namespace FLib {
156
156
  /** click */
157
157
  click?: Callback;
158
158
  /** touchend on touch device, click on other */
159
- tap?: (( e: Event, $target: HTMLElement, coords: CoordsType, type: string ) => void);
159
+ tap?: (( e: Event, $target: HTMLElement, coords: Coords, type: string ) => void);
160
160
  swipeLeft?: SwipeCallback;
161
161
  swipeRight?: SwipeCallback;
162
162
  swipeUp?: SwipeCallback;
@@ -179,12 +179,12 @@ namespace FLib {
179
179
  */
180
180
  namespace History {
181
181
  type StateObject = {
182
- url: UrlParser;
182
+ url: FLib.Helpers.UrlParser;
183
183
  state: any;
184
184
  title: string;
185
185
  }
186
186
 
187
- type Callback = ( url: UrlParser, state: any ) => void;
187
+ type Callback = ( url: FLib.Helpers.UrlParser, state: any ) => void;
188
188
  }
189
189
 
190
190
 
@@ -378,10 +378,10 @@ namespace FLib {
378
378
 
379
379
 
380
380
  type CallbackParam = {
381
- windowInfo: WindowInfoType,
382
- scrollInfo: ScrollInfoType,
383
- documentInfo: DocumentInfoType,
384
- viewportInfo: ViewportInfoType
381
+ windowInfo: WindowInfo,
382
+ scrollInfo: ScrollInfo,
383
+ documentInfo: DocumentInfo,
384
+ viewportInfo: ViewportInfo
385
385
  }
386
386
 
387
387
  type Callback = ( info: CallbackParam, type: Type, e? ) => void;
@@ -1,4 +1,4 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace GLImageTransition {
3
3
  type FitType = 'cover' | 'contains';
4
4
 
@@ -1,4 +1,4 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace GlobalState {
3
3
  type Options = {
4
4
  alwaysDispatch: boolean;
@@ -1,4 +1,4 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace Helpers {
3
3
  namespace Color {
4
4
  type RenderType = 'obj' | 'hex' | 'rgba';
@@ -26,5 +26,38 @@ namespace FLib {
26
26
  path: string;
27
27
  }
28
28
  }
29
+
30
+ interface UrlParser {
31
+ absolute: string;
32
+ absolute2: string;
33
+ anchor: string;
34
+ authority: string;
35
+ directory: string;
36
+ file: string;
37
+ full: string;
38
+ full2: string;
39
+ host: string;
40
+ location;
41
+ password: string;
42
+ path: string;
43
+ port: string;
44
+ protocol: string;
45
+ query: string;
46
+ queryKey: Record<string, string>;
47
+ relative: string;
48
+ relative2: string;
49
+ source: string;
50
+ user: string;
51
+ userInfo: string;
52
+ isAnchor: boolean;
53
+ isSameDomain: boolean;
54
+
55
+ init( url: string ): void;
56
+ setAnchor( anchor: string ): this;
57
+ getParam( key: string ): string;
58
+ setParam( keys: string | Record<string, string>, value?: string ): this;
59
+ removeParam( keys: string | string[] ): this
60
+ removeAll(): this;
61
+ }
29
62
  }
30
63
  }
@@ -1,4 +1,4 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace Notifications {
3
3
  type Type = 'info' | 'success' | 'warning' | 'danger';
4
4
 
@@ -38,8 +38,8 @@ namespace FLib {
38
38
  info: string;
39
39
  };
40
40
  animations: {
41
- show: ( $notification, options ) => Promise
42
- hide: ( $notification, options ) => Promise
41
+ show: ( $notification, options ) => Promise<any>
42
+ hide: ( $notification, options ) => Promise<any>
43
43
  };
44
44
  }
45
45
 
package/Types/Popin.d.ts CHANGED
@@ -1,8 +1,26 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace Popin {
3
3
  type AnimationFunction = ( $element: HTMLElement ) => Promise<void>;
4
4
  type ResponseType = 'arrayBuffer' | 'blob' | 'json' | 'text' | 'formData';
5
5
 
6
+ interface Controller {
7
+ load( url: string, data: RequestInit, type?: FLib.Popin.ResponseType ): Promise<void>
8
+ loadForm( $form: HTMLFormElement ): Promise<void>
9
+ loadLink( $link: HTMLAnchorElement ): Promise<void>
10
+ set( html: string, openFirst?: boolean ): Promise<void>
11
+ clear(): void;
12
+ close(): Promise<void>;
13
+ open(): Promise<void>;
14
+ destroy(): this;
15
+ }
16
+
17
+ interface Background {
18
+ isOpened: boolean;
19
+ open(): Promise<any>;
20
+ close(): Promise<any>;
21
+ destroy(): void;
22
+ }
23
+
6
24
  interface TemplatesOptions {
7
25
  /** @defaultValue `<div class="popin-loader"></div>` */
8
26
  popinLoader: string;
@@ -1,4 +1,4 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace ScrollSnap {
3
3
  type SnapType = 'scroll' | 'api';
4
4
 
@@ -1,5 +1,14 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace SkinCheckbox {
3
+ interface SkinCheckbox {
4
+ check(): this;
5
+ uncheck(): this;
6
+ enable(): this;
7
+ disable(): this;
8
+ setInvalid(): this;
9
+ setValid(): this;
10
+ }
11
+
3
12
  type Options = {
4
13
  /** @defaultValue <span class="cb-skin"></span> */
5
14
  wrap: string;
@@ -1,5 +1,12 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace SkinFile {
3
+ interface SkinFile {
4
+ enable(): this;
5
+ disable(): this;
6
+ setInvalid(): this;
7
+ setValid(): this;
8
+ }
9
+
3
10
  type Options = {
4
11
  /** @defaultValue .file-skin */
5
12
  selector: string;
@@ -1,5 +1,14 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace SkinRadio {
3
+ interface SkinRadio {
4
+ check(): this;
5
+ uncheck(): this;
6
+ enable(): this;
7
+ disable(): this;
8
+ setInvalid(): this;
9
+ setValid(): this;
10
+ }
11
+
3
12
  type Options = {
4
13
  /** @defaultValue <span class="rb-skin"></span> */
5
14
  wrap: string;
@@ -1,5 +1,18 @@
1
- namespace FLib {
1
+ declare declare namespace FLib {
2
2
  namespace SkinSelect {
3
+ interface SkinSelect {
4
+ enable(): this;
5
+ disable(): this;
6
+ setInvalid(): this;
7
+ setValid(): this;
8
+ setLoading(): this
9
+ unsetLoading(): this
10
+ updateTitle(): this
11
+ select( optionOrIndex: HTMLElement | number ): this
12
+ updateOptions( optionsArray?: FLib.SkinSelect.OptionArray[] ): this
13
+ }
14
+
15
+
3
16
  type Options = {
4
17
  /**
5
18
  * If true, skin event the option list
package/Types/Slider.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace Slider {
3
3
  type SlideDirection = -1 | 1;
4
4
 
package/Types/Tabs.d.ts CHANGED
@@ -1,25 +1,32 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace Tabs {
3
3
  type AnimationFunction = ( $tab: HTMLElement, $panel: HTMLElement ) => Promise<void>;
4
4
  type Callback = ( $tab: HTMLElement, $panel: HTMLElement, autoClose?: boolean ) => void;
5
5
 
6
+ interface Tab {
7
+ isOpened: boolean;
8
+ index: number;
9
+ close( autoClose?: boolean ): this;
10
+ open( autoOpen?: boolean ): this;
11
+ destroy(): this;
12
+ }
6
13
 
7
14
  type Options = {
8
15
  /** @defaultValue 'li[aria-selected]' */
9
16
  tabSelector: string;
10
- onOpenAtStart?: TabsCallbackType;
11
- onOpen?: TabsCallbackType;
12
- onClose?: TabsCallbackType;
17
+ onOpenAtStart?: Callback;
18
+ onOpen?: Callback;
19
+ onClose?: Callback;
13
20
  animations: {
14
- open: TabsAnimationFunctionType;
15
- close: TabsAnimationFunctionType;
16
- destroy: TabsAnimationFunctionType;
21
+ open: AnimationFunction;
22
+ close: AnimationFunction;
23
+ destroy: AnimationFunction;
17
24
  }
18
25
  }
19
26
 
20
27
 
21
28
  type TabOptions = Options & {
22
- onOpenTab: (( tab: Tab ) => void) | null;
29
+ onOpenTab?: ( tab: Tab ) => void;
23
30
  index: number;
24
31
  }
25
32
  }
@@ -1,4 +1,4 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace Validator {
3
3
  type ValidationState = {
4
4
  $input: HTMLElement;
@@ -18,6 +18,33 @@ namespace FLib {
18
18
  validate: ValidateFunction;
19
19
  }
20
20
 
21
+ interface InputValidator {
22
+ $input: HTMLElement;
23
+ name: string;
24
+ isAsynch: boolean;
25
+ extraMessages: string[];
26
+ extraErrorMessages: string[];
27
+ data: any;
28
+ validate( isLiveValidation: boolean ): Promise<void>;
29
+ isValid(): boolean;
30
+ getData(): any;
31
+ }
32
+
33
+ interface Input {
34
+ $input: HTMLElement;
35
+ $label: HTMLElement | undefined;
36
+ hasError: boolean;
37
+ isLiveValidation: boolean;
38
+ $radioGroup: CustomValidatorRadioInput[] | undefined;
39
+ $otherRadioOfGroup: CustomValidatorRadioInput[];
40
+ hasValidator: boolean;
41
+ getErrors(): InputValidator[];
42
+ getErrorMessages( _locale?: { [ key: string ]: string } ): { message: string, label: string, type: string }[];
43
+ isValid(): Promise<void>;
44
+ getData(): any[];
45
+ destroy(): this
46
+ }
47
+
21
48
 
22
49
  type ValidateFunction = ( $input: HTMLElement, value: string | string[], isLiveValidation: boolean, validatorOptions ) => Promise<ValidationState>
23
50
 
@@ -50,13 +77,13 @@ namespace FLib {
50
77
  liveValidation?: {
51
78
  onValidate?: ( input: Input, event ) => void;
52
79
  onInvalidate?: ( input: Input, event ) => void;
53
- eventsName: {
80
+ eventsName?: {
54
81
  /** @defaultValue change */
55
- optin: string;
82
+ optin?: string;
56
83
  /** @defaultValue change */
57
- select: string;
84
+ select?: string;
58
85
  /** @defaultValue input */
59
- inputText: string;
86
+ inputText?: string;
60
87
  }
61
88
  eventsHook
62
89
  }
@@ -1,4 +1,4 @@
1
- namespace FLib {
1
+ declare namespace FLib {
2
2
  namespace YouTubePlayer {
3
3
  type Options = {
4
4
  height: number;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@creative-web-solution/front-library",
3
3
  "title": "Frontend library",
4
4
  "description": "Frontend functions and modules",
5
- "version": "7.1.1",
5
+ "version": "7.1.2",
6
6
  "homepage": "https://github.com/creative-web-solution/front-library",
7
7
  "author": "Creative Web Solution <contact@cws-studio.com> (https://www.cws-studio.com)",
8
8
  "keywords": [],