@progress/kendo-vue-inputs 2.7.0 → 2.7.1-dev.202112201049

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 (36) hide show
  1. package/dist/cdn/js/kendo-vue-inputs.js +1 -1
  2. package/dist/es/main.d.ts +5 -0
  3. package/dist/es/main.js +5 -0
  4. package/dist/es/package-metadata.js +1 -1
  5. package/dist/es/switch/Switch.d.ts +131 -0
  6. package/dist/es/switch/Switch.js +304 -0
  7. package/dist/es/switch/util.d.ts +8 -0
  8. package/dist/es/switch/util.js +46 -0
  9. package/dist/es/textarea/TextArea.d.ts +46 -0
  10. package/dist/es/textarea/TextArea.js +251 -0
  11. package/dist/es/textarea/interfaces/TextAreaBlurEvent.d.ts +5 -0
  12. package/dist/es/textarea/interfaces/TextAreaBlurEvent.js +0 -0
  13. package/dist/es/textarea/interfaces/TextAreaChangeEvent.d.ts +9 -0
  14. package/dist/es/textarea/interfaces/TextAreaChangeEvent.js +0 -0
  15. package/dist/es/textarea/interfaces/TextAreaFocusEvent.d.ts +5 -0
  16. package/dist/es/textarea/interfaces/TextAreaFocusEvent.js +0 -0
  17. package/dist/es/textarea/interfaces/TextAreaProps.d.ts +84 -0
  18. package/dist/es/textarea/interfaces/TextAreaProps.js +0 -0
  19. package/dist/npm/main.d.ts +5 -0
  20. package/dist/npm/main.js +6 -0
  21. package/dist/npm/package-metadata.js +1 -1
  22. package/dist/npm/switch/Switch.d.ts +131 -0
  23. package/dist/npm/switch/Switch.js +317 -0
  24. package/dist/npm/switch/util.d.ts +8 -0
  25. package/dist/npm/switch/util.js +49 -0
  26. package/dist/npm/textarea/TextArea.d.ts +46 -0
  27. package/dist/npm/textarea/TextArea.js +261 -0
  28. package/dist/npm/textarea/interfaces/TextAreaBlurEvent.d.ts +5 -0
  29. package/dist/npm/textarea/interfaces/TextAreaBlurEvent.js +2 -0
  30. package/dist/npm/textarea/interfaces/TextAreaChangeEvent.d.ts +9 -0
  31. package/dist/npm/textarea/interfaces/TextAreaChangeEvent.js +2 -0
  32. package/dist/npm/textarea/interfaces/TextAreaFocusEvent.d.ts +5 -0
  33. package/dist/npm/textarea/interfaces/TextAreaFocusEvent.js +2 -0
  34. package/dist/npm/textarea/interfaces/TextAreaProps.d.ts +84 -0
  35. package/dist/npm/textarea/interfaces/TextAreaProps.js +5 -0
  36. package/package.json +7 -7
@@ -0,0 +1,131 @@
1
+ import { DefineComponent } from '../additionalTypes';
2
+ import { RecordPropsDefinition, ComponentOptions } from 'vue/types/options';
3
+ declare type DefaultData<V> = object | ((this: V) => {});
4
+ declare type DefaultMethods<V> = {
5
+ [key: string]: (this: V, ...args: any[]) => any;
6
+ };
7
+ import { FormComponentProps } from '@progress/kendo-vue-common';
8
+ import { ToggleBaseProps } from '../interfaces/ToggleBaseProps';
9
+ import { LocalizationService } from '@progress/kendo-vue-intl';
10
+ /**
11
+ * The arguments for the `onChange` Switch event.
12
+ */
13
+ export interface SwitchChangeEvent {
14
+ /**
15
+ * The new value of the Switch.
16
+ */
17
+ value: boolean;
18
+ }
19
+ /**
20
+ * Represents the props of the [Kendo UI for Vue Switch component]({% slug overview_switch %}).
21
+ */
22
+ export interface SwitchProps extends ToggleBaseProps, FormComponentProps {
23
+ /**
24
+ * Specifies the `accessKey` of the Switch.
25
+ */
26
+ accessKey?: string;
27
+ /**
28
+ * Sets the current value of the Switch ([see example]({% slug controlled_switch %})).
29
+ */
30
+ checked?: boolean;
31
+ /**
32
+ * Sets the `className` of the wrapping element of the Switch.
33
+ */
34
+ className?: string;
35
+ /**
36
+ * Sets the value of the Switch when it is initially displayed ([see example]({% slug default_state %})).
37
+ */
38
+ defaultChecked?: boolean;
39
+ /**
40
+ * Sets the default value of the Switch.
41
+ */
42
+ defaultValue?: any;
43
+ /**
44
+ * Disables the Switch when set to `true` ([see example]({% slug disabled_switch %})).
45
+ */
46
+ disabled?: boolean;
47
+ /**
48
+ * Sets the `dir` property of the wrapping element of the Switch.
49
+ */
50
+ dir?: string;
51
+ /**
52
+ * Sets the `id` of the Switch.
53
+ */
54
+ id?: string;
55
+ /**
56
+ * Identifies the element(s) which will describe the component, similar to [HTML aria-describedby attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-describedby_attribute).
57
+ * For example these elements could contain error or hint message.
58
+ */
59
+ ariaDescribedBy?: string;
60
+ /**
61
+ * Identifies the element(s) which will label the component.
62
+ */
63
+ ariaLabelledBy?: string;
64
+ /**
65
+ * Changes the **Off** label([see example]({% slug labels_switch %})).
66
+ */
67
+ offLabel?: string;
68
+ /**
69
+ * Fires each time the Switch gets blurred.
70
+ */
71
+ onBlur?: (event: any) => void;
72
+ /**
73
+ * Fires each time the user selects a new value ([see example]({% slug controlled_switch %})).
74
+ */
75
+ onChange?: (event: SwitchChangeEvent) => void;
76
+ /**
77
+ * Fires each time the Switch component gets focused.
78
+ */
79
+ onFocus?: (event: any) => void;
80
+ /**
81
+ * Changes the **On** label ([see example]({% slug labels_switch %})).
82
+ */
83
+ onLabel?: string;
84
+ /**
85
+ * Specifies the [`tabIndex`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) of the component.
86
+ */
87
+ tabIndex?: number;
88
+ /**
89
+ * Sets the value of the Switch. It can either be of the primitive (string, number, boolean) or of the complex (array) type.
90
+ */
91
+ value?: string | number | string[] | boolean | null;
92
+ modelValue?: string | number | string[] | boolean | null;
93
+ }
94
+ /**
95
+ * @hidden
96
+ */
97
+ export interface SwitchState {
98
+ _element: HTMLSpanElement | null;
99
+ _input: HTMLInputElement | null;
100
+ _id: string;
101
+ dir?: string;
102
+ defaultValidationMessage: LocalizationService;
103
+ eventTimeStamp?: number;
104
+ }
105
+ /**
106
+ * @hidden
107
+ */
108
+ export interface SwitchComputed {
109
+ }
110
+ /**
111
+ * @hidden
112
+ */
113
+ export interface SwitchMethods {
114
+ [key: string]: any;
115
+ }
116
+ /**
117
+ * @hidden
118
+ */
119
+ export interface SwitchData {
120
+ valueDuringOnChange?: boolean;
121
+ currentChecked: boolean;
122
+ focused: boolean;
123
+ }
124
+ /**
125
+ * @hidden
126
+ */
127
+ export interface SwitchAll extends Vue, SwitchMethods, SwitchData, SwitchComputed, SwitchState {
128
+ }
129
+ declare let Switch: ComponentOptions<SwitchAll, DefaultData<SwitchData>, DefaultMethods<SwitchAll>, SwitchComputed, RecordPropsDefinition<SwitchProps>>;
130
+ declare const SwitchVue3: DefineComponent<SwitchProps, any, SwitchData, SwitchComputed, SwitchMethods, {}, {}, {}, string, SwitchProps, SwitchProps, {}>;
131
+ export { Switch, SwitchVue3 };
@@ -0,0 +1,304 @@
1
+ // @ts-ignore
2
+ import * as Vue from 'vue';
3
+ var allVue = Vue;
4
+ var gh = allVue.h;
5
+ import { guid, noop, Keys, getTabIndex, validatePackage, isRtl } from '@progress/kendo-vue-common';
6
+ import { provideLocalizationService } from '@progress/kendo-vue-intl';
7
+ import { messages, switchValidation } from './../messages';
8
+ import { packageMetadata } from '../package-metadata';
9
+ var SWITCH_CONTAINER = 'k-switch-container';
10
+ var SWITCH_HANDLE = 'k-switch-handle';
11
+ var SWITCH_LABEL_ON = 'k-switch-label-on';
12
+ var SWITCH_LABEL_OFF = 'k-switch-label-off'; // tslint:enable:max-line-length
13
+
14
+ var Switch = {
15
+ name: 'KendoSwitch',
16
+ model: {
17
+ event: 'changemodel'
18
+ },
19
+ // @ts-ignore
20
+ emits: {
21
+ 'change': null,
22
+ 'changemodel': null,
23
+ 'update:modelValue': null,
24
+ 'focus': null,
25
+ 'blur': null
26
+ },
27
+ props: {
28
+ accessKey: String,
29
+ checked: {
30
+ type: Boolean,
31
+ default: undefined
32
+ },
33
+ className: String,
34
+ disabled: {
35
+ type: Boolean,
36
+ default: false
37
+ },
38
+ defaultChecked: {
39
+ type: Boolean,
40
+ default: false
41
+ },
42
+ dir: String,
43
+ id: String,
44
+ ariaLabelledBy: String,
45
+ ariaDescribedBy: String,
46
+ offLabel: {
47
+ type: String,
48
+ default: 'OFF'
49
+ },
50
+ onLabel: {
51
+ type: String,
52
+ default: 'ON'
53
+ },
54
+ required: {
55
+ type: Boolean,
56
+ default: false
57
+ },
58
+ tabIndex: Number,
59
+ valid: Boolean,
60
+ // validate: {
61
+ // type: Boolean,
62
+ // default: false
63
+ // },
64
+ validityStyles: {
65
+ type: Boolean,
66
+ default: false
67
+ },
68
+ validationMessage: String,
69
+ value: [String, Number, Boolean],
70
+ modelValue: {
71
+ type: Boolean,
72
+ default: undefined
73
+ }
74
+ },
75
+ created: function created() {
76
+ validatePackage(packageMetadata);
77
+ this._id = guid();
78
+ this.defaultValidationMessage = provideLocalizationService(this);
79
+ },
80
+ data: function data() {
81
+ return {
82
+ currentChecked: this.$props.defaultChecked,
83
+ valueDuringOnChange: undefined,
84
+ focused: false,
85
+ currentDir: undefined
86
+ };
87
+ },
88
+ computed: {
89
+ computedValue: function computedValue() {
90
+ return this.valueDuringOnChange !== undefined ? this.valueDuringOnChange : this.$props.checked !== undefined ? this.$props.checked : this.$props.value !== undefined ? this.$props.value : this.$props.modelValue !== undefined ? this.$props.modelValue : this.currentChecked;
91
+ },
92
+ switchClassName: function switchClassName() {
93
+ var isValid = !this.validityStyles || this.validity().valid;
94
+ return {
95
+ 'k-widget': true,
96
+ 'k-switch': true,
97
+ 'k-switch-on': this.computedValue,
98
+ 'k-switch-off': !this.computedValue,
99
+ 'k-state-focused': this.focused,
100
+ 'k-state-disabled': this.$props.disabled,
101
+ 'k-state-invalid': !isValid
102
+ };
103
+ }
104
+ },
105
+ mounted: function mounted() {
106
+ this._element = this.v3 ? this.elementRef : this.$refs.element;
107
+ this.input = this.v3 ? this.inputRef : this.$refs.input;
108
+ this.currentDir = this.$props.dir !== undefined ? this.$props.dir : isRtl(this.$el) ? 'rtl' : 'ltr';
109
+ this.setValidity();
110
+ },
111
+ updated: function updated() {
112
+ this.setValidity();
113
+ },
114
+ // @ts-ignore
115
+ setup: !gh ? undefined : function () {
116
+ var v3 = !!gh;
117
+ return {
118
+ v3: v3
119
+ };
120
+ },
121
+ // @ts-ignore
122
+ render: function render(createElement) {
123
+ var _this = this;
124
+
125
+ var h = gh || createElement;
126
+ var _a = this.$props,
127
+ disabled = _a.disabled,
128
+ id = _a.id,
129
+ offLabel = _a.offLabel,
130
+ onLabel = _a.onLabel,
131
+ tabIndex = _a.tabIndex;
132
+ return h("span", {
133
+ "class": this.switchClassName,
134
+ dir: this.currentDir,
135
+ attrs: this.v3 ? undefined : {
136
+ dir: this.currentDir
137
+ },
138
+ onKeydown: this.handleKeyDown,
139
+ on: this.v3 ? undefined : {
140
+ "keydown": this.handleKeyDown,
141
+ "click": this.handleClick,
142
+ "focusout": this.handleWrapperBlur,
143
+ "focusin": this.handleWrapperFocus
144
+ },
145
+ onClick: this.handleClick,
146
+ onFocusout: this.handleWrapperBlur,
147
+ onFocusin: this.handleWrapperFocus
148
+ }, [h("span", {
149
+ "class": SWITCH_CONTAINER,
150
+ id: id || this._id,
151
+ attrs: this.v3 ? undefined : {
152
+ id: id || this._id,
153
+ role: 'switch',
154
+ "aria-checked": this.computedValue,
155
+ "aria-disabled": disabled || undefined,
156
+ "aria-labelledby": this.$props.ariaLabelledBy,
157
+ "aria-describedby": this.$props.ariaDescribedBy,
158
+ tabIndex: getTabIndex(tabIndex, disabled, undefined),
159
+ accessKey: this.$props.accessKey
160
+ },
161
+ role: 'switch',
162
+ "aria-checked": this.computedValue,
163
+ "aria-disabled": disabled || undefined,
164
+ "aria-labelledby": this.$props.ariaLabelledBy,
165
+ "aria-describedby": this.$props.ariaDescribedBy,
166
+ ref: this.v3 ? function (el) {
167
+ _this.elementRef = el;
168
+ } : 'element',
169
+ tabIndex: getTabIndex(tabIndex, disabled, undefined),
170
+ accessKey: this.$props.accessKey
171
+ }, [h("input", {
172
+ type: "checkbox",
173
+ attrs: this.v3 ? undefined : {
174
+ type: "checkbox",
175
+ tabIndex: -1,
176
+ "aria-hidden": true
177
+ },
178
+ checked: this.v3 ? this.$props.checked : null,
179
+ domProps: this.v3 ? undefined : {
180
+ "checked": this.$props.checked,
181
+ "value": this.computedValue
182
+ },
183
+ ref: this.v3 ? function (el) {
184
+ _this.inputRef = el;
185
+ } : 'input',
186
+ tabIndex: -1,
187
+ "aria-hidden": true,
188
+ value: this.v3 ? this.computedValue : null,
189
+ style: {
190
+ opacity: 0,
191
+ width: 1,
192
+ border: 0,
193
+ zIndex: -1,
194
+ position: 'absolute',
195
+ left: '50%'
196
+ },
197
+ onChange: noop,
198
+ on: this.v3 ? undefined : {
199
+ "change": noop
200
+ }
201
+ }), h("span", {
202
+ "class": SWITCH_LABEL_ON
203
+ }, [onLabel]), h("span", {
204
+ "class": SWITCH_LABEL_OFF
205
+ }, [offLabel]), h("span", {
206
+ "class": SWITCH_HANDLE
207
+ })])]);
208
+ },
209
+ methods: {
210
+ focus: function focus() {
211
+ if (this._element) {
212
+ this._element.focus();
213
+ }
214
+ },
215
+ element: function element() {
216
+ return this._element;
217
+ },
218
+ name: function name() {
219
+ return this.$props.name;
220
+ },
221
+ validity: function validity() {
222
+ var customError = this.$props.validationMessage !== undefined;
223
+ var isValid = this.$props.valid !== undefined ? this.$props.valid : !this.$props.required ? true : this.computedValue ? true : false;
224
+ var valid = this.$props.valid !== undefined ? this.$props.valid : isValid;
225
+ return {
226
+ customError: customError,
227
+ valid: valid,
228
+ valueMissing: this.computedValue === null
229
+ };
230
+ },
231
+ setValidity: function setValidity() {
232
+ if (this.input && this.input.setCustomValidity) {
233
+ this.input.setCustomValidity(this.validity().valid ? '' : this.$props.validationMessage || this.defaultValidationMessage.toLanguageString(switchValidation, messages[switchValidation]));
234
+ }
235
+ },
236
+ limit: function limit(offset, drag, wrapper) {
237
+ var wrapperWidth = wrapper.offsetWidth;
238
+ var margin = drag.offsetWidth;
239
+
240
+ if (offset < 0) {
241
+ return 0;
242
+ } else if (offset > wrapperWidth - margin) {
243
+ return wrapperWidth - margin;
244
+ }
245
+
246
+ return offset;
247
+ },
248
+ toggle: function toggle(value, event) {
249
+ this.currentChecked = value;
250
+ this.valueDuringOnChange = value;
251
+ this.$emit('change', {
252
+ event: event,
253
+ component: this,
254
+ target: {
255
+ value: value
256
+ },
257
+ name: this.$props.name,
258
+ value: value,
259
+ validity: this.validity()
260
+ });
261
+ this.$emit('changemodel', value);
262
+ this.$emit('update:modelValue', value);
263
+ this.valueDuringOnChange = undefined;
264
+ },
265
+ handleClick: function handleClick(event) {
266
+ if (this.eventTimeStamp === event.timeStamp) {
267
+ // This is guard against the case when wrapped in label, click event is emmited twice
268
+ return;
269
+ }
270
+
271
+ this.eventTimeStamp = event.timeStamp;
272
+ this.toggle(!this.computedValue, event);
273
+ },
274
+ handleKeyDown: function handleKeyDown(event) {
275
+ if (this.$props.disabled) {
276
+ return;
277
+ }
278
+
279
+ var keyCode = event.keyCode;
280
+
281
+ if (keyCode === Keys.space || keyCode === Keys.enter) {
282
+ this.toggle(!this.computedValue, event);
283
+ }
284
+ },
285
+ handleWrapperFocus: function handleWrapperFocus(event) {
286
+ if (this.$props.disabled) {
287
+ return;
288
+ }
289
+
290
+ this.focused = true;
291
+ this.$emit('focus', event);
292
+ },
293
+ handleWrapperBlur: function handleWrapperBlur(event) {
294
+ if (this.$props.disabled) {
295
+ return;
296
+ }
297
+
298
+ this.focused = false;
299
+ this.$emit('blur', event);
300
+ }
301
+ }
302
+ };
303
+ var SwitchVue3 = Switch;
304
+ export { Switch, SwitchVue3 };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @hidden
3
+ */
4
+ export declare const FRAME_DURATION: number;
5
+ /**
6
+ * @hidden
7
+ */
8
+ export declare const throttle: (func: Function, wait: number, options?: any) => (this: any) => any;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @hidden
3
+ */
4
+ export var FRAME_DURATION = 1000 / 60; // 1000ms divided by 60fps
5
+ /**
6
+ * @hidden
7
+ */
8
+ export var throttle = function (func, wait, options) {
9
+ if (options === void 0) { options = {}; }
10
+ var timeout, context, args, result;
11
+ var previous = 0;
12
+ options = options || {};
13
+ var later = function () {
14
+ previous = options.leading === false ? 0 : new Date().getTime();
15
+ timeout = null;
16
+ result = func.apply(context, args);
17
+ if (!timeout) {
18
+ context = args = null;
19
+ }
20
+ };
21
+ var throttled = function () {
22
+ var now = new Date().getTime();
23
+ if (!previous && options.leading === false) {
24
+ previous = now;
25
+ }
26
+ var remaining = wait - (now - previous);
27
+ context = this;
28
+ args = arguments;
29
+ if (remaining <= 0 || remaining > wait) {
30
+ if (timeout) {
31
+ clearTimeout(timeout);
32
+ timeout = null;
33
+ }
34
+ previous = now;
35
+ result = func.apply(context, args);
36
+ if (!timeout) {
37
+ context = args = null;
38
+ }
39
+ }
40
+ else if (!timeout && options.trailing !== false) {
41
+ timeout = window.setTimeout(later, remaining);
42
+ }
43
+ return result;
44
+ };
45
+ return throttled;
46
+ };
@@ -0,0 +1,46 @@
1
+ import { DefineComponent } from '../additionalTypes';
2
+ import { RecordPropsDefinition, ComponentOptions } from 'vue/types/options';
3
+ declare type DefaultData<V> = object | ((this: V) => {});
4
+ declare type DefaultMethods<V> = {
5
+ [key: string]: (this: V, ...args: any[]) => any;
6
+ };
7
+ import { TextAreaProps } from './interfaces/TextAreaProps';
8
+ /**
9
+ * @hidden
10
+ */
11
+ export interface TextAreaHandle {
12
+ element: HTMLTextAreaElement | null;
13
+ focus: any;
14
+ name?: string | null;
15
+ }
16
+ /**
17
+ * @hidden
18
+ */
19
+ export interface TextAreaState {
20
+ }
21
+ /**
22
+ * @hidden
23
+ */
24
+ export interface TextAreaComputed {
25
+ [key: string]: any;
26
+ }
27
+ /**
28
+ * @hidden
29
+ */
30
+ export interface TextAreaMethods {
31
+ [key: string]: any;
32
+ }
33
+ /**
34
+ * @hidden
35
+ */
36
+ export interface TextAreaData {
37
+ currentActive: boolean;
38
+ }
39
+ /**
40
+ * @hidden
41
+ */
42
+ export interface TextAreaAll extends Vue, TextAreaMethods, TextAreaData, TextAreaComputed, TextAreaState {
43
+ }
44
+ declare let TextArea: ComponentOptions<TextAreaAll, DefaultData<TextAreaData>, DefaultMethods<TextAreaAll>, TextAreaComputed, RecordPropsDefinition<TextAreaProps>>;
45
+ declare const TextAreaVue3: DefineComponent<TextAreaProps, any, TextAreaData, TextAreaComputed, TextAreaMethods, {}, {}, {}, string, TextAreaProps, TextAreaProps, {}>;
46
+ export { TextArea, TextAreaVue3 };