bfg-common 1.5.236 → 1.5.238

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.5.236",
4
+ "version": "1.5.238",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",
@@ -0,0 +1,18 @@
1
+ import { defineNuxtPlugin } from '#app'
2
+ export default defineNuxtPlugin(() => {
3
+ const isObjectEmpty = (obj: any): boolean => {
4
+ for (const i in obj) {
5
+ // eslint-disable-next-line no-prototype-builtins
6
+ if (obj.hasOwnProperty(i)) {
7
+ return false
8
+ }
9
+ }
10
+ return true
11
+ }
12
+
13
+ return {
14
+ provide: {
15
+ isObjectEmpty,
16
+ },
17
+ }
18
+ })
@@ -0,0 +1,18 @@
1
+ import { defineNuxtPlugin } from '#app'
2
+ export default defineNuxtPlugin(() => {
3
+ const number = function (): any {
4
+ const self: any = {}
5
+ self.format = function (n: number, format: string): string {
6
+ const formatter = new Intl.NumberFormat(format)
7
+ return formatter.format(n)
8
+ }
9
+
10
+ return self
11
+ }.call({})
12
+
13
+ return {
14
+ provide: {
15
+ number,
16
+ },
17
+ }
18
+ })
@@ -0,0 +1,70 @@
1
+ import { defineNuxtPlugin } from '#app'
2
+ import type { UI_I_PanelOptions } from '~/lib/models/plugins/panelStates/interfaces'
3
+
4
+ export default defineNuxtPlugin(() => {
5
+ const panelStates = function (): any {
6
+ const self: any = {}
7
+ let options: UI_I_PanelOptions = {
8
+ leftPanelWidth: 20,
9
+ topPanelHeight: 80,
10
+ isBottomPanelCollapsed: false,
11
+ }
12
+
13
+ self.setLeftPanelWidth = function (width: number): void {
14
+ options.leftPanelWidth = width
15
+
16
+ self.setPanelStatesInStorage()
17
+ }
18
+ self.setTopPanelHeight = function (height: number): void {
19
+ options.topPanelHeight = height
20
+
21
+ self.setPanelStatesInStorage()
22
+ }
23
+ self.bottomPanelCollapse = function (collapse: boolean): void {
24
+ options.isBottomPanelCollapsed = collapse
25
+
26
+ self.setPanelStatesInStorage()
27
+ }
28
+
29
+ self.setPanelStatesInStorage = function (): void {
30
+ useLocalStorage('panelStates', options)
31
+ self.emitChanges()
32
+ }
33
+ self.getPanelStatesOfStorage = function (): UI_I_PanelOptions {
34
+ let panelStates = useLocalStorage('panelStates')
35
+
36
+ if (!panelStates) {
37
+ // const parent = document.getElementById('default-layout-outer')
38
+ const parent = document.body
39
+ const parentHeight = parent?.clientHeight || 0
40
+ const onePercent = parentHeight / 100
41
+ const defaultRecentTasksHeight = 250
42
+
43
+ options.topPanelHeight =
44
+ (parentHeight - defaultRecentTasksHeight - 1.5) / onePercent
45
+
46
+ panelStates = options
47
+ }
48
+
49
+ options = panelStates
50
+
51
+ return panelStates
52
+ }
53
+
54
+ self.cb = (): void => {}
55
+ self.on = function (cb: () => any | void): void {
56
+ self.cb = cb
57
+ }
58
+ self.emitChanges = function (): void {
59
+ self.cb(options)
60
+ }
61
+
62
+ return self
63
+ }.call({})
64
+
65
+ return {
66
+ provide: {
67
+ panelStates,
68
+ },
69
+ }
70
+ })
package/plugins/text.ts CHANGED
@@ -1,48 +1,59 @@
1
- export default defineNuxtPlugin(() => {
2
- const text = function () {
3
- const self: any = {}
4
- self.toCapitalize = function (str: string): string {
5
- return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()
6
- }
7
- self.toLowerCaseFirstLetter = function (str: string): string {
8
- // TODO не используется
9
- return str.charAt(0).toLowerCase() + str.slice(1)
10
- }
11
- self.toCapitalizeEveryWord = function (str: string): string {
12
- return str
13
- .split(' ')
14
- .map((word) => self.toCapitalize(word))
15
- .join(' ')
16
- }
17
- self.toCapitalizeByIndex = function (
18
- str: string,
19
- indexes: number[]
20
- ): string {
21
- return str
22
- .split(' ')
23
- .map((word, index) =>
24
- indexes.includes(index) ? self.toCapitalize(word) : word
25
- )
26
- .join(' ')
27
- }
28
- self.toLowerCaseByIndex = function (
29
- str: string,
30
- indexes: number[]
31
- ): string {
32
- return str
33
- .split(' ')
34
- .map((word, index) =>
35
- indexes.includes(index) ? self.toLowerCaseFirstLetter(word) : word
36
- )
37
- .join(' ')
38
- }
39
-
40
- return self
41
- }.call({})
42
-
43
- return {
44
- provide: {
45
- text,
46
- },
47
- }
48
- })
1
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
2
+
3
+ export default defineNuxtPlugin(() => {
4
+ const text = function () {
5
+ const self: any = {}
6
+ self.toCapitalize = function (str: string): string {
7
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()
8
+ }
9
+ self.toLowerCaseFirstLetter = function (str: string): string {
10
+ // TODO не используется
11
+ return str.charAt(0).toLowerCase() + str.slice(1)
12
+ }
13
+ self.toCapitalizeEveryWord = function (str: string): string {
14
+ return str
15
+ .split(' ')
16
+ .map((word) => self.toCapitalize(word))
17
+ .join(' ')
18
+ }
19
+ self.toCapitalizeByIndex = function (
20
+ str: string,
21
+ indexes: number[]
22
+ ): string {
23
+ return str
24
+ .split(' ')
25
+ .map((word, index) =>
26
+ indexes.includes(index) ? self.toCapitalize(word) : word
27
+ )
28
+ .join(' ')
29
+ }
30
+ self.toLowerCaseByIndex = function (
31
+ str: string,
32
+ indexes: number[]
33
+ ): string {
34
+ return str
35
+ .split(' ')
36
+ .map((word, index) =>
37
+ indexes.includes(index) ? self.toLowerCaseFirstLetter(word) : word
38
+ )
39
+ .join(' ')
40
+ }
41
+ self.replaceStringByLocalization = function (
42
+ str: string,
43
+ localization: UI_I_Localization
44
+ ): string {
45
+ return str.replace(/\[\w+\]/g, (val) => {
46
+ const variable = val.replace(/\[|\]/g, '')
47
+ return localization.common[variable]
48
+ })
49
+ }
50
+
51
+ return self
52
+ }.call({})
53
+
54
+ return {
55
+ provide: {
56
+ text,
57
+ },
58
+ }
59
+ })
@@ -0,0 +1,17 @@
1
+ import { defineNuxtPlugin } from '#app'
2
+ export default defineNuxtPlugin(() => {
3
+ const time = function (): any {
4
+ const self: any = {}
5
+ self.millisecondsToHour = function (ms: number): number {
6
+ return ~~(ms / 1000 / 60 / 60 / 24)
7
+ }
8
+
9
+ return self
10
+ }.call({})
11
+
12
+ return {
13
+ provide: {
14
+ time,
15
+ },
16
+ }
17
+ })