@onereach/ui-components 13.2.2 → 13.2.3-beta.4665.0

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 (29) hide show
  1. package/dist/bundled/v2/components/OrTextareaV3/OrTextarea.js +30 -13
  2. package/dist/bundled/v2/components/OrTextareaV3/OrTextarea.vue.d.ts +15 -8
  3. package/dist/bundled/v2/components/OrTextareaV3/styles.js +2 -4
  4. package/dist/bundled/v2/components/OrTextareaV3/types.d.ts +4 -0
  5. package/dist/bundled/v2/index.js +1 -1
  6. package/dist/bundled/v3/components/OrTextareaV3/OrTextarea.js +1 -1
  7. package/dist/bundled/v3/components/OrTextareaV3/OrTextarea.vue.d.ts +15 -8
  8. package/dist/bundled/v3/components/OrTextareaV3/index.js +1 -1
  9. package/dist/bundled/v3/components/OrTextareaV3/styles.js +1 -1
  10. package/dist/bundled/v3/components/OrTextareaV3/types.d.ts +4 -0
  11. package/dist/bundled/v3/components/{OrTextareaV3-b142dda2.js → OrTextareaV3-12467615.js} +31 -16
  12. package/dist/bundled/v3/components/index.js +1 -1
  13. package/dist/bundled/v3/index.js +2 -2
  14. package/dist/esm/v2/{OrTextarea-899e5220.js → OrTextarea-ef4fd48a.js} +32 -17
  15. package/dist/esm/v2/components/index.js +1 -1
  16. package/dist/esm/v2/components/or-textarea-v3/OrTextarea.vue.d.ts +15 -8
  17. package/dist/esm/v2/components/or-textarea-v3/index.js +2 -1
  18. package/dist/esm/v2/components/or-textarea-v3/types.d.ts +4 -0
  19. package/dist/esm/v2/index.js +1 -1
  20. package/dist/esm/v3/{OrTextarea-76c037a9.js → OrTextarea-f9cbc1c3.js} +31 -16
  21. package/dist/esm/v3/components/index.js +1 -1
  22. package/dist/esm/v3/components/or-textarea-v3/OrTextarea.vue.d.ts +15 -8
  23. package/dist/esm/v3/components/or-textarea-v3/index.js +2 -1
  24. package/dist/esm/v3/components/or-textarea-v3/types.d.ts +4 -0
  25. package/dist/esm/v3/index.js +1 -1
  26. package/package.json +2 -3
  27. package/src/components/or-textarea-v3/OrTextarea.vue +33 -9
  28. package/src/components/or-textarea-v3/styles.ts +8 -5
  29. package/src/components/or-textarea-v3/types.ts +5 -0
@@ -9,6 +9,7 @@ import { b as InputBoxSize, a as InputBoxVariant } from '../../types-945b6452.js
9
9
  import { useIdAttribute } from '../../hooks/useIdAttribute.js';
10
10
  import { useControlAttributes } from '../../hooks/useControlAttributes.js';
11
11
  import { useValidationAttributes } from '../../hooks/useValidationAttributes.js';
12
+ import { isObject } from '../../utils/isObject.js';
12
13
  import { useProxyModelValue } from '../../hooks/useProxyModelValue.js';
13
14
  import { s as styleInject } from '../../style-inject.es-4c6f2515.js';
14
15
  import { n as normalizeComponent } from '../../normalize-component-6e8e3d80.js';
@@ -46,9 +47,9 @@ var script = defineComponent({
46
47
  type: String,
47
48
  default: () => InputBoxSize.M
48
49
  },
49
- maxHeight: {
50
- type: String,
51
- default: undefined
50
+ rows: {
51
+ type: [Number, Object],
52
+ default: 2
52
53
  },
53
54
  label: {
54
55
  type: String,
@@ -91,7 +92,19 @@ var script = defineComponent({
91
92
  const root = ref();
92
93
  const rootStyles = computed(() => ['or-textarea-v3', ...Textarea, ...(props.variant === InputBoxVariant.Embedded ? ['grow'] : [])]);
93
94
  const control = ref();
94
- const controlStyles = computed(() => [...TextareaControl, ...TextareaControlSizes[props.size]]);
95
+ const controlStyles = computed(() => [...TextareaControl, ...TextareaControlSizes[props.size], ...(isObject(props.rows) ? ['resize-none'] : [])]);
96
+ const controlInlineStyles = computed(() => {
97
+ if (control.value) {
98
+ const paddingTop = Number(getComputedStyle(control.value).getPropertyValue('padding-top').match(/^(?<value>\d+)px$/).groups.value);
99
+ const paddingBottom = Number(getComputedStyle(control.value).getPropertyValue('padding-bottom').match(/^(?<value>\d+)px$/).groups.value);
100
+ const lineHeight = Number(getComputedStyle(control.value).getPropertyValue('line-height').match(/^(?<value>\d+)px$/).groups.value);
101
+ return {
102
+ minHeight: `${paddingTop + paddingBottom + (isObject(props.rows) ? props.rows.min : props.rows) * lineHeight}px`,
103
+ maxHeight: isObject(props.rows) && props.rows.max ? `${paddingTop + paddingBottom + props.rows.max * lineHeight}px` : undefined
104
+ };
105
+ }
106
+ return {};
107
+ });
95
108
  // State
96
109
  const model = useProxyModelValue(toRef(props, 'modelValue'), context.emit, {
97
110
  defaultValue: ref('')
@@ -113,16 +126,21 @@ var script = defineComponent({
113
126
  (_a = control.value) === null || _a === void 0 ? void 0 : _a.blur();
114
127
  }
115
128
  // Effects
116
- useTextareaAutosize({
117
- element: control,
118
- input: model
119
- });
129
+ if (isObject(props.rows)) {
130
+ // Unluckily, `useTextareaAutosize` doesn't have a teardown function
131
+ // So, dynamically changed `rows` won't have any effect
132
+ useTextareaAutosize({
133
+ element: control,
134
+ input: model
135
+ });
136
+ }
120
137
  return {
121
138
  attributes,
122
139
  root,
123
140
  rootStyles,
124
141
  control,
125
142
  controlStyles,
143
+ controlInlineStyles,
126
144
  model,
127
145
  length,
128
146
  maxLength,
@@ -132,7 +150,7 @@ var script = defineComponent({
132
150
  }
133
151
  });
134
152
 
135
- var css_248z = "textarea[data-v-5a0794ae]{min-width:0;background:0 0;outline:0}";
153
+ var css_248z = "textarea[data-v-7988e64b]{min-width:0;background:0 0;outline:0}";
136
154
  styleInject(css_248z);
137
155
 
138
156
  /* script */
@@ -181,11 +199,10 @@ var __vue_render__ = function () {
181
199
  }],
182
200
  ref: 'control',
183
201
  class: _vm.controlStyles,
184
- style: {
185
- maxHeight: _vm.maxHeight
186
- },
202
+ style: _vm.controlInlineStyles,
187
203
  attrs: {
188
204
  "name": _vm.name,
205
+ "rows": _vm.rows,
189
206
  "autocomplete": _vm.autocomplete,
190
207
  "placeholder": _vm.placeholder,
191
208
  "required": _vm.required,
@@ -262,7 +279,7 @@ var __vue_staticRenderFns__ = [];
262
279
  /* style */
263
280
  const __vue_inject_styles__ = undefined;
264
281
  /* scoped */
265
- const __vue_scope_id__ = "data-v-5a0794ae";
282
+ const __vue_scope_id__ = "data-v-7988e64b";
266
283
  /* module identifier */
267
284
  const __vue_module_identifier__ = undefined;
268
285
  /* functional template */
@@ -1,6 +1,6 @@
1
1
  import { PropType } from 'vue-demi';
2
2
  import { InputBoxSize } from '../or-input-box-v3';
3
- import { TextareaModelValue } from './types';
3
+ import { TextareaModelValue, TextareaRows } from './types';
4
4
  declare const _default: import("vue-demi").DefineComponent<{
5
5
  modelValue: {
6
6
  type: PropType<TextareaModelValue>;
@@ -22,9 +22,9 @@ declare const _default: import("vue-demi").DefineComponent<{
22
22
  type: PropType<"m" | "s">;
23
23
  default: () => InputBoxSize;
24
24
  };
25
- maxHeight: {
26
- type: StringConstructor;
27
- default: undefined;
25
+ rows: {
26
+ type: PropType<TextareaRows>;
27
+ default: number;
28
28
  };
29
29
  label: {
30
30
  type: StringConstructor;
@@ -72,6 +72,13 @@ declare const _default: import("vue-demi").DefineComponent<{
72
72
  rootStyles: import("vue-demi").ComputedRef<string[]>;
73
73
  control: import("vue-demi").Ref<HTMLTextAreaElement | undefined>;
74
74
  controlStyles: import("vue-demi").ComputedRef<string[]>;
75
+ controlInlineStyles: import("vue-demi").ComputedRef<{
76
+ minHeight: string;
77
+ maxHeight: string | undefined;
78
+ } | {
79
+ minHeight?: undefined;
80
+ maxHeight?: undefined;
81
+ }>;
75
82
  model: import("../../hooks").UseProxyModelValueReturn<string>;
76
83
  length: import("vue-demi").ComputedRef<number>;
77
84
  maxLength: import("vue-demi").ComputedRef<number | undefined>;
@@ -98,9 +105,9 @@ declare const _default: import("vue-demi").DefineComponent<{
98
105
  type: PropType<"m" | "s">;
99
106
  default: () => InputBoxSize;
100
107
  };
101
- maxHeight: {
102
- type: StringConstructor;
103
- default: undefined;
108
+ rows: {
109
+ type: PropType<TextareaRows>;
110
+ default: number;
104
111
  };
105
112
  label: {
106
113
  type: StringConstructor;
@@ -143,7 +150,7 @@ declare const _default: import("vue-demi").DefineComponent<{
143
150
  autocomplete: string;
144
151
  variant: "styled" | "unstyled" | "embedded";
145
152
  size: "m" | "s";
146
- maxHeight: string;
153
+ rows: TextareaRows;
147
154
  label: string;
148
155
  placeholder: string;
149
156
  hint: string;
@@ -6,8 +6,6 @@ const Textarea = [
6
6
  // Spacing
7
7
  'gap-xs'];
8
8
  const TextareaControl = [
9
- // Interactivity
10
- 'resize-none',
11
9
  // Box
12
10
  'w-full',
13
11
  // Typography
@@ -17,10 +15,10 @@ const TextareaControl = [
17
15
  const TextareaControlSizes = {
18
16
  [InputBoxSize.M]: [
19
17
  // Spacing
20
- 'pt-sm+* md:pt-sm*'],
18
+ '!mx-0', 'px-md md:px-sm+', 'py-sm+* md:py-sm*'],
21
19
  [InputBoxSize.S]: [
22
20
  // Spacing
23
- 'pt-sm*']
21
+ '!mx-0', 'px-md md:px-sm+', 'py-sm*']
24
22
  };
25
23
 
26
24
  export { Textarea, TextareaControl, TextareaControlSizes };
@@ -1,2 +1,6 @@
1
1
  import { ModelValue } from '../../types';
2
2
  export type TextareaModelValue = ModelValue<string>;
3
+ export type TextareaRows = number | {
4
+ min: number;
5
+ max?: number;
6
+ };