@central-design-system/components 3.0.0-alpha.5 → 3.0.0-alpha.7

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 (59) hide show
  1. package/dist/cds.css +1 -1
  2. package/dist/cds.d.ts +51 -48
  3. package/dist/cds.es.js +3841 -3315
  4. package/dist/cds.umd.js +1 -1
  5. package/dist/components/CdsButton/CdsButton.vue.d.ts +6 -5
  6. package/dist/components/CdsCombobox/CdsCombobox.vue.d.ts +98 -80
  7. package/dist/components/CdsDropdown/CdsDropdown.vue.d.ts +134 -54
  8. package/dist/components/CdsGrid/composable/grid.d.ts +2 -1
  9. package/dist/components/CdsInput/CdsInput.vue.d.ts +14 -0
  10. package/dist/components/CdsMenu/CdsMenu.vue.d.ts +24 -18
  11. package/dist/components/CdsOverlay/CdsOverlay.vue.d.ts +9 -13
  12. package/dist/components/CdsOverlay/composable/locationStrategies.d.ts +3 -0
  13. package/dist/components/CdsPagination/CdsPagination.vue.d.ts +142 -0
  14. package/dist/components/CdsSelect/CdsSelect.vue.d.ts +40 -22
  15. package/dist/components/CdsTextArea/CdsTextArea.vue.d.ts +15 -3
  16. package/dist/components/CdsTextInput/CdsTextInput.vue.d.ts +64 -10
  17. package/dist/components/CdsTooltip/CdsTooltip.vue.d.ts +765 -0
  18. package/dist/components/index.d.ts +3 -1
  19. package/dist/composable/dimensions.d.ts +23 -5
  20. package/dist/composable/display.d.ts +56 -0
  21. package/dist/composable/index.d.ts +3 -0
  22. package/dist/composable/overlay.d.ts +1 -1
  23. package/dist/composable/refs.d.ts +6 -0
  24. package/dist/composable/resizeObserver.d.ts +7 -0
  25. package/dist/create.d.ts +21 -0
  26. package/dist/globals.d.ts +2 -0
  27. package/dist/utils/helpers.d.ts +2 -0
  28. package/package.json +1 -2
  29. package/src/scss/themes/index.ts +1 -1
  30. package/src/scss/utility/lists.scss +1 -0
  31. package/dist/types/CdsOptions.d.ts +0 -3
  32. package/src/utils/__test__/helper.test.ts +0 -59
  33. package/src/utils/__test__/mocks/helper.mock.ts +0 -362
  34. package/src/utils/__test__/mocks/propFactory.mock.ts +0 -88
  35. package/src/utils/__test__/propFactory.test.ts +0 -9
  36. package/src/utils/anchor.ts +0 -76
  37. package/src/utils/animation.ts +0 -62
  38. package/src/utils/box.ts +0 -39
  39. package/src/utils/cache.ts +0 -12
  40. package/src/utils/changeCase/__test__/lowerCase.test.ts +0 -12
  41. package/src/utils/changeCase/__test__/mocks/lowerCase.mock.ts +0 -80
  42. package/src/utils/changeCase/__test__/mocks/noCase.mock.ts +0 -131
  43. package/src/utils/changeCase/__test__/mocks/paramCase.mock.ts +0 -39
  44. package/src/utils/changeCase/__test__/mocks/pascalCase.mock.ts +0 -46
  45. package/src/utils/changeCase/__test__/noCase.test.ts +0 -8
  46. package/src/utils/changeCase/__test__/paramCase.test.ts +0 -8
  47. package/src/utils/changeCase/__test__/pascalCase.test.ts +0 -8
  48. package/src/utils/changeCase/lowerCase.ts +0 -56
  49. package/src/utils/changeCase/noCase.ts +0 -45
  50. package/src/utils/changeCase/paramCase.ts +0 -11
  51. package/src/utils/changeCase/pascalCase.ts +0 -24
  52. package/src/utils/date.ts +0 -1106
  53. package/src/utils/dom.ts +0 -24
  54. package/src/utils/getCurrentInstance.ts +0 -43
  55. package/src/utils/getScrollParent.ts +0 -29
  56. package/src/utils/globals.ts +0 -8
  57. package/src/utils/helpers.ts +0 -312
  58. package/src/utils/index.ts +0 -19
  59. package/src/utils/propsFactory.ts +0 -92
@@ -1,88 +0,0 @@
1
- import { IMockDataProvider } from '@/types/vitest';
2
- import { ComponentObjectPropsOptions } from '@components/shims-vue';
3
-
4
- export const mockPropFactory: IMockDataProvider<
5
- { props: ComponentObjectPropsOptions; source: string; defaults?: any },
6
- ComponentObjectPropsOptions
7
- >[] = [
8
- {
9
- name: 'propFactory',
10
- initial: {
11
- props: {
12
- foo: String,
13
- bar: Array
14
- },
15
- source: 'props'
16
- },
17
- expected: {
18
- foo: {
19
- source: 'props',
20
- type: String
21
- },
22
- bar: {
23
- source: 'props',
24
- type: Array
25
- }
26
- }
27
- },
28
- {
29
- name: 'propFactory',
30
- initial: {
31
- props: {
32
- test: {
33
- type: String,
34
- default: ''
35
- }
36
- },
37
- source: 'test'
38
- },
39
- expected: {
40
- test: {
41
- source: 'test',
42
- type: String,
43
- default: ''
44
- }
45
- }
46
- },
47
- {
48
- name: 'propFactory',
49
- initial: {
50
- props: {
51
- bar: {
52
- type: Object,
53
- default: {}
54
- }
55
- },
56
- source: 'bar'
57
- },
58
- expected: {
59
- bar: {
60
- source: 'bar',
61
- type: Object,
62
- default: {}
63
- }
64
- }
65
- },
66
- {
67
- name: 'propFactory',
68
- initial: {
69
- props: {
70
- foo: {
71
- type: String,
72
- default: undefined
73
- }
74
- },
75
- source: 'foo',
76
- defaults: {
77
- foo: 'string'
78
- }
79
- },
80
- expected: {
81
- foo: {
82
- default: 'string',
83
- source: 'foo',
84
- type: String
85
- }
86
- }
87
- }
88
- ];
@@ -1,9 +0,0 @@
1
- import { propsFactory } from '../propsFactory';
2
- import { mockPropFactory } from './mocks/propFactory.mock';
3
-
4
- describe('propFactory.ts', () => {
5
- it.each(mockPropFactory)('should be props', ({ initial, expected }) => {
6
- const makeProps = propsFactory(initial.props, initial.source);
7
- expect(makeProps(initial.defaults)).toEqual(expected);
8
- });
9
- });
@@ -1,76 +0,0 @@
1
- import { includes } from './';
2
-
3
- const block = ['top', 'bottom'] as const;
4
- const inline = ['start', 'end', 'left', 'right'] as const;
5
- type Tblock = typeof block[number];
6
- type Tinline = typeof inline[number];
7
- export type TAnchor =
8
- | Tblock
9
- | Tinline
10
- | 'center'
11
- | 'center center'
12
- | `${Tblock} ${Tinline | 'center'}`
13
- | `${Tinline} ${Tblock | 'center'}`;
14
- export type ParsedAnchor =
15
- | { side: 'center'; align: 'center' }
16
- | { side: Tblock; align: 'left' | 'right' | 'center' }
17
- | { side: 'left' | 'right'; align: Tblock | 'center' };
18
-
19
- /** Parse a raw anchor string into an object */
20
- export function parseAnchor(anchor: TAnchor) {
21
- const anchorArr = anchor.split(' ') as [Tblock | Tinline | 'center', Tblock | Tinline | 'center' | undefined];
22
- const side = anchorArr[0];
23
- let align = anchorArr[1];
24
-
25
- if (!align) {
26
- align = includes(block, side) ? 'start' : includes(inline, side) ? 'top' : 'center';
27
- }
28
-
29
- return {
30
- side: toPhysical(side),
31
- align: toPhysical(align)
32
- } as ParsedAnchor;
33
- }
34
-
35
- export function toPhysical(str: 'center' | Tblock | Tinline) {
36
- if (str === 'start') return 'left';
37
- if (str === 'end') return 'right';
38
- return str;
39
- }
40
-
41
- export function flipSide(anchor: ParsedAnchor) {
42
- return {
43
- side: {
44
- center: 'center',
45
- top: 'bottom',
46
- bottom: 'top',
47
- left: 'right',
48
- right: 'left'
49
- }[anchor.side],
50
- align: anchor.align
51
- } as ParsedAnchor;
52
- }
53
-
54
- export function flipAlign(anchor: ParsedAnchor) {
55
- return {
56
- side: anchor.side,
57
- align: {
58
- center: 'center',
59
- top: 'bottom',
60
- bottom: 'top',
61
- left: 'right',
62
- right: 'left'
63
- }[anchor.align]
64
- } as ParsedAnchor;
65
- }
66
-
67
- export function flipCorner(anchor: ParsedAnchor) {
68
- return {
69
- side: anchor.align,
70
- align: anchor.side
71
- } as ParsedAnchor;
72
- }
73
-
74
- export function getAxis(anchor: ParsedAnchor) {
75
- return includes(block, anchor.side) ? 'y' : 'x';
76
- }
@@ -1,62 +0,0 @@
1
- import { Box } from './box';
2
-
3
- /** @see https://stackoverflow.com/a/57876601/2074736 */
4
- export function nullifyTransforms(el: HTMLElement): Box {
5
- const rect = el.getBoundingClientRect();
6
- const style = getComputedStyle(el);
7
- const tx = style.transform;
8
-
9
- if (tx) {
10
- let ta, sx, sy, dx, dy;
11
- if (tx.startsWith('matrix3d(')) {
12
- ta = tx.slice(9, -1).split(/, /);
13
- sx = +ta[0];
14
- sy = +ta[5];
15
- dx = +ta[12];
16
- dy = +ta[13];
17
- } else if (tx.startsWith('matrix(')) {
18
- ta = tx.slice(7, -1).split(/, /);
19
- sx = +ta[0];
20
- sy = +ta[3];
21
- dx = +ta[4];
22
- dy = +ta[5];
23
- } else {
24
- return new Box(rect);
25
- }
26
-
27
- const to = style.transformOrigin;
28
- const x = rect.x - dx - (1 - sx) * parseFloat(to);
29
- const y = rect.y - dy - (1 - sy) * parseFloat(to.slice(to.indexOf(' ') + 1));
30
- const w = sx ? rect.width / sx : el.offsetWidth + 1;
31
- const h = sy ? rect.height / sy : el.offsetHeight + 1;
32
-
33
- return new Box({ x, y, width: w, height: h });
34
- } else {
35
- return new Box(rect);
36
- }
37
- }
38
-
39
- export function animate(
40
- el: Element,
41
- keyframes: Keyframe[] | PropertyIndexedKeyframes | null,
42
- options?: number | KeyframeAnimationOptions
43
- ) {
44
- if (typeof el.animate === 'undefined') return { finished: Promise.resolve() };
45
-
46
- let animation: Animation;
47
- try {
48
- animation = el.animate(keyframes, options);
49
- } catch (err) {
50
- return { finished: Promise.resolve() };
51
- }
52
-
53
- if (typeof animation.finished === 'undefined') {
54
- (animation as any).finished = new Promise((resolve) => {
55
- animation.onfinish = () => {
56
- resolve(animation);
57
- };
58
- });
59
- }
60
-
61
- return animation;
62
- }
package/src/utils/box.ts DELETED
@@ -1,39 +0,0 @@
1
- export class Box {
2
- x: number;
3
- y: number;
4
- width: number;
5
- height: number;
6
-
7
- constructor({ x, y, width, height }: { x: number; y: number; width: number; height: number }) {
8
- this.x = x;
9
- this.y = y;
10
- this.width = width;
11
- this.height = height;
12
- }
13
-
14
- get top() {
15
- return this.y;
16
- }
17
- get bottom() {
18
- return this.y + this.height;
19
- }
20
- get left() {
21
- return this.x;
22
- }
23
- get right() {
24
- return this.x + this.width;
25
- }
26
- }
27
-
28
- export function getOverflow(a: Box, b: Box) {
29
- return {
30
- x: {
31
- before: Math.max(0, b.left - a.left),
32
- after: Math.max(0, a.right - b.right)
33
- },
34
- y: {
35
- before: Math.max(0, b.top - a.top),
36
- after: Math.max(0, a.bottom - b.bottom)
37
- }
38
- };
39
- }
@@ -1,12 +0,0 @@
1
- export function useCache() {
2
- const cache: Record<string, any> = new Map();
3
-
4
- return {
5
- getCache: function (key: string, obj: any) {
6
- return cache[key] || (cache[key] = obj);
7
- },
8
- getCacheWithFn: function (key: string, fn: () => any) {
9
- return cache[key] || (cache[key] = fn());
10
- }
11
- };
12
- }
@@ -1,12 +0,0 @@
1
- import { lowerCaseMock, localeLowerCaseMock } from './mocks/lowerCase.mock';
2
- import { localeLowerCase, lowerCase } from '../lowerCase';
3
-
4
- describe('lowerCase.ts', () => {
5
- it.each(lowerCaseMock)('should be to lower case - #%#', ({ initial, expected }) => {
6
- expect(lowerCase(initial)).toBe(expected);
7
- });
8
-
9
- it.each(localeLowerCaseMock)('should be to locale lower case - #%#', ({ initial, expected, locale }) => {
10
- expect(localeLowerCase(initial, locale)).toBe(expected);
11
- });
12
- });
@@ -1,80 +0,0 @@
1
- import type { IMockDataProvider } from '@/types/vitest';
2
-
3
- export const lowerCaseMock: IMockDataProvider[] = [
4
- {
5
- name: 'lowerCase',
6
- initial: 'FOO',
7
- expected: 'foo'
8
- },
9
- {
10
- name: 'lowerCase',
11
- initial: 'hEllO',
12
- expected: 'hello'
13
- },
14
- {
15
- name: 'lowerCase',
16
- initial: '123BAR',
17
- expected: '123bar'
18
- },
19
- {
20
- name: 'lowerCase',
21
- initial: 'ТЕКСТ',
22
- expected: 'текст'
23
- },
24
- {
25
- name: 'lowerCase',
26
- initial: 'тЕкСт',
27
- expected: 'текст'
28
- },
29
- {
30
- name: 'lowerCase',
31
- initial: 'Some_Foo',
32
- expected: 'some_foo'
33
- },
34
- {
35
- name: 'lowerCase',
36
- initial: 'SOME-FOO',
37
- expected: 'some-foo'
38
- },
39
- {
40
- name: 'lowerCase',
41
- initial: ' FOO',
42
- expected: ' foo'
43
- },
44
- {
45
- name: 'lowerCase',
46
- initial: 'HI how Are You?',
47
- expected: 'hi how are you?'
48
- },
49
- {
50
- name: 'lowerCase',
51
- initial: 'test string',
52
- expected: 'test string'
53
- },
54
- {
55
- name: 'lowerCase',
56
- initial: '',
57
- expected: ''
58
- }
59
- ];
60
-
61
- export const localeLowerCaseMock: IMockDataProvider[] = [
62
- {
63
- name: 'lowerCase',
64
- initial: 'FOO',
65
- expected: 'foo',
66
- locale: 'en'
67
- },
68
- {
69
- name: 'lowerCase',
70
- initial: 'ФУУ',
71
- expected: 'фуу',
72
- locale: 'ru'
73
- },
74
- {
75
- name: 'lowerCase',
76
- initial: 'STRING',
77
- expected: 'strıng',
78
- locale: 'tr'
79
- }
80
- ];
@@ -1,131 +0,0 @@
1
- import { IMockDataProvider } from '@/types/vitest';
2
-
3
- export const noCaseMock: IMockDataProvider[] = [
4
- {
5
- name: 'noCase',
6
- initial: 'test',
7
- expected: 'test'
8
- },
9
- {
10
- name: 'noCase',
11
- initial: 'testString',
12
- expected: 'test string'
13
- },
14
- {
15
- name: 'noCase',
16
- initial: 'testString_1_2_3',
17
- expected: 'test string 1 2 3'
18
- },
19
- {
20
- name: 'noCase',
21
- initial: 'x_256',
22
- expected: 'x 256'
23
- },
24
- {
25
- name: 'noCase',
26
- initial: 'anHTMLTag',
27
- expected: 'an html tag'
28
- },
29
- {
30
- name: 'noCase',
31
- initial: 'ID123String',
32
- expected: 'id123 string'
33
- },
34
- {
35
- name: 'noCase',
36
- initial: 'Id123String',
37
- expected: 'id123 string'
38
- },
39
- {
40
- name: 'noCase',
41
- initial: 'foo bar123',
42
- expected: 'foo bar123'
43
- },
44
- {
45
- name: 'noCase',
46
- initial: 'a1bStar',
47
- expected: 'a1b star'
48
- },
49
- {
50
- name: 'noCase',
51
- initial: ' test ',
52
- expected: 'test'
53
- },
54
- {
55
- name: 'noCase',
56
- initial: 'CONSTANT_CASE ',
57
- expected: 'constant case'
58
- },
59
- {
60
- name: 'noCase',
61
- initial: 'CONST123_FOO',
62
- expected: 'const123 foo'
63
- },
64
- {
65
- name: 'noCase',
66
- initial: 'FOO_bar',
67
- expected: 'foo bar'
68
- },
69
- {
70
- name: 'noCase',
71
- initial: 'XMLHttpRequest',
72
- expected: 'xml http request'
73
- },
74
- {
75
- name: 'noCase',
76
- initial: 'IQueryAArgs',
77
- expected: 'i query a args'
78
- },
79
- {
80
- name: 'noCase',
81
- initial: 'dot.case',
82
- expected: 'dot case'
83
- },
84
- {
85
- name: 'noCase',
86
- initial: 'path/case',
87
- expected: 'path case'
88
- },
89
- {
90
- name: 'noCase',
91
- initial: 'snake_case',
92
- expected: 'snake case'
93
- },
94
- {
95
- name: 'noCase',
96
- initial: 'snake_case123',
97
- expected: 'snake case123'
98
- },
99
- {
100
- name: 'noCase',
101
- initial: 'snake_case_123',
102
- expected: 'snake case 123'
103
- },
104
- {
105
- name: 'noCase',
106
- initial: 'version 0.45.0',
107
- expected: 'version 0 45 0'
108
- },
109
- {
110
- name: 'noCase',
111
- initial: 'version 0..78..9',
112
- expected: 'version 0 78 9'
113
- },
114
- {
115
- name: 'noCase',
116
- initial: 'version 4_99/4',
117
- expected: 'version 4 99 4'
118
- },
119
- {
120
- name: 'noCase',
121
- initial: 'camel2019',
122
- expected: 'camel 2019',
123
- options: { splitRegexp: /([a-z])([A-Z0-9])/g }
124
- },
125
- {
126
- name: 'noCase',
127
- initial: 'minifyURLs',
128
- expected: 'minify urls',
129
- options: { splitRegexp: /([a-z])([A-Z0-9])/g }
130
- }
131
- ];
@@ -1,39 +0,0 @@
1
- import { IMockDataProvider } from '@/types/vitest';
2
-
3
- export const paramCaseMock: IMockDataProvider[] = [
4
- {
5
- name: 'paramCase',
6
- initial: '',
7
- expected: ''
8
- },
9
- {
10
- name: 'paramCase',
11
- initial: 'test',
12
- expected: 'test'
13
- },
14
- {
15
- name: 'paramCase',
16
- initial: 'test string',
17
- expected: 'test-string'
18
- },
19
- {
20
- name: 'paramCase',
21
- initial: 'Test String',
22
- expected: 'test-string'
23
- },
24
- {
25
- name: 'paramCase',
26
- initial: 'TestV2',
27
- expected: 'test-v2'
28
- },
29
- {
30
- name: 'paramCase',
31
- initial: 'version 1.2.10',
32
- expected: 'version-1-2-10'
33
- },
34
- {
35
- name: 'paramCase',
36
- initial: 'version 1.21.0',
37
- expected: 'version-1-21-0'
38
- }
39
- ];
@@ -1,46 +0,0 @@
1
- import { IMockDataProvider } from '@/types/vitest';
2
- import { pascalCaseTransformMerge } from '@components/utils';
3
-
4
- export const pascalCaseMock: IMockDataProvider[] = [
5
- {
6
- name: 'pascalCase',
7
- initial: '',
8
- expected: ''
9
- },
10
- {
11
- name: 'pascalCase',
12
- initial: 'test',
13
- expected: 'Test'
14
- },
15
- {
16
- name: 'pascalCase',
17
- initial: 'test string',
18
- expected: 'TestString'
19
- },
20
- {
21
- name: 'pascalCase',
22
- initial: 'Test String',
23
- expected: 'TestString'
24
- },
25
- {
26
- name: 'pascalCase',
27
- initial: 'TestV2',
28
- expected: 'TestV2'
29
- },
30
- {
31
- name: 'pascalCase',
32
- initial: 'version 1.2.10',
33
- expected: 'Version_1_2_10'
34
- },
35
- {
36
- name: 'pascalCase',
37
- initial: 'version 1.21.0',
38
- expected: 'Version_1_21_0'
39
- },
40
- {
41
- name: 'pascalCase',
42
- initial: 'version 1.21.0',
43
- expected: 'Version1210',
44
- options: { transform: pascalCaseTransformMerge }
45
- }
46
- ];
@@ -1,8 +0,0 @@
1
- import { noCaseMock } from './mocks/noCase.mock';
2
- import { noCase } from '../noCase';
3
-
4
- describe('noCase.ts', () => {
5
- it.each(noCaseMock)('should be to no case - #%#', ({ initial, expected, options }) => {
6
- expect(noCase(initial, options)).toBe(expected);
7
- });
8
- });
@@ -1,8 +0,0 @@
1
- import { paramCaseMock } from './mocks/paramCase.mock';
2
- import { paramCase } from '../paramCase';
3
-
4
- describe('paramCase.ts', () => {
5
- it.each(paramCaseMock)('should be to param case - #%#', ({ initial, expected, options }) => {
6
- expect(paramCase(initial, options)).toBe(expected);
7
- });
8
- });
@@ -1,8 +0,0 @@
1
- import { pascalCaseMock } from './mocks/pascalCase.mock';
2
- import { pascalCase } from '../pascalCase';
3
-
4
- describe('pascalCase.ts', () => {
5
- it.each(pascalCaseMock)('should be to pascal case - #%#', ({ initial, expected, options }) => {
6
- expect(pascalCase(initial, options)).toBe(expected);
7
- });
8
- });
@@ -1,56 +0,0 @@
1
- /**
2
- * Locale character mapping rules.
3
- */
4
- interface Locale {
5
- regexp: RegExp;
6
- map: Record<string, string>;
7
- }
8
-
9
- /**
10
- * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
11
- */
12
- const SUPPORTED_LOCALE: Record<string, Locale> = {
13
- tr: {
14
- regexp: /\u0130|\u0049|\u0049\u0307/g,
15
- map: {
16
- İ: '\u0069',
17
- I: '\u0131',
18
- İ: '\u0069'
19
- }
20
- },
21
- az: {
22
- regexp: /\u0130/g,
23
- map: {
24
- İ: '\u0069',
25
- I: '\u0131',
26
- İ: '\u0069'
27
- }
28
- },
29
- lt: {
30
- regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
31
- map: {
32
- I: '\u0069\u0307',
33
- J: '\u006A\u0307',
34
- Į: '\u012F\u0307',
35
- Ì: '\u0069\u0307\u0300',
36
- Í: '\u0069\u0307\u0301',
37
- Ĩ: '\u0069\u0307\u0303'
38
- }
39
- }
40
- };
41
-
42
- /**
43
- * Localized lower case.
44
- */
45
- export function localeLowerCase(str: string, locale: string) {
46
- const lang = SUPPORTED_LOCALE[locale.toLowerCase()];
47
- if (lang) return lowerCase(str.replace(lang.regexp, (m) => lang.map[m]));
48
- return lowerCase(str);
49
- }
50
-
51
- /**
52
- * Lower case as a function.
53
- */
54
- export function lowerCase(str: string) {
55
- return str.toLowerCase();
56
- }