UNPKG

primevue

Version:

PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc

1,214 lines (1,205 loc) 293 kB
import { cn } from '@primeuix/utils'; import { getNextElementSibling, getOuterWidth, getPreviousElementSibling, getAttribute, getFirstFocusableElement, invokeElementMethod, getOuterHeight, isTouchDevice, addStyle, absolutePosition, focus, getIndex, setAttribute, find, removeClass, getOffset, addClass, getHiddenElementOuterWidth, getHiddenElementOuterHeight, isRTL, exportCSV, findSingle, clearSelection, isClickable } from '@primeuix/utils/dom'; import { resolveFieldData, isNotEmpty, equals, isEmpty, reorderArray, findIndexInList, localeComparator, sort } from '@primeuix/utils/object'; import { FilterOperator, FilterMatchMode, FilterService } from '@primevue/core/api'; import { getVNodeProp, HelperSet, ConnectedOverlayScrollHandler } from '@primevue/core/utils'; import ArrowDownIcon from '@primevue/icons/arrowdown'; import ArrowUpIcon from '@primevue/icons/arrowup'; import SpinnerIcon from '@primevue/icons/spinner'; import Paginator from 'primevue/paginator'; import VirtualScroller from 'primevue/virtualscroller'; import BaseComponent from '@primevue/core/basecomponent'; import DataTableStyle from 'primevue/datatable/style'; import ChevronDownIcon from '@primevue/icons/chevrondown'; import ChevronRightIcon from '@primevue/icons/chevronright'; import { mergeProps, resolveComponent, createBlock, openBlock, withCtx, createCommentVNode, resolveDynamicComponent, normalizeClass, resolveDirective, createElementBlock, withDirectives, Fragment, createTextVNode, toDisplayString, createElementVNode, withModifiers, renderList, createVNode, Transition, withKeys, normalizeProps, renderSlot, createSlots } from 'vue'; import BarsIcon from '@primevue/icons/bars'; import CheckIcon from '@primevue/icons/check'; import PencilIcon from '@primevue/icons/pencil'; import TimesIcon from '@primevue/icons/times'; import Button from 'primevue/button'; import OverlayEventBus from 'primevue/overlayeventbus'; import Ripple from 'primevue/ripple'; import Checkbox from 'primevue/checkbox'; import RadioButton from 'primevue/radiobutton'; import { ZIndex } from '@primeuix/utils/zindex'; import FilterIcon from '@primevue/icons/filter'; import FilterFillIcon from '@primevue/icons/filterfill'; import FilterSlashIcon from '@primevue/icons/filterslash'; import PlusIcon from '@primevue/icons/plus'; import TrashIcon from '@primevue/icons/trash'; import FocusTrap from 'primevue/focustrap'; import Portal from 'primevue/portal'; import Select from 'primevue/select'; import SortAltIcon from '@primevue/icons/sortalt'; import SortAmountDownIcon from '@primevue/icons/sortamountdown'; import SortAmountUpAltIcon from '@primevue/icons/sortamountupalt'; import Badge from 'primevue/badge'; var script$d = { name: 'BaseDataTable', "extends": BaseComponent, props: { value: { type: Array, "default": null }, dataKey: { type: [String, Function], "default": null }, rows: { type: Number, "default": 0 }, first: { type: Number, "default": 0 }, totalRecords: { type: Number, "default": 0 }, paginator: { type: Boolean, "default": false }, paginatorPosition: { type: String, "default": 'bottom' }, alwaysShowPaginator: { type: Boolean, "default": true }, paginatorTemplate: { type: [Object, String], "default": 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown' }, pageLinkSize: { type: Number, "default": 5 }, rowsPerPageOptions: { type: Array, "default": null }, currentPageReportTemplate: { type: String, "default": '({currentPage} of {totalPages})' }, lazy: { type: Boolean, "default": false }, loading: { type: Boolean, "default": false }, loadingIcon: { type: String, "default": undefined }, sortField: { type: [String, Function], "default": null }, sortOrder: { type: Number, "default": null }, defaultSortOrder: { type: Number, "default": 1 }, nullSortOrder: { type: Number, "default": 1 }, multiSortMeta: { type: Array, "default": null }, sortMode: { type: String, "default": 'single' }, removableSort: { type: Boolean, "default": false }, filters: { type: Object, "default": null }, filterDisplay: { type: String, "default": null }, globalFilterFields: { type: Array, "default": null }, filterLocale: { type: String, "default": undefined }, selection: { type: [Array, Object], "default": null }, selectionMode: { type: String, "default": null }, compareSelectionBy: { type: String, "default": 'deepEquals' }, metaKeySelection: { type: Boolean, "default": false }, contextMenu: { type: Boolean, "default": false }, contextMenuSelection: { type: Object, "default": null }, selectAll: { type: Boolean, "default": null }, rowHover: { type: Boolean, "default": false }, csvSeparator: { type: String, "default": ',' }, exportFilename: { type: String, "default": 'download' }, exportFunction: { type: Function, "default": null }, resizableColumns: { type: Boolean, "default": false }, columnResizeMode: { type: String, "default": 'fit' }, reorderableColumns: { type: Boolean, "default": false }, expandedRows: { type: [Array, Object], "default": null }, expandedRowIcon: { type: String, "default": undefined }, collapsedRowIcon: { type: String, "default": undefined }, rowGroupMode: { type: String, "default": null }, groupRowsBy: { type: [Array, String, Function], "default": null }, expandableRowGroups: { type: Boolean, "default": false }, expandedRowGroups: { type: Array, "default": null }, stateStorage: { type: String, "default": 'session' }, stateKey: { type: String, "default": null }, editMode: { type: String, "default": null }, editingRows: { type: Array, "default": null }, rowClass: { type: Function, "default": null }, rowStyle: { type: Function, "default": null }, scrollable: { type: Boolean, "default": false }, virtualScrollerOptions: { type: Object, "default": null }, scrollHeight: { type: String, "default": null }, frozenValue: { type: Array, "default": null }, breakpoint: { type: String, "default": '960px' }, showHeaders: { type: Boolean, "default": true }, showGridlines: { type: Boolean, "default": false }, stripedRows: { type: Boolean, "default": false }, highlightOnSelect: { type: Boolean, "default": false }, size: { type: String, "default": null }, tableStyle: { type: null, "default": null }, tableClass: { type: [String, Object], "default": null }, tableProps: { type: Object, "default": null }, filterInputProps: { type: null, "default": null }, filterButtonProps: { type: Object, "default": function _default() { return { filter: { severity: 'secondary', text: true, rounded: true }, inline: { clear: { severity: 'secondary', text: true, rounded: true } }, popover: { addRule: { severity: 'info', text: true, size: 'small' }, removeRule: { severity: 'danger', text: true, size: 'small' }, apply: { size: 'small' }, clear: { outlined: true, size: 'small' } } }; } }, editButtonProps: { type: Object, "default": function _default() { return { init: { severity: 'secondary', text: true, rounded: true }, save: { severity: 'secondary', text: true, rounded: true }, cancel: { severity: 'secondary', text: true, rounded: true } }; } } }, style: DataTableStyle, provide: function provide() { return { $pcDataTable: this, $parentInstance: this }; } }; var script$c = { name: 'RowCheckbox', hostName: 'DataTable', "extends": BaseComponent, emits: ['change'], props: { value: null, checked: null, column: null, rowCheckboxIconTemplate: { type: Function, "default": null }, index: { type: Number, "default": null } }, methods: { getColumnPT: function getColumnPT(key) { var columnMetaData = { props: this.column.props, parent: { instance: this, props: this.$props, state: this.$data }, context: { index: this.index, checked: this.checked, disabled: this.$attrs.disabled } }; return mergeProps(this.ptm("column.".concat(key), { column: columnMetaData }), this.ptm("column.".concat(key), columnMetaData), this.ptmo(this.getColumnProp(), key, columnMetaData)); }, getColumnProp: function getColumnProp() { return this.column.props && this.column.props.pt ? this.column.props.pt : undefined; //@todo: }, onChange: function onChange(event) { if (!this.$attrs.disabled) { this.$emit('change', { originalEvent: event, data: this.value }); } } }, computed: { checkboxAriaLabel: function checkboxAriaLabel() { return this.$primevue.config.locale.aria ? this.checked ? this.$primevue.config.locale.aria.selectRow : this.$primevue.config.locale.aria.unselectRow : undefined; } }, components: { CheckIcon: CheckIcon, Checkbox: Checkbox } }; function render$c(_ctx, _cache, $props, $setup, $data, $options) { var _component_CheckIcon = resolveComponent("CheckIcon"); var _component_Checkbox = resolveComponent("Checkbox"); return openBlock(), createBlock(_component_Checkbox, { modelValue: $props.checked, binary: true, disabled: _ctx.$attrs.disabled, "aria-label": $options.checkboxAriaLabel, onChange: $options.onChange, unstyled: _ctx.unstyled, pt: $options.getColumnPT('pcRowCheckbox') }, { icon: withCtx(function (slotProps) { return [$props.rowCheckboxIconTemplate ? (openBlock(), createBlock(resolveDynamicComponent($props.rowCheckboxIconTemplate), { key: 0, checked: slotProps.checked, "class": normalizeClass(slotProps["class"]) }, null, 8, ["checked", "class"])) : !$props.rowCheckboxIconTemplate && slotProps.checked ? (openBlock(), createBlock(_component_CheckIcon, mergeProps({ key: 1, "class": slotProps["class"] }, $options.getColumnPT('pcRowCheckbox.icon')), null, 16, ["class"])) : createCommentVNode("", true)]; }), _: 1 }, 8, ["modelValue", "disabled", "aria-label", "onChange", "unstyled", "pt"]); } script$c.render = render$c; var script$b = { name: 'RowRadioButton', hostName: 'DataTable', "extends": BaseComponent, emits: ['change'], props: { value: null, checked: null, name: null, column: null, index: { type: Number, "default": null } }, methods: { getColumnPT: function getColumnPT(key) { var columnMetaData = { props: this.column.props, parent: { instance: this, props: this.$props, state: this.$data }, context: { index: this.index, checked: this.checked, disabled: this.$attrs.disabled } }; return mergeProps(this.ptm("column.".concat(key), { column: columnMetaData }), this.ptm("column.".concat(key), columnMetaData), this.ptmo(this.getColumnProp(), key, columnMetaData)); }, getColumnProp: function getColumnProp() { return this.column.props && this.column.props.pt ? this.column.props.pt : undefined; //@todo: }, onChange: function onChange(event) { if (!this.$attrs.disabled) { this.$emit('change', { originalEvent: event, data: this.value }); } } }, components: { RadioButton: RadioButton } }; function render$b(_ctx, _cache, $props, $setup, $data, $options) { var _component_RadioButton = resolveComponent("RadioButton"); return openBlock(), createBlock(_component_RadioButton, { modelValue: $props.checked, binary: true, disabled: _ctx.$attrs.disabled, name: $props.name, onChange: $options.onChange, unstyled: _ctx.unstyled, pt: $options.getColumnPT('pcRowRadiobutton') }, null, 8, ["modelValue", "disabled", "name", "onChange", "unstyled", "pt"]); } script$b.render = render$b; function _typeof$c(o) { "@babel/helpers - typeof"; return _typeof$c = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$c(o); } function _regeneratorRuntime() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: true }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), true), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof$c(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, true); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(true); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = false, e; return e.value = t, e.done = true, e; }; return a.next = a; } } throw new TypeError(_typeof$c(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = false, t; return t.done = true, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = true; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), false; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), true; if (u < h) return n(h), false; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; } function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } var script$a = { name: 'BodyCell', hostName: 'DataTable', "extends": BaseComponent, emits: ['cell-edit-init', 'cell-edit-complete', 'cell-edit-cancel', 'row-edit-init', 'row-edit-save', 'row-edit-cancel', 'row-toggle', 'radio-change', 'checkbox-change', 'editing-meta-change'], props: { rowData: { type: Object, "default": null }, column: { type: Object, "default": null }, frozenRow: { type: Boolean, "default": false }, rowIndex: { type: Number, "default": null }, index: { type: Number, "default": null }, isRowExpanded: { type: Boolean, "default": false }, selected: { type: Boolean, "default": false }, editing: { type: Boolean, "default": false }, editingMeta: { type: Object, "default": null }, editMode: { type: String, "default": null }, virtualScrollerContentProps: { type: Object, "default": null }, ariaControls: { type: String, "default": null }, name: { type: String, "default": null }, expandedRowIcon: { type: String, "default": null }, collapsedRowIcon: { type: String, "default": null }, editButtonProps: { type: Object, "default": null } }, documentEditListener: null, selfClick: false, overlayEventListener: null, editCompleteTimeout: null, data: function data() { return { d_editing: this.editing, styleObject: {} }; }, watch: { editing: function editing(newValue) { this.d_editing = newValue; }, '$data.d_editing': function $dataD_editing(newValue) { this.$emit('editing-meta-change', { data: this.rowData, field: this.field || "field_".concat(this.index), index: this.rowIndex, editing: newValue }); } }, mounted: function mounted() { if (this.columnProp('frozen')) { this.updateStickyPosition(); } }, updated: function updated() { var _this = this; if (this.columnProp('frozen')) { this.updateStickyPosition(); } if (this.d_editing && (this.editMode === 'cell' || this.editMode === 'row' && this.columnProp('rowEditor'))) { setTimeout(function () { var focusableEl = getFirstFocusableElement(_this.$el); focusableEl && focusableEl.focus(); }, 1); } }, beforeUnmount: function beforeUnmount() { if (this.overlayEventListener) { OverlayEventBus.off('overlay-click', this.overlayEventListener); this.overlayEventListener = null; } }, methods: { columnProp: function columnProp(prop) { return getVNodeProp(this.column, prop); }, getColumnPT: function getColumnPT(key) { var _this$$parentInstance, _this$$parentInstance2; var columnMetaData = { props: this.column.props, parent: { instance: this, props: this.$props, state: this.$data }, context: { index: this.index, size: (_this$$parentInstance = this.$parentInstance) === null || _this$$parentInstance === void 0 || (_this$$parentInstance = _this$$parentInstance.$parentInstance) === null || _this$$parentInstance === void 0 ? void 0 : _this$$parentInstance.size, showGridlines: (_this$$parentInstance2 = this.$parentInstance) === null || _this$$parentInstance2 === void 0 || (_this$$parentInstance2 = _this$$parentInstance2.$parentInstance) === null || _this$$parentInstance2 === void 0 ? void 0 : _this$$parentInstance2.showGridlines } }; return mergeProps(this.ptm("column.".concat(key), { column: columnMetaData }), this.ptm("column.".concat(key), columnMetaData), this.ptmo(this.getColumnProp(), key, columnMetaData)); }, getColumnProp: function getColumnProp() { return this.column.props && this.column.props.pt ? this.column.props.pt : undefined; }, resolveFieldData: function resolveFieldData$1() { return resolveFieldData(this.rowData, this.field); }, toggleRow: function toggleRow(event) { this.$emit('row-toggle', { originalEvent: event, data: this.rowData }); }, toggleRowWithRadio: function toggleRowWithRadio(event, index) { this.$emit('radio-change', { originalEvent: event.originalEvent, index: index, data: event.data }); }, toggleRowWithCheckbox: function toggleRowWithCheckbox(event, index) { this.$emit('checkbox-change', { originalEvent: event.originalEvent, index: index, data: event.data }); }, isEditable: function isEditable() { return this.column.children && this.column.children.editor != null; }, bindDocumentEditListener: function bindDocumentEditListener() { var _this2 = this; if (!this.documentEditListener) { this.documentEditListener = function (event) { _this2.selfClick = _this2.$el && _this2.$el.contains(event.target); if (_this2.editCompleteTimeout) { clearTimeout(_this2.editCompleteTimeout); } if (!_this2.selfClick) { _this2.editCompleteTimeout = setTimeout(function () { _this2.completeEdit(event, 'outside'); }, 1); } }; document.addEventListener('mousedown', this.documentEditListener); } }, unbindDocumentEditListener: function unbindDocumentEditListener() { if (this.documentEditListener) { document.removeEventListener('mousedown', this.documentEditListener); this.documentEditListener = null; this.selfClick = false; if (this.editCompleteTimeout) { clearTimeout(this.editCompleteTimeout); this.editCompleteTimeout = null; } } }, switchCellToViewMode: function switchCellToViewMode() { this.d_editing = false; this.unbindDocumentEditListener(); OverlayEventBus.off('overlay-click', this.overlayEventListener); this.overlayEventListener = null; }, onClick: function onClick(event) { var _this3 = this; if (this.editMode === 'cell' && this.isEditable()) { if (!this.d_editing) { this.d_editing = true; this.bindDocumentEditListener(); this.$emit('cell-edit-init', { originalEvent: event, data: this.rowData, field: this.field, index: this.rowIndex }); this.overlayEventListener = function (e) { _this3.selfClick = _this3.$el && _this3.$el.contains(e.target); }; OverlayEventBus.on('overlay-click', this.overlayEventListener); } } }, completeEdit: function completeEdit(event, type) { var completeEvent = { originalEvent: event, data: this.rowData, newData: this.editingRowData, value: this.rowData[this.field], newValue: this.editingRowData[this.field], field: this.field, index: this.rowIndex, type: type, defaultPrevented: false, preventDefault: function preventDefault() { this.defaultPrevented = true; } }; this.$emit('cell-edit-complete', completeEvent); if (!completeEvent.defaultPrevented) { this.switchCellToViewMode(); } }, onKeyDown: function onKeyDown(event) { if (this.editMode === 'cell') { switch (event.code) { case 'Enter': case 'NumpadEnter': this.completeEdit(event, 'enter'); break; case 'Escape': this.switchCellToViewMode(); this.$emit('cell-edit-cancel', { originalEvent: event, data: this.rowData, field: this.field, index: this.rowIndex }); break; case 'Tab': this.completeEdit(event, 'tab'); if (event.shiftKey) this.moveToPreviousCell(event);else this.moveToNextCell(event); break; } } }, moveToPreviousCell: function moveToPreviousCell(event) { var _this4 = this; return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() { var currentCell, targetCell; return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: currentCell = _this4.findCell(event.target); targetCell = _this4.findPreviousEditableColumn(currentCell); if (!targetCell) { _context.next = 7; break; } _context.next = 5; return _this4.$nextTick(); case 5: invokeElementMethod(targetCell, 'click'); event.preventDefault(); case 7: case "end": return _context.stop(); } }, _callee); }))(); }, moveToNextCell: function moveToNextCell(event) { var _this5 = this; return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { var currentCell, targetCell; return _regeneratorRuntime().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: currentCell = _this5.findCell(event.target); targetCell = _this5.findNextEditableColumn(currentCell); if (!targetCell) { _context2.next = 7; break; } _context2.next = 5; return _this5.$nextTick(); case 5: invokeElementMethod(targetCell, 'click'); event.preventDefault(); case 7: case "end": return _context2.stop(); } }, _callee2); }))(); }, findCell: function findCell(element) { if (element) { var cell = element; while (cell && !getAttribute(cell, 'data-p-cell-editing')) { cell = cell.parentElement; } return cell; } else { return null; } }, findPreviousEditableColumn: function findPreviousEditableColumn(cell) { var prevCell = cell.previousElementSibling; if (!prevCell) { var previousRow = cell.parentElement.previousElementSibling; if (previousRow) { prevCell = previousRow.lastElementChild; } } if (prevCell) { if (getAttribute(prevCell, 'data-p-editable-column')) return prevCell;else return this.findPreviousEditableColumn(prevCell); } else { return null; } }, findNextEditableColumn: function findNextEditableColumn(cell) { var nextCell = cell.nextElementSibling; if (!nextCell) { var nextRow = cell.parentElement.nextElementSibling; if (nextRow) { nextCell = nextRow.firstElementChild; } } if (nextCell) { if (getAttribute(nextCell, 'data-p-editable-column')) return nextCell;else return this.findNextEditableColumn(nextCell); } else { return null; } }, onRowEditInit: function onRowEditInit(event) { this.$emit('row-edit-init', { originalEvent: event, data: this.rowData, newData: this.editingRowData, field: this.field, index: this.rowIndex }); }, onRowEditSave: function onRowEditSave(event) { this.$emit('row-edit-save', { originalEvent: event, data: this.rowData, newData: this.editingRowData, field: this.field, index: this.rowIndex }); }, onRowEditCancel: function onRowEditCancel(event) { this.$emit('row-edit-cancel', { originalEvent: event, data: this.rowData, newData: this.editingRowData, field: this.field, index: this.rowIndex }); }, editorInitCallback: function editorInitCallback(event) { this.$emit('row-edit-init', { originalEvent: event, data: this.rowData, newData: this.editingRowData, field: this.field, index: this.rowIndex }); }, editorSaveCallback: function editorSaveCallback(event) { if (this.editMode === 'row') { this.$emit('row-edit-save', { originalEvent: event, data: this.rowData, newData: this.editingRowData, field: this.field, index: this.rowIndex }); } else { this.completeEdit(event, 'enter'); } }, editorCancelCallback: function editorCancelCallback(event) { if (this.editMode === 'row') { this.$emit('row-edit-cancel', { originalEvent: event, data: this.rowData, newData: this.editingRowData, field: this.field, index: this.rowIndex }); } else { this.switchCellToViewMode(); this.$emit('cell-edit-cancel', { originalEvent: event, data: this.rowData, field: this.field, index: this.rowIndex }); } }, updateStickyPosition: function updateStickyPosition() { if (this.columnProp('frozen')) { var align = this.columnProp('alignFrozen'); if (align === 'right') { var pos = 0; var next = getNextElementSibling(this.$el, '[data-p-frozen-column="true"]'); if (next) { pos = getOuterWidth(next) + parseFloat(next.style['inset-inline-end'] || 0); } this.styleObject.insetInlineEnd = pos + 'px'; } else { var _pos = 0; var prev = getPreviousElementSibling(this.$el, '[data-p-frozen-column="true"]'); if (prev) { _pos = getOuterWidth(prev) + parseFloat(prev.style['inset-inline-start'] || 0); } this.styleObject.insetInlineStart = _pos + 'px'; } } }, getVirtualScrollerProp: function getVirtualScrollerProp(option) { return this.virtualScrollerContentProps ? this.virtualScrollerContentProps[option] : null; } }, computed: { editingRowData: function editingRowData() { return this.editingMeta[this.rowIndex] ? this.editingMeta[this.rowIndex].data : this.rowData; }, field: function field() { return this.columnProp('field'); }, containerClass: function containerClass() { return [this.columnProp('bodyClass'), this.columnProp('class'), this.cx('bodyCell')]; }, containerStyle: function containerStyle() { var bodyStyle = this.columnProp('bodyStyle'); var columnStyle = this.columnProp('style'); return this.columnProp('frozen') ? [columnStyle, bodyStyle, this.styleObject] : [columnStyle, bodyStyle]; }, loading: function loading() { return this.getVirtualScrollerProp('loading'); }, loadingOptions: function loadingOptions() { var getLoaderOptions = this.getVirtualScrollerProp('getLoaderOptions'); return getLoaderOptions && getLoaderOptions(this.rowIndex, { cellIndex: this.index, cellFirst: this.index === 0, cellLast: this.index === this.getVirtualScrollerProp('columns').length - 1, cellEven: this.index % 2 === 0, cellOdd: this.index % 2 !== 0, column: this.column, field: this.field }); }, expandButtonAriaLabel: function expandButtonAriaLabel() { return this.$primevue.config.locale.aria ? this.isRowExpanded ? this.$primevue.config.locale.aria.expandRow : this.$primevue.config.locale.aria.collapseRow : undefined; }, initButtonAriaLabel: function initButtonAriaLabel() { return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.editRow : undefined; }, saveButtonAriaLabel: function saveButtonAriaLabel() { return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.saveEdit : undefined; }, cancelButtonAriaLabel: function cancelButtonAriaLabel() { return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.cancelEdit : undefined; } }, components: { DTRadioButton: script$b, DTCheckbox: script$c, Button: Button, ChevronDownIcon: ChevronDownIcon, ChevronRightIcon: ChevronRightIcon, BarsIcon: BarsIcon, PencilIcon: PencilIcon, CheckIcon: CheckIcon, TimesIcon: TimesIcon }, directives: { ripple: Ripple } }; function _typeof$b(o) { "@babel/helpers - typeof"; return _typeof$b = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$b(o); } function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), true).forEach(function (r) { _defineProperty$b(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty$b(e, r, t) { return (r = _toPropertyKey$b(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; } function _toPropertyKey$b(t) { var i = _toPrimitive$b(t, "string"); return "symbol" == _typeof$b(i) ? i : i + ""; } function _toPrimitive$b(t, r) { if ("object" != _typeof$b(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != _typeof$b(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } var _hoisted_1$9 = ["colspan", "rowspan", "data-p-selection-column", "data-p-editable-column", "data-p-cell-editing", "data-p-frozen-column"]; var _hoisted_2$3 = ["aria-expanded", "aria-controls", "aria-label"]; function render$a(_ctx, _cache, $props, $setup, $data, $options) { var _component_DTRadioButton = resolveComponent("DTRadioButton"); var _component_DTCheckbox = resolveComponent("DTCheckbox"); var _component_BarsIcon = resolveComponent("BarsIcon"); var _component_ChevronDownIcon = resolveComponent("ChevronDownIcon"); var _component_ChevronRightIcon = resolveComponent("ChevronRightIcon"); var _component_Button = resolveComponent("Button"); var _directive_ripple = resolveDirective("ripple"); return $options.loading ? (openBlock(), createElementBlock("td", mergeProps({ key: 0, style: $options.containerStyle, "class": $options.containerClass, role: "cell" }, _objectSpread$b(_objectSpread$b({}, $options.getColumnPT('root')), $options.getColumnPT('bodyCell'))), [(openBlock(), createBlock(resolveDynamicComponent($props.column.children.loading), { data: $props.rowData, column: $props.column, field: $options.field, index: $props.rowIndex, frozenRow: $props.frozenRow, loadingOptions: $options.loadingOptions }, null, 8, ["data", "column", "field", "index", "frozenRow", "loadingOptions"]))], 16)) : (openBlock(), createElementBlock("td", mergeProps({ key: 1, style: $options.containerStyle, "class": $options.containerClass, colspan: $options.columnProp('colspan'), rowspan: $options.columnProp('rowspan'), onClick: _cache[3] || (_cache[3] = function () { return $options.onClick && $options.onClick.apply($options, arguments); }), onKeydown: _cache[4] || (_cache[4] = function () { return $options.onKeyDown && $options.onKeyDown.apply($options, arguments); }), role: "cell" }, _objectSpread$b(_objectSpread$b({}, $options.getColumnPT('root')), $options.getColumnPT('bodyCell')), { "data-p-selection-column": $options.columnProp('selectionMode') != null, "data-p-editable-column": $options.isEditable(), "data-p-cell-editing": $data.d_editing, "data-p-frozen-column": $options.columnProp('frozen') }), [$props.column.children && $props.column.children.body && !$data.d_editing ? (openBlock(), createBlock(resolveDynamicComponent($props.column.children.body), { key: 0, data: $props.rowData, column: $props.column, field: $options.field, index: $props.rowIndex, frozenRow: $props.frozenRow, editorInitCallback: $options.editorInitCallback, rowTogglerCallback: $options.toggleRow }, null, 8, ["data", "column", "field", "index", "frozenRow", "editorInitCallback", "rowTogglerCallback"])) : $props.column.children && $props.column.children.editor && $data.d_editing ? (openBlock(), createBlock(resolveDynamicComponent($props.column.children.editor), { key: 1, data: $options.editingRowData, column: $props.column, field: $options.field, index: $props.rowIndex, frozenRow: $props.frozenRow, editorSaveCallback: $options.editorSaveCallback, editorCancelCallback: $options.editorCancelCallback }, null, 8, ["data", "column", "field", "index", "frozenRow", "editorSaveCallback", "editorCancelCallback"])) : $props.column.children && $props.column.children.body && !$props.column.children.editor && $data.d_editing ? (openBlock(), createBlock(resolveDynamicComponent($props.column.children.body), { key: 2, data: $options.editingRowData, column: $props.column, field: $options.field, index: $props.rowIndex, frozenRow: $props.frozenRow }, null, 8, ["data", "column", "field", "index", "frozenRow"])) : $options.columnProp('selectionMode') ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [$options.columnProp('selectionMode') === 'single' ? (openBlock(), createBlock(_component_DTRadioButton, { key: 0, value: $props.rowData, name: $props.name, checked: $props.selected, onChange: _cache[0] || (_cache[0] = function ($event) { return $options.toggleRowWithRadio($event, $props.rowIndex); }), column: $props.column, index: $props.index, unstyled: _ctx.unstyled, pt: _ctx.pt }, null, 8, ["value", "name", "checked", "column", "index", "unstyled", "pt"])) : $options.columnProp('selectionMode') === 'multiple' ? (openBlock(), createBlock(_component_DTCheckbox, { key: 1, value: $props.rowData, checked: $props.selected, rowCheckboxIconTemplate: $props.column.children && $props.column.children.rowcheckboxicon, "aria-selected": $props.selected ? true : undefined, onChange: _cache[1] || (_cache[1] = function ($event) { return $options.toggleRowWithCheckbox($event, $props.rowIndex); }), column: $props.column, index: $props.index, unstyled: _ctx.unstyled, pt: _ctx.pt }, null, 8, ["value", "checked", "rowCheckboxIconTemplate", "aria-selected", "column", "index", "unstyled", "pt"])) : createCommentVNode("", true)], 64)) : $options.columnProp('rowReorder') ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [$props.column.children && $props.column.children.rowreordericon ? (openBlock(), createBlock(resolveDynamicComponent($props.column.children.rowreordericon), { key: 0, "class": normalizeClass(_ctx.cx('reorderableRowHandle')) }, null, 8, ["class"])) : $options.columnProp('rowReorderIcon') ? (openBlock(), createElementBlock("i", mergeProps({ key: 1, "class": [_ctx.cx('reorderableRowHandle'), $options.columnProp('rowReorderIcon')] }, $options.getColumnPT('reorderableRowHandle')), null, 16)) : (openBlock(), createBlock(_component_BarsIcon, mergeProps({ key: 2, "class": _ctx.cx('reorderableRowHandle') }, $options.getColumnPT('reorderableRowHandle')), null, 16, ["class"]))], 64)) : $options.columnProp('expander') ? withDirectives((openBlock(), createElementBlock("button", mergeProps({ key: 5, "class": _ctx.cx('rowToggleButton'), type: "button", "aria-expanded": $props.isRowExpanded, "aria-controls": $props.ariaControls, "aria-label": $options.expandButtonAriaLabel, onClick: _cache[2] || (_cache[2] = function () { return $options.toggleRow && $options.toggleRow.apply($options, arguments); }), "data-p-selected": "selected" }, $options.getColumnPT('rowToggleButton'), { "data-pc-group-section": "rowactionbutton" }), [$props.column.children && $props.column.children.rowtoggleicon ? (openBlock(), createBlock(resolveDynamicComponent($props.column.children.rowtoggleicon), { key: 0, "class": normalizeClass(_ctx.cx('rowToggleIcon')), rowExpanded: $props.isRowExpanded }, null, 8, ["class", "rowExpanded"])) : $props.column.children && $props.column.children.rowtogglericon ? (openBlock(), createBlock(resolveDynamicComponent($props.column.children.rowtogglericon), { key: 1, "class": normalizeClass(_ctx.cx('rowToggleIcon')), rowExpanded: $props.isRowExpanded }, null, 8, ["class", "rowExpanded"])) : (openBlock(), createElementBlock(Fragment, { key: 2 }, [$props.isRowExpanded && $props.expandedRowIcon ? (openBlock(), createElementBlock("span", { key: 0, "class": normalizeClass([_ctx.cx('rowToggleIcon'), $props.expandedRowIcon]) }, null, 2)) : $props.isRowExpanded && !$props.expandedRowIcon ? (openBlock(), createBlock(_component_ChevronDownIcon, mergeProps({ key: 1, "class": _ctx.cx('rowToggleIcon') }, $options.getColumnPT('rowToggleIcon')), null, 16, ["class"])) : !$props.isRowExpanded && $props.collapsedRowIcon ? (openBlock(), createElementBlock("span", { key: 2, "class": normalizeClass([_ctx.cx('rowToggleIcon'), $props.collapsedRowIcon]) }, null, 2)) : !$props.isRowExpanded && !$props.collapsedRowIcon ? (openBlock(), createBlock(_component_ChevronRightIcon, mergeProps({ key: 3, "class": _ctx.cx('rowToggleIcon') }, $options.getColumnPT('rowToggleIcon')), null, 16, ["class"])) : createCommentVNode("", true)], 64))], 16, _hoisted_2$3)), [[_directive_ripple]]) : $props.editMode === 'row' && $options.columnProp('rowEditor') ? (openBlock(), createElementBlock(Fragment, { key: 6 }, [!$data.d_editing ? (openBlock(), createBlock(_component_Button, mergeProps({ key: 0, "class": _ctx.cx('pcRowEditorInit'), "aria-label": $options.initButtonAriaLabel, unstyled: _ctx.unstyled, onClick: $options.onRowEditInit }, $props.editButtonProps.init, { pt: $options.getColumnPT('pcRowEditorInit'), "data-pc-group-section": "rowactionbutton" }), { icon: withCtx(function (slotProps) { return [(openBlock(), createBlock(resolveDynamicComponent($props.column.children && $props.column.children.roweditoriniticon || 'PencilIcon'), mergeProps({ "class": slotProps["class"] }, $options.getColumnPT('pcRowEditorInit')['icon']), null, 16, ["class"]))]; }), _: 1 }, 16, ["class", "aria-label", "unstyled", "onClick", "pt"])) : createCommentVNode("", true), $data.d_editing ? (openBlock(), createBlock(_component_Button, mergeProps({ key: 1, "class": _ctx.cx('pcRowEditorSave'), "aria-label": $options.saveButtonAriaLabel, unstyled: _ctx.unstyled, onClick: $options.onRowEditSave }, $props.editButtonProps.save, { pt: $options.getColumnPT('pcRowEditorSave'), "data-pc-group-section": "rowac