@onereach/ui-components 2.74.8-beta.2339.0 → 2.74.8

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 (31) hide show
  1. package/dist/bundled/v2/{OrDateTimePicker-18587a06.js → OrDateTimePicker-24a56fd2.js} +2 -4
  2. package/dist/bundled/v2/{OrText-a665b991.js → OrText-15bf85c4.js} +36 -3
  3. package/dist/bundled/v2/components/index.js +2 -2
  4. package/dist/bundled/v2/components/or-date-time-picker/index.js +1 -1
  5. package/dist/bundled/v2/components/or-text-v3/OrText.vue.d.ts +27 -2
  6. package/dist/bundled/v2/components/or-text-v3/index.js +1 -1
  7. package/dist/bundled/v2/index.js +3 -3
  8. package/dist/bundled/v3/OrText.vue_vue_type_script_lang-e93438ea.js +93 -0
  9. package/dist/bundled/v3/components/index.js +1 -1
  10. package/dist/bundled/v3/components/or-text-v3/OrText.vue.d.ts +27 -2
  11. package/dist/bundled/v3/components/or-text-v3/index.js +1 -1
  12. package/dist/bundled/v3/index.js +4 -6
  13. package/dist/esm/v2/{OrDateTimePicker-d8cb0e8d.js → OrDateTimePicker-e1ea0a9a.js} +2 -4
  14. package/dist/esm/v2/{OrText-b12d0682.js → OrText-91d662a0.js} +36 -3
  15. package/dist/esm/v2/components/index.js +2 -2
  16. package/dist/esm/v2/components/or-date-time-picker/index.js +1 -1
  17. package/dist/esm/v2/components/or-text-v3/OrText.vue.d.ts +27 -2
  18. package/dist/esm/v2/components/or-text-v3/index.js +1 -1
  19. package/dist/esm/v2/index.js +2 -2
  20. package/dist/esm/v3/{OrDateTimePicker-c4af17e3.js → OrDateTimePicker-63f22d1b.js} +1 -3
  21. package/dist/esm/v3/{OrText-6b4f7cd1.js → OrText-a3b00048.js} +36 -3
  22. package/dist/esm/v3/components/index.js +2 -2
  23. package/dist/esm/v3/components/or-date-time-picker/index.js +1 -1
  24. package/dist/esm/v3/components/or-text-v3/OrText.vue.d.ts +27 -2
  25. package/dist/esm/v3/components/or-text-v3/index.js +1 -1
  26. package/dist/esm/v3/index.js +2 -2
  27. package/package.json +3 -2
  28. package/src/components/or-date-time-picker/OrDateTimePicker.vue +0 -11
  29. package/src/components/or-text-v3/OrText.stories3.ts +83 -5
  30. package/src/components/or-text-v3/OrText.vue +37 -3
  31. package/dist/bundled/v3/OrText.vue_vue_type_script_lang-271fb345.js +0 -60
@@ -17,18 +17,33 @@
17
17
  import { computed, defineComponent, ref } from 'vue-demi';
18
18
  import { MainText, RestText, TextRoot } from './styles';
19
19
 
20
+ /**
21
+ * Use `OrText` component to crop un-wrapped single-line text with ellipsis inside narrow containers.
22
+ * Ellipsis can be placed in the end or in the middle of the text. Convenient for displaying long labels,
23
+ * that have same beginning and differ in the ending part.
24
+ */
20
25
  export default defineComponent({
21
26
  name: 'OrText',
22
27
 
23
28
  props: {
29
+ /**
30
+ * Text to crop.
31
+ */
24
32
  text: {
25
33
  type: String,
26
34
  required: true,
27
35
  },
28
36
 
37
+ /**
38
+ * The index counted from the end of the string where ellipsis will be placed.
39
+ * Defines how many ending characters will remain visible.
40
+ * By default, ellipsis is placed in the end of the line.
41
+ *
42
+ * Note: Negative values behave same as corresponding positives still counting from the end of the line.
43
+ */
29
44
  sliceIndex: {
30
45
  type: Number,
31
- default: undefined,
46
+ default: 0,
32
47
  },
33
48
  },
34
49
 
@@ -54,17 +69,36 @@ export default defineComponent({
54
69
  ...RestText,
55
70
  ]);
56
71
 
72
+ /**
73
+ * Preserves whitespace at the last position as <code>&nbsp;</code>
74
+ * @param str A string to escape
75
+ */
76
+ const escapeLast = (str: string): string => str && (str.slice(0, -1) + '\xa0');
77
+ /**
78
+ * Preserves whitespace at the first position as <code>&nbsp;</code>
79
+ * @param str A string to escape
80
+ */
81
+ const escapeFirst = (str: string): string => str && ('\xa0' + str.slice(1));
82
+
57
83
  // State
58
84
  const mainText = computed(() => {
59
85
  if (props.sliceIndex) {
60
- return props.text.slice(0, Math.abs(props.sliceIndex) * -1);
86
+ let mainPart = props.text.slice(0, -Math.abs(props.sliceIndex));
87
+ if (mainPart[mainPart.length - 1] === ' ') {
88
+ mainPart = escapeLast(mainPart);
89
+ }
90
+ return mainPart;
61
91
  }
62
92
 
63
93
  return props.text;
64
94
  });
65
95
 
66
96
  const restText = computed(() => {
67
- return props.text.slice(mainText.value.length);
97
+ let restPart = props.text.slice(mainText.value.length);
98
+ if (restPart[0] === ' ') {
99
+ restPart = escapeFirst(restPart);
100
+ }
101
+ return restPart;
68
102
  });
69
103
 
70
104
  return {
@@ -1,60 +0,0 @@
1
- import { defineComponent, ref, computed } from 'vue';
2
-
3
- const TextRoot = [
4
- // Layout
5
- 'inline-flex',
6
- // Box
7
- 'max-w-full',
8
- // Typography
9
- 'whitespace-nowrap'];
10
- const MainText = [
11
- // Layout
12
- 'overflow-hidden',
13
- // Typography
14
- 'text-ellipsis'];
15
- const RestText = [
16
- // Layout
17
- 'shrink'];
18
-
19
- var script = defineComponent({
20
- name: 'OrText',
21
- props: {
22
- text: {
23
- type: String,
24
- required: true
25
- },
26
- sliceIndex: {
27
- type: Number,
28
- default: undefined
29
- }
30
- },
31
- expose: ['root'],
32
- setup(props) {
33
- // Refs
34
- const root = ref();
35
- // Styles
36
- const rootStyles = computed(() => ['or-text', ...TextRoot]);
37
- const mainTextStyles = computed(() => [...MainText]);
38
- const restTextStyles = computed(() => [...RestText]);
39
- // State
40
- const mainText = computed(() => {
41
- if (props.sliceIndex) {
42
- return props.text.slice(0, Math.abs(props.sliceIndex) * -1);
43
- }
44
- return props.text;
45
- });
46
- const restText = computed(() => {
47
- return props.text.slice(mainText.value.length);
48
- });
49
- return {
50
- root,
51
- rootStyles,
52
- mainTextStyles,
53
- restTextStyles,
54
- mainText,
55
- restText
56
- };
57
- }
58
- });
59
-
60
- export { script as s };