@trustme24/flext 1.10.1 → 1.10.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.
@@ -0,0 +1,133 @@
1
+ :host,
2
+ :host *,
3
+ :host::before,
4
+ :host::after,
5
+ :host *::before,
6
+ :host *::after,
7
+ :host::backdrop,
8
+ :host *::backdrop {
9
+
10
+ /* Opacity */
11
+
12
+ --un-bg-opacity: 100%;
13
+ --un-text-opacity: 100%;
14
+ --un-border-opacity: 100%;
15
+ --un-outline-opacity: 100%;
16
+ --un-ring-opacity: 100%;
17
+ --un-divide-opacity: 100%;
18
+ --un-placeholder-opacity: 100%;
19
+
20
+
21
+ /* Gradients */
22
+
23
+ --un-gradient-position: initial;
24
+ --un-gradient-from: #0000;
25
+ --un-gradient-via: #0000;
26
+ --un-gradient-to: #0000;
27
+ --un-gradient-stops: initial;
28
+ --un-gradient-via-stops: initial;
29
+ --un-gradient-from-position: 0%;
30
+ --un-gradient-via-position: 50%;
31
+ --un-gradient-to-position: 100%;
32
+ --un-from-opacity: 100%;
33
+ --un-via-opacity: 100%;
34
+ --un-to-opacity: 100%;
35
+
36
+
37
+ /* Ring */
38
+
39
+ --un-ring-color: initial;
40
+ --un-ring-shadow: 0 0 #0000;
41
+ --un-ring-inset: initial;
42
+ --un-ring-offset-width: 0px;
43
+ --un-ring-offset-color: #fff;
44
+ --un-ring-offset-shadow: 0 0 #0000;
45
+ --un-inset-ring-color: initial;
46
+ --un-inset-ring-shadow: 0 0 #0000;
47
+
48
+
49
+ /* Shadow */
50
+
51
+ --un-shadow: 0 0 #0000;
52
+ --un-shadow-color: initial;
53
+ --un-inset-shadow: 0 0 #0000;
54
+ --un-inset-shadow-color: initial;=
55
+
56
+
57
+ /* Border, Outline */
58
+
59
+ --un-border-style: solid;
60
+ --un-outline-style: solid;
61
+
62
+
63
+ /* Font, Letter Spacing */
64
+
65
+ --un-font-weight: initial;
66
+ --un-tracking: initial;
67
+
68
+
69
+ /* Transforms */
70
+
71
+ --un-translate-x: 0;
72
+ --un-translate-y: 0;
73
+ --un-translate-z: 0;
74
+ --un-rotate-x: rotateX(0);
75
+ --un-rotate-y: rotateY(0);
76
+ --un-rotate-z: rotateZ(0);
77
+ --un-skew-x: skewX(0);
78
+ --un-skew-y: skewY(0);
79
+ --un-scale-x: 1;
80
+ --un-scale-y: 1;
81
+ --un-scale-z: 1;
82
+
83
+
84
+ /* Filters */
85
+
86
+ --un-blur: initial;
87
+ --un-brightness: initial;
88
+ --un-contrast: initial;
89
+ --un-grayscale: initial;
90
+ --un-hue-rotate: initial;
91
+ --un-invert: initial;
92
+ --un-opacity: initial;
93
+ --un-saturate: initial;
94
+ --un-sepia: initial;
95
+ --un-drop-shadow: initial;
96
+
97
+
98
+ /* Backdrop */
99
+
100
+ --un-backdrop-blur: initial;
101
+ --un-backdrop-brightness: initial;
102
+ --un-backdrop-contrast: initial;
103
+ --un-backdrop-grayscale: initial;
104
+ --un-backdrop-hue-rotate: initial;
105
+ --un-backdrop-invert: initial;
106
+ --un-backdrop-opacity: initial;
107
+ --un-backdrop-saturate: initial;
108
+ --un-backdrop-sepia: initial;
109
+ --un-backdrop-drop-shadow: initial;
110
+
111
+
112
+ /* Transitions */
113
+
114
+ --un-duration: initial;
115
+ --un-ease: initial;
116
+
117
+
118
+ /* Other */
119
+
120
+ --un-content: '';
121
+ --un-divide-y-reverse: 0;
122
+ --un-divide-x-reverse: 0;
123
+ --un-space-x-reverse: 0;
124
+ --un-space-y-reverse: 0;
125
+ --un-default-border-color: #e5e7eb;
126
+ }
127
+
128
+ :host::before,
129
+ :host::after,
130
+ :host *::before,
131
+ :host *::after {
132
+ --un-content: '';
133
+ }
@@ -0,0 +1,68 @@
1
+ import { Obj } from '@/types';
2
+ import { defineModule } from '@/lib';
3
+
4
+
5
+ // Functions
6
+
7
+ export function op(state: any): any[] | boolean {
8
+ const args: any[] = state?.args ?? [];
9
+ const [ op, arr, prop ] = args;
10
+
11
+
12
+ // Defining he functions
13
+
14
+ const destruct = <T extends any = any>(val: Obj[], _prop: string): T[] => {
15
+ const items = _prop?.split('.') ?? [];
16
+ const result: T[] = [];
17
+
18
+
19
+ // Iterating for each item
20
+
21
+ for (const obj of val) {
22
+ let cursor: any = obj;
23
+
24
+ for (const item of items) cursor = cursor[item];
25
+
26
+ result.push(cursor);
27
+ }
28
+
29
+
30
+ return result;
31
+ };
32
+
33
+
34
+ // Applying the operation
35
+
36
+ switch (op) {
37
+ case 'destruct':
38
+ return destruct(arr, prop);
39
+ case 'check':
40
+ return Array.isArray(arr);
41
+ default:
42
+ return op;
43
+ }
44
+ }
45
+
46
+ export function destruct(state: any): any[] {
47
+ const args: any[] = state?.args ?? [];
48
+ const [ arr, prop ] = args;
49
+
50
+ return op({ ...state, args: [ 'destruct', arr, prop ] }) as any[];
51
+ }
52
+
53
+ export function check(state: any): boolean {
54
+ const args: any[] = state?.args ?? [];
55
+ const [ arr ] = args;
56
+
57
+ return op({ ...state, args: [ 'check', arr ] }) as boolean;
58
+ }
59
+
60
+
61
+ export default defineModule({
62
+ helpers: {
63
+ op: op,
64
+ destruct: destruct,
65
+ check: check,
66
+ __default: op,
67
+ },
68
+ });
@@ -0,0 +1,123 @@
1
+ import { Obj } from '@/types';
2
+ import { audit, defineModule } from '@/lib';
3
+ import { TemplateSyntaxError } from '@/errors';
4
+
5
+
6
+ // Functions
7
+
8
+ export function op(state: any): boolean {
9
+ const args: any[] = state?.args ?? [];
10
+ const namedArgs: Obj = state?.namedArgs ?? {};
11
+ const [ arg1, arg2OrOp, arg3, ...rest ] = args;
12
+ const { soft } = namedArgs;
13
+
14
+
15
+ // If the 'not' was passed
16
+
17
+ if (arg1 === 'not') return !arg2OrOp;
18
+
19
+
20
+ // If the 'soft' was passed
21
+
22
+ if (soft) {
23
+ switch (arg2OrOp) {
24
+ case 'equal':
25
+ return arg1 == arg3;
26
+ case 'notEqual':
27
+ return arg1 != arg3;
28
+ default:
29
+ throw new TemplateSyntaxError('Condition: Unknown operation: ' + audit(arg2OrOp));
30
+ }
31
+ }
32
+
33
+
34
+ // Defining the functions
35
+
36
+ const and = <T = any>(...a: T[]): T => a.reduce((r, x) => r && x);
37
+
38
+ const or = <T = any>(...a: T[]): T => a.reduce((r, x) => r || x);
39
+
40
+
41
+ // Applying the operation
42
+
43
+ switch (arg2OrOp) {
44
+ case 'equal':
45
+ return arg1 === arg3;
46
+ case 'notEqual':
47
+ return arg1 !== arg3;
48
+ case 'and':
49
+ return and(arg1, arg3, ...rest);
50
+ case 'or':
51
+ return or(arg1, arg3, ...rest);
52
+ case 'greater':
53
+ return Number(arg1) > Number(arg3);
54
+ case 'less':
55
+ return Number(arg1) < Number(arg3);
56
+ default:
57
+ throw new TemplateSyntaxError('Condition: Unknown operation: ' + audit(arg2OrOp));
58
+ }
59
+ }
60
+
61
+ export function not(state: any): boolean {
62
+ const args: any[] = state?.args ?? [];
63
+ const [ a ] = args;
64
+
65
+ return op({ ...state, args: [ 'not', a ] });
66
+ }
67
+
68
+ export function equal(state: any): boolean {
69
+ const args: any[] = state?.args ?? [];
70
+ const [ a, b ] = args;
71
+
72
+ return op({ ...state, args: [ a, 'equal', b ] });
73
+ }
74
+
75
+ export function notEqual(state: any): boolean {
76
+ const args: any[] = state?.args ?? [];
77
+ const [ a, b ] = args;
78
+
79
+ return op({ ...state, args: [ a, 'notEqual', b ] });
80
+ }
81
+
82
+ export function and(state: any): boolean {
83
+ const args: any[] = state?.args ?? [];
84
+ const [ a, ...rest ] = args;
85
+
86
+ return op({ ...state, args: [ a, 'and', ...rest ] });
87
+ }
88
+
89
+ export function or(state: any): boolean {
90
+ const args: any[] = state?.args ?? [];
91
+ const [ a, ...rest ] = args;
92
+
93
+ return op({ ...state, args: [ a, 'or', ...rest ] });
94
+ }
95
+
96
+ export function greater(state: any): boolean {
97
+ const args: any[] = state?.args ?? [];
98
+ const [ a, b ] = args;
99
+
100
+ return op({ ...state, args: [ a, 'greater', b ] });
101
+ }
102
+
103
+ export function less(state: any): boolean {
104
+ const args: any[] = state?.args ?? [];
105
+ const [ a, b ] = args;
106
+
107
+ return op({ ...state, args: [ a, 'less', b ] });
108
+ }
109
+
110
+
111
+ export default defineModule({
112
+ helpers: {
113
+ op: op,
114
+ not: not,
115
+ equal: equal,
116
+ notEqual: notEqual,
117
+ and: and,
118
+ or: or,
119
+ greater: greater,
120
+ less: less,
121
+ __default: op,
122
+ },
123
+ });
@@ -0,0 +1,254 @@
1
+ import { DateTime } from 'luxon';
2
+ import { Obj } from '@/types';
3
+ import { audit, ensureDate, defineModule, isset } from '@/lib';
4
+ import { TemplateSyntaxError } from '@/errors';
5
+
6
+
7
+ // Functions
8
+
9
+ export function op(state: any): DateTime | string | number | null {
10
+ const flext: Obj = state?.flext ?? {};
11
+ const args: any[] = state?.args ?? [];
12
+ const namedArgs: Obj = state?.namedArgs ?? {};
13
+ const [ date, op ] = args;
14
+ const { padding, genitive, timeZone, lang } = namedArgs;
15
+
16
+
17
+ // Doing some checks
18
+
19
+ if (!date) return null;
20
+
21
+
22
+ // Getting the date
23
+
24
+ let newDate: DateTime = DateTime.local();
25
+
26
+ if (date !== 'now')
27
+ newDate = DateTime.fromJSDate(ensureDate(date));
28
+
29
+ if (timeZone || flext?.timeZone)
30
+ newDate = newDate.setZone(timeZone ?? flext?.timeZone);
31
+
32
+ if (lang || flext?.lang)
33
+ newDate = newDate.setLocale(lang ?? flext?.lang);
34
+
35
+
36
+ // Defining the functions
37
+
38
+ const padStart = (val: string|number, _padding: string|number = 2): string => String(val || '').padStart(Number(_padding), '0');
39
+
40
+
41
+ // If the 'pad' was passed
42
+
43
+ if (isset(padding)) {
44
+ switch (op) {
45
+ case 'seconds':
46
+ return padStart(newDate.second, padding);
47
+ case 'minutes':
48
+ return padStart(newDate.minute, padding);
49
+ case 'hours':
50
+ return padStart(newDate.hour, padding);
51
+ case 'day':
52
+ return padStart(newDate.day, padding);
53
+ case 'month':
54
+ return padStart(newDate.month, padding);
55
+ case 'year':
56
+ return padStart(newDate.year, 4);
57
+ default:
58
+ throw new TemplateSyntaxError(`Date: Operation ${audit(op)} is not compatible with argument 'padding'`);
59
+ }
60
+ }
61
+
62
+ if (genitive) {
63
+ switch (op) {
64
+ case 'monthText':
65
+ const dateText = newDate.toLocaleString({ day: 'numeric', month: 'long' });
66
+ const monthText = dateText.replace(/[^\p{L}]/gu, ''); // TODO: kr: Costyl to work with thw US dates
67
+
68
+ return monthText.toLowerCase();
69
+ default:
70
+ throw new TemplateSyntaxError(`Date: Operation ${audit(op)} is not compatible with argument 'genitive'`);
71
+ }
72
+ }
73
+
74
+
75
+ // Applying the operation
76
+
77
+ switch (op) {
78
+ case 'seconds':
79
+ return newDate.second;
80
+ case 'minutes':
81
+ return newDate.minute;
82
+ case 'hours':
83
+ return newDate.hour;
84
+ case 'day':
85
+ return newDate.day;
86
+ case 'month':
87
+ return newDate.month;
88
+ case 'monthText':
89
+ const monthText = newDate.toLocaleString({ month: 'long' });
90
+ return monthText.toLowerCase();
91
+ case 'year':
92
+ return newDate.year;
93
+ case 'format':
94
+ return newDate.toLocaleString();
95
+ case 'text':
96
+ return newDate.toLocaleString({ day: 'numeric', month: 'long', year: 'numeric' });
97
+ case 'unix':
98
+ return newDate.toMillis();
99
+ case 'iso':
100
+ return newDate.toISOTime();
101
+ default:
102
+ return newDate;
103
+ }
104
+ }
105
+
106
+ export function now(state: any): DateTime {
107
+ return op({ ...state, args: [ 'now' ] }) as DateTime;
108
+ }
109
+
110
+ export function seconds(state: any): string {
111
+ const args: any[] = state?.args ?? [];
112
+ const [ date ] = args;
113
+ const namedArgs: Obj = state?.namedArgs ?? {};
114
+ const padding = namedArgs?.padding ?? 2;
115
+
116
+ return op({
117
+ ...state,
118
+
119
+ args: [ date, 'seconds' ],
120
+ namedArgs: { ...namedArgs, padding },
121
+ });
122
+ }
123
+
124
+ export function minutes(state: any): string {
125
+ const args: any[] = state?.args ?? [];
126
+ const [ date ] = args;
127
+ const namedArgs: Obj = state?.namedArgs ?? {};
128
+ const padding = namedArgs?.padding ?? 2;
129
+
130
+ return op({
131
+ ...state,
132
+
133
+ args: [ date, 'minutes' ],
134
+ namedArgs: { ...namedArgs, padding },
135
+ });
136
+ }
137
+
138
+ export function hours(state: any): string {
139
+ const args: any[] = state?.args ?? [];
140
+ const [ date ] = args;
141
+ const namedArgs: Obj = state?.namedArgs ?? {};
142
+ const padding = namedArgs?.padding ?? 2;
143
+
144
+ return op({
145
+ ...state,
146
+
147
+ args: [ date, 'hours' ],
148
+ namedArgs: { ...namedArgs, padding },
149
+ });
150
+ }
151
+
152
+ export function day(state: any): string {
153
+ const args: any[] = state?.args ?? [];
154
+ const [ date ] = args;
155
+ const namedArgs: Obj = state?.namedArgs ?? {};
156
+ const padding = namedArgs?.padding ?? 2;
157
+
158
+ return op({
159
+ ...state,
160
+
161
+ args: [ date, 'day' ],
162
+ namedArgs: { ...namedArgs, padding },
163
+ });
164
+ }
165
+
166
+ export function month(state: any): string {
167
+ const args: any[] = state?.args ?? [];
168
+ const [ date ] = args;
169
+ const namedArgs: Obj = state?.namedArgs ?? {};
170
+ const padding = namedArgs?.padding ?? 2;
171
+
172
+ return op({
173
+ ...state,
174
+
175
+ args: [ date, 'month' ],
176
+ namedArgs: { ...namedArgs, padding },
177
+ });
178
+ }
179
+
180
+ export function monthText(state: any): string {
181
+ const args: any[] = state?.args ?? [];
182
+ const [ date ] = args;
183
+ const namedArgs: Obj = state?.namedArgs ?? {};
184
+ const genitive = !namedArgs?.nominative;
185
+
186
+ return op({
187
+ ...state,
188
+
189
+ args: [ date, 'monthText' ],
190
+ namedArgs: { ...namedArgs, genitive },
191
+ });
192
+ }
193
+
194
+ export function year(state: any): string {
195
+ const args: any[] = state?.args ?? [];
196
+ const [ date ] = args;
197
+ const namedArgs: Obj = state?.namedArgs ?? {};
198
+ const padding = namedArgs?.padding ?? 2;
199
+
200
+ return op({
201
+ ...state,
202
+
203
+ args: [ date, 'year' ],
204
+ namedArgs: { ...namedArgs, padding },
205
+ });
206
+ }
207
+
208
+ export function format(state: any): string {
209
+ const args: any[] = state?.args ?? [];
210
+ const [ date ] = args;
211
+
212
+ return op({ ...state, args: [ date, 'format' ] });
213
+ }
214
+
215
+ export function text(state: any): string {
216
+ const args: any[] = state?.args ?? [];
217
+ const [ date ] = args;
218
+
219
+ return op({ ...state, args: [ date, 'text' ] });
220
+ }
221
+
222
+ export function unix(state: any): number {
223
+ const args: any[] = state?.args ?? [];
224
+ const [ date ] = args;
225
+
226
+ return op({ ...state, args: [ date, 'unix' ] }) as number;
227
+ }
228
+
229
+ export function iso(state: any): string {
230
+ const args: any[] = state?.args ?? [];
231
+ const [ date ] = args;
232
+
233
+ return op({ ...state, args: [ date, 'iso' ] }) as string;
234
+ }
235
+
236
+
237
+ export default defineModule({
238
+ helpers: {
239
+ op: op,
240
+ now: now,
241
+ seconds: seconds,
242
+ minutes: minutes,
243
+ hours: hours,
244
+ day: day,
245
+ month: month,
246
+ monthText: monthText,
247
+ year: year,
248
+ format: format,
249
+ text: text,
250
+ unix: unix,
251
+ iso: iso,
252
+ __default: op,
253
+ },
254
+ });
@@ -0,0 +1,9 @@
1
+ export { default as array } from './array';
2
+ export { default as cond } from './cond';
3
+ export { default as date } from './date';
4
+ export { default as match } from './match';
5
+ export { default as math } from './math';
6
+ export { default as media } from './media';
7
+ export { default as number } from './number';
8
+ export { default as put } from './put';
9
+ export { default as string } from './string';
@@ -0,0 +1,54 @@
1
+ import { defineModule } from '@/lib';
2
+
3
+
4
+ // Functions
5
+
6
+ export function _match(state: any): any {
7
+ const args: any[] = state?.args ?? [];
8
+ const [ value ] = args;
9
+ const self = state?.self ?? null;
10
+ const render = state?.getContent ?? null;
11
+
12
+
13
+ // Setting the match data
14
+
15
+ self.__flext_match_value = value;
16
+ self.__flext_match_isCompleted = false;
17
+
18
+
19
+ return render();
20
+ }
21
+
22
+ export function _case(state: any): any {
23
+ const args: any[] = state?.args ?? [];
24
+ const self = state?.self ?? null;
25
+ const value = self.__flext_match_value ?? null;
26
+ const render = state?.getContent ?? null;
27
+
28
+
29
+ // Iterating for each value
30
+
31
+ if (!self.__flext_match_isCompleted) for (const valueRef of args) if (value === valueRef) {
32
+ self.__flext_match_isCompleted = true;
33
+ return render();
34
+ }
35
+
36
+
37
+ return '';
38
+ }
39
+
40
+ export function _fallback(state: any): any {
41
+ const self = state?.self ?? null;
42
+ const value = self.__flext_match_value ?? null;
43
+
44
+ return _case({ ...state, args: [ value ] });
45
+ }
46
+
47
+
48
+ export default defineModule({
49
+ helpers: {
50
+ case: _case,
51
+ fallback: _fallback,
52
+ __default: _match,
53
+ },
54
+ });