@triptyk/ember-yeti-table 3.0.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.
- package/LICENSE.md +9 -0
- package/README.md +132 -0
- package/addon-main.cjs +4 -0
- package/declarations/themes/default-theme.d.ts +28 -0
- package/declarations/themes/default-theme.d.ts.map +1 -0
- package/declarations/utils/create-regex.d.ts +2 -0
- package/declarations/utils/create-regex.d.ts.map +1 -0
- package/declarations/utils/filtering-utils.d.ts +5 -0
- package/declarations/utils/filtering-utils.d.ts.map +1 -0
- package/declarations/utils/sorting-utils.d.ts +24 -0
- package/declarations/utils/sorting-utils.d.ts.map +1 -0
- package/dist/_app_/components/yeti-table/body.js +1 -0
- package/dist/_app_/components/yeti-table/header.js +1 -0
- package/dist/_app_/components/yeti-table/pagination.js +1 -0
- package/dist/_app_/components/yeti-table/table.js +1 -0
- package/dist/_app_/components/yeti-table/tbody/row/cell.js +1 -0
- package/dist/_app_/components/yeti-table/tbody/row.js +1 -0
- package/dist/_app_/components/yeti-table/tbody.js +1 -0
- package/dist/_app_/components/yeti-table/tfoot/row/cell.js +1 -0
- package/dist/_app_/components/yeti-table/tfoot/row.js +1 -0
- package/dist/_app_/components/yeti-table/tfoot.js +1 -0
- package/dist/_app_/components/yeti-table/thead/row/cell.js +1 -0
- package/dist/_app_/components/yeti-table/thead/row/column.js +1 -0
- package/dist/_app_/components/yeti-table/thead/row.js +1 -0
- package/dist/_app_/components/yeti-table/thead.js +1 -0
- package/dist/_app_/components/yeti-table.js +1 -0
- package/dist/_app_/themes/default-theme.js +1 -0
- package/dist/_app_/utils/create-regex.js +1 -0
- package/dist/_app_/utils/filtering-utils.js +1 -0
- package/dist/_app_/utils/sorting-utils.js +1 -0
- package/dist/components/yeti-table/body.js +37 -0
- package/dist/components/yeti-table/body.js.map +1 -0
- package/dist/components/yeti-table/header.js +30 -0
- package/dist/components/yeti-table/header.js.map +1 -0
- package/dist/components/yeti-table/pagination.js +86 -0
- package/dist/components/yeti-table/pagination.js.map +1 -0
- package/dist/components/yeti-table/table.js +38 -0
- package/dist/components/yeti-table/table.js.map +1 -0
- package/dist/components/yeti-table/tbody/row/cell.js +35 -0
- package/dist/components/yeti-table/tbody/row/cell.js.map +1 -0
- package/dist/components/yeti-table/tbody/row.js +47 -0
- package/dist/components/yeti-table/tbody/row.js.map +1 -0
- package/dist/components/yeti-table/tbody.js +20 -0
- package/dist/components/yeti-table/tbody.js.map +1 -0
- package/dist/components/yeti-table/tfoot/row/cell.js +31 -0
- package/dist/components/yeti-table/tfoot/row/cell.js.map +1 -0
- package/dist/components/yeti-table/tfoot/row.js +31 -0
- package/dist/components/yeti-table/tfoot/row.js.map +1 -0
- package/dist/components/yeti-table/tfoot.js +20 -0
- package/dist/components/yeti-table/tfoot.js.map +1 -0
- package/dist/components/yeti-table/thead/row/cell.js +24 -0
- package/dist/components/yeti-table/thead/row/cell.js.map +1 -0
- package/dist/components/yeti-table/thead/row/column.js +202 -0
- package/dist/components/yeti-table/thead/row/column.js.map +1 -0
- package/dist/components/yeti-table/thead/row.js +41 -0
- package/dist/components/yeti-table/thead/row.js.map +1 -0
- package/dist/components/yeti-table/thead.js +35 -0
- package/dist/components/yeti-table/thead.js.map +1 -0
- package/dist/components/yeti-table.js +618 -0
- package/dist/components/yeti-table.js.map +1 -0
- package/dist/themes/default-theme.js +51 -0
- package/dist/themes/default-theme.js.map +1 -0
- package/dist/utils/create-regex.js +34 -0
- package/dist/utils/create-regex.js.map +1 -0
- package/dist/utils/filtering-utils.js +55 -0
- package/dist/utils/filtering-utils.js.map +1 -0
- package/dist/utils/sorting-utils.js +93 -0
- package/dist/utils/sorting-utils.js.map +1 -0
- package/package.json +124 -0
- package/src/.gitkeep +0 -0
- package/src/components/yeti-table/body.gjs +94 -0
- package/src/components/yeti-table/header.gjs +54 -0
- package/src/components/yeti-table/pagination.gjs +155 -0
- package/src/components/yeti-table/table.gjs +34 -0
- package/src/components/yeti-table/tbody/row/cell.gjs +51 -0
- package/src/components/yeti-table/tbody/row.gjs +89 -0
- package/src/components/yeti-table/tbody.gjs +55 -0
- package/src/components/yeti-table/tfoot/row/cell.gjs +45 -0
- package/src/components/yeti-table/tfoot/row.gjs +44 -0
- package/src/components/yeti-table/tfoot.gjs +33 -0
- package/src/components/yeti-table/thead/row/cell.gjs +52 -0
- package/src/components/yeti-table/thead/row/column.gjs +260 -0
- package/src/components/yeti-table/thead/row.gjs +71 -0
- package/src/components/yeti-table/thead.gjs +45 -0
- package/src/components/yeti-table.gjs +780 -0
- package/src/themes/default-theme.js +53 -0
- package/src/utils/create-regex.js +65 -0
- package/src/utils/filtering-utils.js +75 -0
- package/src/utils/sorting-utils.js +108 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yeti-table.js","sources":["../../src/components/yeti-table.gjs"],"sourcesContent":["import { getOwner } from '@ember/application';\nimport { action, notifyPropertyChange } from '@ember/object';\nimport { later, schedule, scheduleOnce } from '@ember/runloop';\nimport { isEmpty, isPresent } from '@ember/utils';\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport merge from 'deepmerge';\nimport { use } from 'ember-resources';\nimport { trackedFunction } from 'reactiveweb/function';\nimport { keepLatest } from 'reactiveweb/keep-latest';\nimport { dedupeTracked, localCopy } from 'tracked-toolbox';\nimport { cached } from '@glimmer/tracking';\n\nimport DEFAULT_THEME from '../themes/default-theme.js';\nimport filterData from '../utils/filtering-utils.js';\nimport {\n compareValues,\n mergeSort,\n sortMultiple,\n} from '../utils/sorting-utils.js';\nimport Helper from '@ember/component/helper';\n/**\n The primary Yeti Table component. This component represents the root of the\n table, and manages high level state of all of its subcomponents.\n\n ```hbs\n <YetiTable @data={{this.data}} as |table|>\n\n <table.header as |header|>\n <header.column @prop=\"firstName\">\n First name\n </header.column>\n <header.column @prop=\"lastName\">\n Last name\n </header.column>\n <header.column @prop=\"points\">\n Points\n </header.column>\n </table.header>\n\n <table.body/>\n\n </YetiTable>\n ```\n\n ```hbs\n <YetiTable @data={{this.data}} as |table|>\n\n <table.thead as |thead|>\n <thead.row as |row|>\n <row.column @prop=\"firstName\">\n First name\n </row.column>\n <row.column @prop=\"lastName\">\n Last name\n </row.column>\n <row.column @prop=\"points\">\n Points\n </row.column>\n </thead.row>\n </table.thead>\n\n <table.body/>\n\n </YetiTable>\n ```\n @class YetiTable\n @yield {object} table\n @yield {Component} table.header the table header component (Single row in header)\n @yield {Component} table.thead the table header component (Allows multiple rows in header)\n @yield {Component} table.body the table body component\n @yield {Component} table.tfoot the table footer component\n @yield {Component} table.pagination the pagination controls component\n @yield {object} table.actions an object that contains actions to interact with the table\n @yield {object} table.paginationData object that represents the current pagination state\n @yield {boolean} table.isLoading boolean that is `true` when data is being loaded\n @yield {array} table.columns the columns on the table\n @yield {array} table.visibleColumns the visible columns on the table\n @yield {array} table.rows an array of all the rows yeti table knows of. In the sync case, it will contain the entire dataset. In the async case, it will be the same as `table.visibleRows`\n @yield {number} table.totalRows the total number of rows on the table (regardless of pagination). Important argument in the async case to inform yeti table of the total number of rows in the dataset.\n @yield {array} table.visibleRows the rendered rows on the table account for pagination, filtering, etc; when pagination is false, it will be the same length as totalRows\n @yield {object} table.theme the theme being used\n */\n// template imports\nimport { hash } from '@ember/helper';\nimport Table from './yeti-table/table.gjs';\nimport Header from './yeti-table/header.gjs';\nimport THead from './yeti-table/thead.gjs';\nimport Body from './yeti-table/body.gjs';\nimport TBody from './yeti-table/tbody.gjs';\nimport TFoot from './yeti-table/tfoot.gjs';\nimport Pagination from './yeti-table/pagination.gjs';\n\n// bring ember-concurrency didCancel helper instead of\n// including the whole dependency\nconst TASK_CANCELATION_NAME = 'TaskCancelation';\nconst didCancel = function (e) {\n return e && e.name === TASK_CANCELATION_NAME;\n};\n\nconst getConfigWithDefault = function (key, defaultValue) {\n return function () {\n return this.config[key] ?? defaultValue;\n };\n};\n\n// we keep `totalRows` updated manually in xwaan untracked property\n// to allow the user to update it in a loadData call and avoid\n// a re-run of the main tracked function\nclass UpdateTotalRows extends Helper {\n compute(positional, { context }) {\n context.totalRows = positional[0];\n notifyPropertyChange(context, 'normalizedTotalRows');\n notifyPropertyChange(context, 'paginationData');\n return '';\n }\n}\n\n// we need some control of how we update the filter property, hence this modifier\n// in this case, any falsy value will be considered as en empty string, which will then\n// be deduped.\nclass UpdateFilter extends Helper {\n compute(positional, { context }) {\n context.filter = positional[0] || '';\n return '';\n }\n}\n\nclass ProcessedData extends Helper {\n compute(positional, { loadData, context }) {\n let data = context.latestData ?? [];\n\n if (!loadData) {\n context.processData(data);\n } else {\n // This is instrumental to ignoreDataChanges working\n context.processedData = data;\n }\n return '';\n }\n}\n\nexport default class YetiTable extends Component {\n <template>\n {{#let\n (hash\n table=(component Table theme=this.mergedTheme parent=this)\n header=(component\n Header\n columns=this.columns\n onColumnClick=this.onColumnSort\n sortable=this.sortable\n sortSequence=this.sortSequence\n parent=this\n theme=this.mergedTheme\n )\n thead=(component\n THead\n columns=this.columns\n onColumnClick=this.onColumnSort\n sortable=this.sortable\n sortSequence=this.sortSequence\n theme=this.mergedTheme\n parent=this\n )\n body=(component\n Body\n data=this.processedData\n columns=this.columns\n theme=this.mergedTheme\n parent=this\n )\n tbody=(component\n TBody\n data=this.processedData\n columns=this.columns\n theme=this.mergedTheme\n parent=this\n )\n tfoot=(component\n TFoot columns=this.columns theme=this.mergedTheme parent=this\n )\n pagination=(component\n Pagination\n disabled=this.isLoading\n theme=this.mergedTheme\n paginationData=this.paginationData\n paginationActions=(hash\n previousPage=this.previousPage\n nextPage=this.nextPage\n goToPage=this.goToPage\n changePageSize=this.changePageSize\n )\n )\n actions=this.publicApi\n paginationData=this.paginationData\n isLoading=this.resolvedData.isPending\n columns=this.columns\n visibleColumns=this.visibleColumns\n rows=this.normalizedRows\n totalRows=this.normalizedTotalRows\n visibleRows=this.processedData\n theme=this.mergedTheme\n )\n as |api|\n }}\n {{UpdateTotalRows @totalRows context=this}}\n {{UpdateFilter @filter context=this}}\n {{ProcessedData loadData=@loadData context=this}}\n\n {{#if this.renderTableElement}}\n <Table @theme={{this.mergedTheme}} @parent={{this}} ...attributes>\n {{yield api}}\n </Table>\n {{else}}\n {{yield api}}\n {{/if}}\n\n {{/let}}\n </template>\n /**\n * An object that contains classes for yeti table to apply when rendering its various table\n * html elements. The theme object your pass in will be deeply merged with yeti-table's default theme\n * and with a theme defined in your environment.js at `ENV['ember-yeti-table'].theme`.\n *\n * @argument theme\n * @type {Object}\n */\n\n /**\n * The data for Yeti Table to render. It can be an array or a promise that resolves with an array.\n * The only case when `@data` is optional is if a `@loadData` was passed in.\n * @argument data\n * @type {Array | Promise<Array>}\n */\n\n /**\n * The function that will be called when Yeti Table needs data. This argument is used\n * when you don't have all the data available or loading all rows at once isn't possible,\n * e.g the dataset is too large.\n *\n * By passing in a function to `@loadData` you assume the responsibility to filter, sort and\n * paginate the data (if said features are enabled).\n *\n * This function must return an array or a promise that resolves with an array.\n *\n * This function will be called with an argument with the current state of the table.\n * Use this object to know what data to fetch, pass it to the server, etc.\n * Please check the \"Async Data\" guide to understand what that object contains and\n * an example of its usage.\n *\n * @argument loadData\n * @type {Function}\n */\n\n publicApi = {\n previousPage: this.previousPage,\n nextPage: this.nextPage,\n goToPage: this.goToPage,\n changePageSize: this.changePageSize,\n reloadData: this.reloadData,\n };\n\n /**\n * This function will be called when Yeti Table initializes. It will be called with\n * an object argument containing the functions for the possible actions you can make\n * on a table. This object contains the following actions:\n * - previousPage\n * - nextPage\n * - goToPage\n * - changePageSize\n * - reloadData\n *\n * @argument registerApi\n * @type {Function}\n */\n\n /**\n * Use this argument to enable the pagination feature. Default is `false`.\n *\n * @argument pagination\n * @type {Boolean}\n */\n @localCopy('args.pagination', getConfigWithDefault('pagination', false))\n pagination;\n\n /**\n * Controls the size of each page. Default is `15`.\n *\n * @argument pageSize\n * @type {number}\n */\n @localCopy('args.pageSize', getConfigWithDefault('pageSize', 15))\n pageSize;\n\n /**\n * Controls the current page to show. Default is `1`.\n *\n * @argument pageNumber\n * @type {number}\n */\n @localCopy('args.pageNumber', 1)\n pageNumber;\n\n /**\n * Optional argument that informs yeti table of how many rows your data has.\n * Only needed when using a `@loadData` function and `@pagination={{true}}`.\n * When you use `@data`, Yeti Table uses the size of that array.\n * This information is used to calculate the pagination information that is yielded\n * and passed to the `@loadData` function.\n *\n * @argument totalRows\n * @type {number}\n */\n totalRows;\n\n // we keep `totalRows` updated manually in an untracked property\n // to allow the user to update it in a loadData call and avoid\n // a re-run of the main tracked function\n // @action\n // updateTotalRows(totalRows) {\n // this.totalRows = totalRows;\n // notifyPropertyChange(this, 'normalizedTotalRows');\n // notifyPropertyChange(this, 'paginationData');\n // }\n\n /**\n * The global filter. If passed in, Yeti Table will search all the rows that contain this\n * string and show them. Defaults to `''`.\n *\n * @argument filter\n * @type {String}\n */\n @dedupeTracked\n filter = '';\n\n // we need some control of how we update the filter property, hence this modifier\n // in this case, any falsy value will be considered as en empty string, which will then\n // be deduped.\n // @action\n // updateFilter(filter) {\n // this.filter = filter || '';\n // }\n\n /**\n * An optional function to customize the filtering logic. This function should return true\n * or false to either include or exclude the row on the resulting set. If this function depends\n * on a value, pass that value as the `@filterUsing` argument.\n *\n * This function will be called with two arguments:\n * - `row` - the current data row to use for filtering\n * - `filterUsing` - the value you passed in as `@filterUsing`\n *\n * @argument filterFunction\n * @type {Function}\n */\n\n /**\n * If you `@filterFunction` function depends on a different value (other that `@filter`)\n * to show, pass it in this argument. Yeti Table uses this argument to know when to recalculate\n * the fitlered rows.\n *\n * @argument filterUsing\n * @type {Object}\n */\n\n /**\n * Used to enable/disable sorting on all columns. You should use this to avoid passing\n * the @sortable argument to all columns. Defaults to `true`.\n *\n * @argument sortable\n * @type {Boolean}\n */\n @localCopy('args.sortable', getConfigWithDefault('sortable', true))\n sortable;\n\n /**\n * Use the `@sortFunction` if you want to completely customize how the row sorting is done.\n * It will be invoked with two rows, the current sortings that are applied and the `@compareFunction`.\n *\n * @argument sortFunction\n * @type {Function}\n */\n @localCopy('args.sortFunction', () => sortMultiple)\n sortFunction;\n\n /**\n * Use `@compareFunction` if you just want to customize how two values relate to each other (not the entire row).\n * It will be invoked with two values and you just need to return `-1`, `0` or `1` depending on if first value is\n * greater than the second or not. The default compare function used is the `compare` function from `@ember/utils`.\n *\n * @argument compareFunction\n * @type {Function}\n */\n @localCopy('args.compareFunction', () => compareValues)\n compareFunction;\n\n /**\n * Use `@sortSequence` to customize the sequence in which the sorting order will cycle when\n * clicking on the table headers. You can either pass in a comma-separated string or an array\n * of strings. Accepted values are `'asc'`, `'desc'` and `'unsorted'`. The default value is `['asc', 'desc']`.\n *\n * @argument sortSequence\n * @type {Array<string> | string}\n */\n @localCopy(\n 'args.sortSequence',\n getConfigWithDefault('sortSequence', ['asc', 'desc']),\n )\n sortSequence;\n\n /**\n * Use `@ignoreDataChanges` to prevent yeti table from observing changes to the underlying data and resorting or\n * refiltering. Useful when doing inline editing in a table.\n *\n * Defaults to `false`.\n *\n * This is an initial render only value. Changing it after the table has been rendered will not be respected.\n *\n * @argument ignoreDataChanges\n * @type {boolean}\n */\n @localCopy(\n 'args.ignoreDataChanges',\n getConfigWithDefault('ignoreDataChanges', false),\n )\n ignoreDataChanges;\n\n /**\n * Use `@renderTableElement` to prevent yeti table from rendering the topmost <table> element.\n * Might be useful for styling purposes (e.g if you want to place your pagination controls outside\n * of your table element). If you set this to `false`, you should render the table element yourself\n * using the yielded `<t.table>` component.\n *\n * Defaults to `true`.\n *\n * @argument renderTableElement\n * @type {boolean}\n */\n @localCopy('args.renderTableElement', true)\n renderTableElement;\n\n /**\n * The `@isColumnVisible` argument can be used to initialize the column visibility in a programmatic way.\n * For example, let's say you store the initial column visibility in local storage, then you can\n * use this function to initialize the `visible` column of the specific column. The given function should\n * return a boolean which will be assigned to the `visible` property of the column. An object representing\n * the column is passed in. Sou can use column.prop and column.name to know which column your computed\n * the visibility for.\n *\n * @argument isColumnVisible\n * @type {Function}\n */\n\n // If the theme is replaced, this will invalidate, but not if any prop under theme is changed\n @cached\n get mergedTheme() {\n let configTheme = this.config.theme || {};\n let localTheme = this.args.theme || {};\n return merge.all([DEFAULT_THEME, configTheme, localTheme]);\n }\n\n @cached\n get visibleColumns() {\n return this.columns.filter((c) => c.visible === true);\n }\n\n config =\n getOwner(this).resolveRegistration('config:environment')[\n 'ember-yeti-table'\n ] || {};\n\n get normalizedTotalRows() {\n if (!this.args.loadData) {\n // sync scenario using @data\n return this.processedDataRows?.length || 0;\n } else {\n // async scenario. @loadData is present.\n if (this.totalRows === undefined) {\n // @totalRows was not passed in. Use the latest returned data set length as a fallback\n return this.previousResolvedData.length || 0;\n } else {\n // @totalRows was passed in.\n return this.totalRows;\n }\n }\n }\n\n get normalizedRows() {\n if (!this.args.loadData) {\n // sync scenario using @data\n return this.processedDataRows;\n } else {\n // async scenario. @loadData is present.\n return this.processedData;\n }\n }\n\n get paginationData() {\n let pageSize = this.pageSize;\n let pageNumber = this.pageNumber;\n let totalRows = this.normalizedTotalRows;\n let isLastPage, totalPages;\n\n if (totalRows) {\n totalPages = Math.ceil(totalRows / pageSize);\n pageNumber = Math.min(pageNumber, totalPages);\n isLastPage = pageNumber === totalPages;\n }\n\n let isFirstPage = pageNumber === 1;\n let pageStart = (pageNumber - 1) * pageSize + 1;\n let pageEnd = pageStart + pageSize - 1;\n\n if (totalRows) {\n pageEnd = Math.min(pageEnd, totalRows);\n }\n\n return {\n pageSize,\n pageNumber,\n pageStart,\n pageEnd,\n isFirstPage,\n isLastPage,\n totalRows,\n totalPages,\n };\n }\n\n @tracked\n columns = [];\n\n constructor(owner, args) {\n super(...arguments);\n\n console.log(owner, args);\n\n if (typeof this.args.registerApi === 'function') {\n // eslint-disable-next-line ember/no-runloop\n scheduleOnce('actions', null, this.args.registerApi, this.publicApi);\n }\n }\n\n previousResolvedData = [];\n\n resolvedData = trackedFunction(this, async () => {\n let data = this.args.data;\n\n if (this.columns.length == 0) {\n return [];\n }\n\n // call loadData if exists\n if (typeof this.args.loadData === 'function') {\n let params = this.computeLoadDataParams();\n\n try {\n console.log(\"loadData\", params);\n\n data = await this.args.loadData(params);\n\n console.log(\"loadData end\");\n\n } catch (e) {\n console.log(e);\n\n if (!didCancel(e)) {\n // re-throw the non-cancellation error\n throw e;\n }\n }\n } else if (data?.then) {\n // resolve the data promise (either from the @loadData call or @data)\n data = await data;\n }\n\n if (this.isDestroyed) {\n return;\n }\n\n data = data || [];\n\n this.previousResolvedData = data;\n\n return data;\n });\n\n @use latestData = keepLatest({\n value: () => this.resolvedData.value ?? [],\n when: () => this.resolvedData.isPending,\n });\n\n @tracked\n processedData;\n\n @tracked\n processedDataRows;\n\n processData(data) {\n // only columns that have filterable = true and a prop defined will be considered\n let columns = this.columns.filter((c) => c.filterable && isPresent(c.prop));\n\n let sortableColumns = this.columns.filter((c) => !isEmpty(c.sort));\n let sortings = sortableColumns.map((c) => ({\n prop: c.prop,\n direction: c.sort,\n }));\n\n let filterFunction = this.args.filterFunction;\n let filterUsing = this.args.filterUsing;\n let filter = this.filter;\n\n let processTheData = () => {\n // filter the data\n data = filterData(data, columns, filter, filterFunction, filterUsing);\n // Sort the data\n if (sortings.length > 0) {\n data = mergeSort(data, (itemA, itemB) => {\n return this.sortFunction(\n itemA,\n itemB,\n sortings,\n this.compareFunction,\n );\n });\n }\n\n this.processedDataRows = data;\n\n // Paginate the Data\n if (this.pagination) {\n let { pageStart, pageEnd } = this.paginationData;\n data = data.slice(pageStart - 1, pageEnd); // slice excludes last element so we don't need to subtract 1\n }\n\n this.processedData = data;\n };\n\n if (this.ignoreDataChanges) {\n // eslint-disable-next-line ember/no-runloop\n later(processTheData, 0);\n } else {\n processTheData();\n }\n }\n\n computeLoadDataParams() {\n let params = {};\n\n if (this.pagination) {\n params.paginationData = this.paginationData;\n }\n\n params.sortData = this.columns\n .filter((c) => !isEmpty(c.sort))\n .map((c) => ({ prop: c.prop, direction: c.sort }));\n params.filterData = {\n filter: this.filter,\n filterUsing: this.args.filterUsing,\n columnFilters: this.columns.map((c) => ({\n prop: c.prop,\n filter: c.filter,\n filterUsing: c.filterUsing,\n })),\n };\n\n return params;\n }\n\n paginateData(data) {\n if (this.pagination) {\n let { pageStart, pageEnd } = this.paginationData;\n data = data.slice(pageStart - 1, pageEnd); // slice excludes last element so we don't need to subtract 1\n }\n\n return data;\n }\n\n @action\n async reloadData() {\n return await this.resolvedData.retry();\n }\n\n @action\n onColumnSort(column, e) {\n if (column.isSorted) {\n // if this column is already sorted, calculate the next\n // sorting on the sequence.\n let direction = column.sort;\n let sortSequence = column.normalizedSortSequence;\n direction =\n sortSequence[\n (sortSequence.indexOf(direction) + 1) % sortSequence.length\n ];\n\n if (direction === 'unsorted') {\n direction = null;\n }\n column.sort = direction;\n\n if (!e.shiftKey) {\n // if not pressed shift, reset other column sorting\n let columns = this.columns.filter((c) => c !== column);\n columns.forEach((c) => (c.sort = null));\n }\n } else {\n // use first direction from sort sequence\n let direction = column.normalizedSortSequence[0];\n // create new sorting\n column.sort = direction;\n\n // normal click replaces all sortings with the new one\n // shift click adds a new sorting to the existing ones\n if (!e.shiftKey) {\n // if not pressed shift, reset other column sortings\n let columns = this.columns.filter((c) => c !== column);\n columns.forEach((c) => (c.sort = null));\n }\n }\n }\n\n @action\n previousPage() {\n if (this.pagination) {\n this.pageNumber = Math.max(this.pageNumber - 1, 1);\n }\n }\n\n @action\n nextPage() {\n if (this.pagination) {\n let { isLastPage } = this.paginationData;\n\n if (!isLastPage) {\n this.pageNumber = this.pageNumber + 1;\n }\n }\n }\n\n @action\n goToPage(pageNumber) {\n if (this.pagination) {\n let { totalPages } = this.paginationData;\n pageNumber = Math.max(pageNumber, 1);\n\n if (totalPages) {\n pageNumber = Math.min(pageNumber, totalPages);\n }\n\n this.pageNumber = pageNumber;\n }\n }\n\n @action\n changePageSize(pageSize) {\n if (this.pagination) {\n this.pageSize = parseInt(pageSize);\n }\n }\n\n registerColumn(column) {\n // eslint-disable-next-line ember/no-runloop\n schedule('afterRender', this, function () {\n if (typeof this.args.isColumnVisible === 'function') {\n column.visible = this.args.isColumnVisible(column);\n }\n\n if (!this.columns.includes(column)) {\n this.columns = [...this.columns, column];\n }\n });\n }\n\n unregisterColumn(column) {\n if (this.columns.includes(column)) {\n this.columns = this.columns.filter((c) => c !== column);\n }\n }\n}\n"],"names":["TASK_CANCELATION_NAME","didCancel","e","name","getConfigWithDefault","key","defaultValue","config","UpdateTotalRows","Helper","compute","positional","context","totalRows","notifyPropertyChange","UpdateFilter","filter","ProcessedData","loadData","data","latestData","processData","processedData","YetiTable","Component","setComponentTemplate","precompileTemplate","strictMode","scope","hash","Table","Header","THead","Body","TBody","TFoot","Pagination","publicApi","previousPage","nextPage","goToPage","changePageSize","reloadData","g","prototype","localCopy","i","dedupeTracked","sortMultiple","compareValues","mergedTheme","configTheme","theme","localTheme","args","merge","all","DEFAULT_THEME","n","cached","visibleColumns","columns","c","visible","getOwner","resolveRegistration","normalizedTotalRows","processedDataRows","length","undefined","previousResolvedData","normalizedRows","paginationData","pageSize","pageNumber","isLastPage","totalPages","Math","ceil","min","isFirstPage","pageStart","pageEnd","tracked","constructor","owner","arguments","console","log","registerApi","scheduleOnce","resolvedData","trackedFunction","params","computeLoadDataParams","then","isDestroyed","use","keepLatest","value","when","isPending","filterable","isPresent","prop","sortableColumns","isEmpty","sort","sortings","map","direction","filterFunction","filterUsing","processTheData","filterData","mergeSort","itemA","itemB","sortFunction","compareFunction","pagination","slice","ignoreDataChanges","later","sortData","columnFilters","paginateData","retry","action","onColumnSort","column","isSorted","sortSequence","normalizedSortSequence","indexOf","shiftKey","forEach","max","parseInt","registerColumn","schedule","isColumnVisible","includes","unregisterColumn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,MAAMA,qBAAA,GAAwB,iBAAA;AAC9B,MAAMC,SAAA,GAAY,UAAUC,CAAC,EAAA;AAC3B,EAAA,OAAOA,CAAA,IAAKA,CAAA,CAAEC,IAAI,KAAKH,qBAAA;AACzB,CAAA;AAEA,MAAMI,oBAAA,GAAuB,UAAUC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ClC,IAAI,CAACrE,OAAO,GAAG,CAAI,GAAA,IAAI,CAACA,OAAO,EAAEqE,MAAA,CAAO;AAC1C,MAAA;AACF,IAAA,CAAA,CAAA;AACF,EAAA;EAEAa,gBAAAA,CAAiBb,MAAM,EAAE;IACvB,IAAI,IAAI,CAACrE,OAAO,CAACiF,QAAQ,CAACZ,MAAA,CAAA,EAAS;AACjC,MAAA,IAAI,CAACrE,OAAO,GAAG,IAAI,CAACA,OAAO,CAAC7C,MAAM,CAAE8C,CAAA,IAAMA,CAAA,KAAMoE,MAAA,CAAA;AAClD,IAAA;AACF,EAAA;AACF;;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// BEGIN-SNIPPET default-theme.js
|
|
2
|
+
var DEFAULT_THEME = {
|
|
3
|
+
// applied to the <table> element
|
|
4
|
+
table: 'yeti-table',
|
|
5
|
+
// applied to any <tr>, wether it is from the header, body or footer
|
|
6
|
+
row: '',
|
|
7
|
+
// applied to the <thead> element
|
|
8
|
+
thead: '',
|
|
9
|
+
// applied to <tr> rows inside the <thead> element
|
|
10
|
+
theadRow: '',
|
|
11
|
+
// applied to <th> cells inside the <thead> element
|
|
12
|
+
theadCell: '',
|
|
13
|
+
// applied to the <tbody> element
|
|
14
|
+
tbody: '',
|
|
15
|
+
// applied to <tr> rows inside the <tbody> element
|
|
16
|
+
tbodyRow: '',
|
|
17
|
+
// applied to <td> cells inside the <thead> element
|
|
18
|
+
tbodyCell: '',
|
|
19
|
+
// applied to the <tfoot> element
|
|
20
|
+
tfoot: '',
|
|
21
|
+
// applied to <tr> rows inside the <tfoot> element
|
|
22
|
+
tfootRow: '',
|
|
23
|
+
// applied to <td> cells inside the <tfoot> element
|
|
24
|
+
tfootCell: '',
|
|
25
|
+
sorting: {
|
|
26
|
+
// applied to <th> header cells when column is sortable
|
|
27
|
+
columnSortable: 'yeti-table-sortable',
|
|
28
|
+
// applied to <th> header cells when column is currently sorted
|
|
29
|
+
columnSorted: 'yeti-table-sorted',
|
|
30
|
+
// applied to <th> header cells when column is currently sorted ascending
|
|
31
|
+
columnSortedAsc: 'yeti-table-sorted-asc',
|
|
32
|
+
// applied to <th> header cells when column is currently sorted descending
|
|
33
|
+
columnSortedDesc: 'yeti-table-sorted-desc'
|
|
34
|
+
},
|
|
35
|
+
pagination: {
|
|
36
|
+
// applied to the pagination controls container
|
|
37
|
+
controls: 'yeti-table-pagination-controls',
|
|
38
|
+
// applied to the pagination information element
|
|
39
|
+
info: 'yeti-table-pagination-controls-page-info',
|
|
40
|
+
// applied to the pageSize select element
|
|
41
|
+
pageSize: 'yeti-table-pagination-controls-page-size',
|
|
42
|
+
// applied to the next button
|
|
43
|
+
next: 'yeti-table-pagination-controls-next',
|
|
44
|
+
// applied to the previous button
|
|
45
|
+
previous: 'yeti-table-pagination-controls-previous'
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
// END-SNIPPET
|
|
49
|
+
|
|
50
|
+
export { DEFAULT_THEME as default };
|
|
51
|
+
//# sourceMappingURL=default-theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-theme.js","sources":["../../src/themes/default-theme.js"],"sourcesContent":["// BEGIN-SNIPPET default-theme.js\nexport default {\n // applied to the <table> element\n table: 'yeti-table',\n // applied to any <tr>, wether it is from the header, body or footer\n row: '',\n\n // applied to the <thead> element\n thead: '',\n // applied to <tr> rows inside the <thead> element\n theadRow: '',\n // applied to <th> cells inside the <thead> element\n theadCell: '',\n\n // applied to the <tbody> element\n tbody: '',\n // applied to <tr> rows inside the <tbody> element\n tbodyRow: '',\n // applied to <td> cells inside the <thead> element\n tbodyCell: '',\n\n // applied to the <tfoot> element\n tfoot: '',\n // applied to <tr> rows inside the <tfoot> element\n tfootRow: '',\n // applied to <td> cells inside the <tfoot> element\n tfootCell: '',\n\n sorting: {\n // applied to <th> header cells when column is sortable\n columnSortable: 'yeti-table-sortable',\n // applied to <th> header cells when column is currently sorted\n columnSorted: 'yeti-table-sorted',\n // applied to <th> header cells when column is currently sorted ascending\n columnSortedAsc: 'yeti-table-sorted-asc',\n // applied to <th> header cells when column is currently sorted descending\n columnSortedDesc: 'yeti-table-sorted-desc',\n },\n\n pagination: {\n // applied to the pagination controls container\n controls: 'yeti-table-pagination-controls',\n // applied to the pagination information element\n info: 'yeti-table-pagination-controls-page-info',\n // applied to the pageSize select element\n pageSize: 'yeti-table-pagination-controls-page-size',\n // applied to the next button\n next: 'yeti-table-pagination-controls-next',\n // applied to the previous button\n previous: 'yeti-table-pagination-controls-previous',\n },\n};\n// END-SNIPPET\n"],"names":["table","row","thead","theadRow","theadCell","tbody","tbodyRow","tbodyCell","tfoot","tfootRow","tfootCell","sorting","columnSortable","columnSorted","columnSortedAsc","columnSortedDesc","pagination","controls","info","pageSize","next","previous"],"mappings":"AAAA;AACA,oBAAe;AACb;AACAA,EAAAA,KAAK,EAAE,YAAY;AACnB;AACAC,EAAAA,GAAG,EAAE,EAAE;AAEP;AACAC,EAAAA,KAAK,EAAE,EAAE;AACT;AACAC,EAAAA,QAAQ,EAAE,EAAE;AACZ;AACAC,EAAAA,SAAS,EAAE,EAAE;AAEb;AACAC,EAAAA,KAAK,EAAE,EAAE;AACT;AACAC,EAAAA,QAAQ,EAAE,EAAE;AACZ;AACAC,EAAAA,SAAS,EAAE,EAAE;AAEb;AACAC,EAAAA,KAAK,EAAE,EAAE;AACT;AACAC,EAAAA,QAAQ,EAAE,EAAE;AACZ;AACAC,EAAAA,SAAS,EAAE,EAAE;AAEbC,EAAAA,OAAO,EAAE;AACP;AACAC,IAAAA,cAAc,EAAE,qBAAqB;AACrC;AACAC,IAAAA,YAAY,EAAE,mBAAmB;AACjC;AACAC,IAAAA,eAAe,EAAE,uBAAuB;AACxC;AACAC,IAAAA,gBAAgB,EAAE;GACnB;AAEDC,EAAAA,UAAU,EAAE;AACV;AACAC,IAAAA,QAAQ,EAAE,gCAAgC;AAC1C;AACAC,IAAAA,IAAI,EAAE,0CAA0C;AAChD;AACAC,IAAAA,QAAQ,EAAE,0CAA0C;AACpD;AACAC,IAAAA,IAAI,EAAE,qCAAqC;AAC3C;AACAC,IAAAA,QAAQ,EAAE;AACZ;AACF,CAAC;AACD;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isBlank } from '@ember/utils';
|
|
2
|
+
|
|
3
|
+
const ESCAPE_REGEX = new RegExp('(\\' + ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-'].join('|\\') + ')', 'g');
|
|
4
|
+
function escapeRegex(val) {
|
|
5
|
+
return val.replace(ESCAPE_REGEX, '\\$1');
|
|
6
|
+
}
|
|
7
|
+
function createRegex(search, regex = false, smart = true, caseInsensitive = true) {
|
|
8
|
+
if (isBlank(search)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
search = regex ? search : escapeRegex(search);
|
|
12
|
+
if (smart) {
|
|
13
|
+
/* For smart filtering we want to allow the search to work regardless of
|
|
14
|
+
* word order. We also want double quoted text to be preserved, so word
|
|
15
|
+
* order is important - a la google. So this is what we want to
|
|
16
|
+
* generate:
|
|
17
|
+
*
|
|
18
|
+
* ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
|
|
19
|
+
*/
|
|
20
|
+
let words = search.match(/"[^"]+"|[^ ]+/g) || [''];
|
|
21
|
+
let a = words.map(word => {
|
|
22
|
+
if (word.charAt(0) === '"') {
|
|
23
|
+
let m = word.match(/^"(.*)"$/);
|
|
24
|
+
word = m ? m[1] : word;
|
|
25
|
+
}
|
|
26
|
+
return word.replace('"', '');
|
|
27
|
+
});
|
|
28
|
+
search = `^(?=.*?${a.join(')(?=.*?')}).*$`;
|
|
29
|
+
}
|
|
30
|
+
return new RegExp(search, caseInsensitive ? 'i' : '');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { createRegex as default };
|
|
34
|
+
//# sourceMappingURL=create-regex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-regex.js","sources":["../../src/utils/create-regex.js"],"sourcesContent":["import { isBlank } from '@ember/utils';\n\nconst ESCAPE_REGEX = new RegExp(\n '(\\\\' +\n [\n '/',\n '.',\n '*',\n '+',\n '?',\n '|',\n '(',\n ')',\n '[',\n ']',\n '{',\n '}',\n '\\\\',\n '$',\n '^',\n '-',\n ].join('|\\\\') +\n ')',\n 'g',\n);\n\nfunction escapeRegex(val) {\n return val.replace(ESCAPE_REGEX, '\\\\$1');\n}\n\nexport default function createRegex(\n search,\n regex = false,\n smart = true,\n caseInsensitive = true,\n) {\n if (isBlank(search)) {\n return;\n }\n\n search = regex ? search : escapeRegex(search);\n\n if (smart) {\n /* For smart filtering we want to allow the search to work regardless of\n * word order. We also want double quoted text to be preserved, so word\n * order is important - a la google. So this is what we want to\n * generate:\n *\n * ^(?=.*?\\bone\\b)(?=.*?\\btwo three\\b)(?=.*?\\bfour\\b).*$\n */\n let words = search.match(/\"[^\"]+\"|[^ ]+/g) || [''];\n let a = words.map((word) => {\n if (word.charAt(0) === '\"') {\n let m = word.match(/^\"(.*)\"$/);\n word = m ? m[1] : word;\n }\n\n return word.replace('\"', '');\n });\n\n search = `^(?=.*?${a.join(')(?=.*?')}).*$`;\n }\n\n return new RegExp(search, caseInsensitive ? 'i' : '');\n}\n"],"names":["ESCAPE_REGEX","RegExp","join","escapeRegex","val","replace","createRegex","search","regex","smart","caseInsensitive","isBlank","words","match","a","map","word","charAt","m"],"mappings":";;AAEA,MAAMA,YAAY,GAAG,IAAIC,MAAM,CAC7B,KAAK,GACH,CACE,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,IAAI,EACJ,GAAG,EACH,GAAG,EACH,GAAG,CACJ,CAACC,IAAI,CAAC,KAAK,CAAC,GACb,GAAG,EACL,GACF,CAAC;AAED,SAASC,WAAWA,CAACC,GAAG,EAAE;AACxB,EAAA,OAAOA,GAAG,CAACC,OAAO,CAACL,YAAY,EAAE,MAAM,CAAC;AAC1C;AAEe,SAASM,WAAWA,CACjCC,MAAM,EACNC,KAAK,GAAG,KAAK,EACbC,KAAK,GAAG,IAAI,EACZC,eAAe,GAAG,IAAI,EACtB;AACA,EAAA,IAAIC,OAAO,CAACJ,MAAM,CAAC,EAAE;AACnB,IAAA;AACF,EAAA;EAEAA,MAAM,GAAGC,KAAK,GAAGD,MAAM,GAAGJ,WAAW,CAACI,MAAM,CAAC;AAE7C,EAAA,IAAIE,KAAK,EAAE;AACT;AACJ;AACA;AACA;AACA;AACA;AACA;IACI,IAAIG,KAAK,GAAGL,MAAM,CAACM,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;AAClD,IAAA,IAAIC,CAAC,GAAGF,KAAK,CAACG,GAAG,CAAEC,IAAI,IAAK;MAC1B,IAAIA,IAAI,CAACC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAC1B,QAAA,IAAIC,CAAC,GAAGF,IAAI,CAACH,KAAK,CAAC,UAAU,CAAC;QAC9BG,IAAI,GAAGE,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGF,IAAI;AACxB,MAAA;AAEA,MAAA,OAAOA,IAAI,CAACX,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;AAC9B,IAAA,CAAC,CAAC;IAEFE,MAAM,GAAG,UAAUO,CAAC,CAACZ,IAAI,CAAC,SAAS,CAAC,CAAA,IAAA,CAAM;AAC5C,EAAA;EAEA,OAAO,IAAID,MAAM,CAACM,MAAM,EAAEG,eAAe,GAAG,GAAG,GAAG,EAAE,CAAC;AACvD;;;;"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { isEmpty } from '@ember/utils';
|
|
2
|
+
import { get } from '@ember/object';
|
|
3
|
+
import createRegex from './create-regex.js';
|
|
4
|
+
|
|
5
|
+
function createColumnFilters(columns) {
|
|
6
|
+
let searcheableColumns = columns.filter(c => {
|
|
7
|
+
return !isEmpty(c.filter) || !isEmpty(c.filterFunction);
|
|
8
|
+
});
|
|
9
|
+
return searcheableColumns.map(c => {
|
|
10
|
+
let regex = createRegex(c.filter);
|
|
11
|
+
return row => {
|
|
12
|
+
let value = get(row, c.prop);
|
|
13
|
+
let passesRegex = true;
|
|
14
|
+
if (!isEmpty(c.filter)) {
|
|
15
|
+
passesRegex = regex.test(value);
|
|
16
|
+
}
|
|
17
|
+
let passesCustom = true;
|
|
18
|
+
if (!isEmpty(c.filterFunction)) {
|
|
19
|
+
passesCustom = c.filterFunction(value, c.filterUsing);
|
|
20
|
+
}
|
|
21
|
+
return passesRegex && passesCustom;
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function filterData(data, columns, globalFilter, filterFunction, filterUsing) {
|
|
26
|
+
if (isEmpty(data)) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
if (isEmpty(columns)) {
|
|
30
|
+
// bail out if there are no columns to filter
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
let globalRegex = createRegex(globalFilter, false, true, true);
|
|
34
|
+
let columnFilters = createColumnFilters(columns);
|
|
35
|
+
return data.filter(row => {
|
|
36
|
+
let passesGeneral = true;
|
|
37
|
+
if (!isEmpty(globalRegex)) {
|
|
38
|
+
passesGeneral = columns.some(c => {
|
|
39
|
+
return globalRegex.test(get(row, c.prop));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
let passesColumn = true;
|
|
43
|
+
if (!isEmpty(columnFilters)) {
|
|
44
|
+
passesColumn = columnFilters.every(fn => fn(row));
|
|
45
|
+
}
|
|
46
|
+
let passesCustom = true;
|
|
47
|
+
if (!isEmpty(filterFunction)) {
|
|
48
|
+
passesColumn = filterFunction(row, filterUsing);
|
|
49
|
+
}
|
|
50
|
+
return passesGeneral && passesColumn && passesCustom;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { filterData as default };
|
|
55
|
+
//# sourceMappingURL=filtering-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filtering-utils.js","sources":["../../src/utils/filtering-utils.js"],"sourcesContent":["import { isEmpty } from '@ember/utils';\nimport { get } from '@ember/object';\n\nimport createRegex from './create-regex.js';\n\nfunction createColumnFilters(columns) {\n let searcheableColumns = columns.filter((c) => {\n return !isEmpty(c.filter) || !isEmpty(c.filterFunction);\n });\n\n return searcheableColumns.map((c) => {\n let regex = createRegex(c.filter);\n\n return (row) => {\n let value = get(row, c.prop);\n let passesRegex = true;\n\n if (!isEmpty(c.filter)) {\n passesRegex = regex.test(value);\n }\n\n let passesCustom = true;\n\n if (!isEmpty(c.filterFunction)) {\n passesCustom = c.filterFunction(value, c.filterUsing);\n }\n\n return passesRegex && passesCustom;\n };\n });\n}\n\nexport default function filterData(\n data,\n columns,\n globalFilter,\n filterFunction,\n filterUsing,\n) {\n if (isEmpty(data)) {\n return [];\n }\n\n if (isEmpty(columns)) {\n // bail out if there are no columns to filter\n return data;\n }\n\n let globalRegex = createRegex(globalFilter, false, true, true);\n\n let columnFilters = createColumnFilters(columns);\n\n return data.filter((row) => {\n let passesGeneral = true;\n\n if (!isEmpty(globalRegex)) {\n passesGeneral = columns.some((c) => {\n return globalRegex.test(get(row, c.prop));\n });\n }\n\n let passesColumn = true;\n\n if (!isEmpty(columnFilters)) {\n passesColumn = columnFilters.every((fn) => fn(row));\n }\n\n let passesCustom = true;\n if (!isEmpty(filterFunction)) {\n passesColumn = filterFunction(row, filterUsing);\n }\n\n return passesGeneral && passesColumn && passesCustom;\n });\n}\n"],"names":["createColumnFilters","columns","searcheableColumns","filter","c","isEmpty","filterFunction","map","regex","createRegex","row","value","get","prop","passesRegex","test","passesCustom","filterUsing","filterData","data","globalFilter","globalRegex","columnFilters","passesGeneral","some","passesColumn","every","fn"],"mappings":";;;;AAKA,SAASA,mBAAmBA,CAACC,OAA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,IAAI,CAAC;AAE9D,EAAA,IAAIE,aAAa,GAAGtB,mBAAmB,CAACC,OAAO,CAAC;AAEhD,EAAA,OAAOkB,IAAI,CAAChB,MAAM,CAAEO,GAAG,IAAK;IAC1B,IAAIa,aAAa,GAAG,IAAI;AAExB,IAAA,IAAI,CAAClB,OAAO,CAACgB,WAAW,CAAC,EAAE;AACzBE,MAAAA,aAAa,GAAGtB,OAAO,CAACuB,IAAI,CAAEpB,CAAC,IAAK;AAClC,QAAA,OAAOiB,WAAW,CAACN,IAAI,CAACH,GAAG,CAACF,GAAG,EAAEN,CAAC,CAACS,IAAI,CAAC,CAAC;AAC3C,MAAA,CAAC,CAAC;AACJ,IAAA;IAEA,IAAIY,YAAY,GAAG,IAAI;AAEvB,IAAA,IAAI,CAACpB,OAAO,CAACiB,aAAa,CAAC,EAAE;MAC3BG,YAAY,GAAGH,aAAa,CAACI,KAAK,CAAEC,EAAE,IAAKA,EAAE,CAACjB,GAAG,CAAC,CAAC;AACrD,IAAA;IAEA,IAAIM,YAAY,GAAG,IAAI;AACvB,IAAA,IAAI,CAACX,OAAO,CAACC,cAAc,CAAC,EAAE;AAC5BmB,MAAAA,YAAY,GAAGnB,cAAc,CAACI,GAAG,EAAEO,WAAW,CAAC;AACjD,IAAA;AAEA,IAAA,OAAOM,aAAa,IAAIE,YAAY,IAAIT,YAAY;AACtD,EAAA,CAAC,CAAC;AACJ;;;;"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { get } from '@ember/object';
|
|
2
|
+
import { compare, isNone } from '@ember/utils';
|
|
3
|
+
|
|
4
|
+
function merge(left, right, comparator) {
|
|
5
|
+
let mergedArray = [];
|
|
6
|
+
let leftIndex = 0;
|
|
7
|
+
let rightIndex = 0;
|
|
8
|
+
while (leftIndex < left.length && rightIndex < right.length) {
|
|
9
|
+
let comparison = comparator(left[leftIndex], right[rightIndex]);
|
|
10
|
+
if (comparison <= 0) {
|
|
11
|
+
mergedArray.push(left[leftIndex]);
|
|
12
|
+
leftIndex++;
|
|
13
|
+
} else {
|
|
14
|
+
mergedArray.push(right[rightIndex]);
|
|
15
|
+
rightIndex++;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (leftIndex < left.length) {
|
|
19
|
+
mergedArray.splice(mergedArray.length, 0, ...left.slice(leftIndex));
|
|
20
|
+
}
|
|
21
|
+
if (rightIndex < right.length) {
|
|
22
|
+
mergedArray.splice(mergedArray.length, 0, ...right.slice(rightIndex));
|
|
23
|
+
}
|
|
24
|
+
return mergedArray;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An implementation of the standard merge sort algorithm.
|
|
29
|
+
*
|
|
30
|
+
* This is necessary because we need a stable sorting algorithm that accepts
|
|
31
|
+
* a general comparator. The built in sort function and Ember's sort functions
|
|
32
|
+
* are not stable, and `_.sortBy` doesn't take a general comparator. Ideally
|
|
33
|
+
* lodash would add a `_.sort` function whose API would mimic this function's.
|
|
34
|
+
*
|
|
35
|
+
* @function
|
|
36
|
+
* @param {Array} array The array to be sorted
|
|
37
|
+
* @param {Comparator} comparator The comparator function to compare elements with.
|
|
38
|
+
* @return {Array} A sorted array
|
|
39
|
+
*/
|
|
40
|
+
function mergeSort(array, comparator = compare) {
|
|
41
|
+
if (array.length <= 1) {
|
|
42
|
+
return array;
|
|
43
|
+
}
|
|
44
|
+
let middleIndex = Math.floor(array.length / 2);
|
|
45
|
+
let leftArray = mergeSort(array.slice(0, middleIndex), comparator);
|
|
46
|
+
let rightArray = mergeSort(array.slice(middleIndex), comparator);
|
|
47
|
+
return merge(leftArray, rightArray, comparator);
|
|
48
|
+
}
|
|
49
|
+
function sortMultiple(itemA, itemB, sorts, compare) {
|
|
50
|
+
let compareValue;
|
|
51
|
+
for (let {
|
|
52
|
+
prop,
|
|
53
|
+
direction
|
|
54
|
+
} of sorts) {
|
|
55
|
+
let valueA = get(itemA, prop);
|
|
56
|
+
let valueB = get(itemB, prop);
|
|
57
|
+
compareValue = direction === 'asc' ? compare(valueA, valueB) : -compare(valueA, valueB);
|
|
58
|
+
if (compareValue !== 0) {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return compareValue;
|
|
63
|
+
}
|
|
64
|
+
function isExactlyNaN(value) {
|
|
65
|
+
return typeof value === 'number' && isNaN(value);
|
|
66
|
+
}
|
|
67
|
+
function isEmpty(value) {
|
|
68
|
+
return isNone(value) || isExactlyNaN(value);
|
|
69
|
+
}
|
|
70
|
+
function orderEmptyValues(itemA, itemB) {
|
|
71
|
+
let aIsEmpty = isEmpty(itemA);
|
|
72
|
+
let bIsEmpty = isEmpty(itemB);
|
|
73
|
+
if (aIsEmpty && !bIsEmpty) {
|
|
74
|
+
return -1;
|
|
75
|
+
} else if (bIsEmpty && !aIsEmpty) {
|
|
76
|
+
return 1;
|
|
77
|
+
} else if (isNone(itemA) && isExactlyNaN(itemB)) {
|
|
78
|
+
return -1;
|
|
79
|
+
} else if (isExactlyNaN(itemA) && isNone(itemB)) {
|
|
80
|
+
return 1;
|
|
81
|
+
} else {
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function compareValues(itemA, itemB) {
|
|
86
|
+
if (isEmpty(itemA) || isEmpty(itemB)) {
|
|
87
|
+
return orderEmptyValues(itemA, itemB);
|
|
88
|
+
}
|
|
89
|
+
return compare(itemA, itemB);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { compareValues, compareValues as default, mergeSort, sortMultiple };
|
|
93
|
+
//# sourceMappingURL=sorting-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorting-utils.js","sources":["../../src/utils/sorting-utils.js"],"sourcesContent":["import { get } from '@ember/object';\nimport { compare, isNone } from '@ember/utils';\n\nfunction merge(left, right, comparator) {\n let mergedArray = [];\n let leftIndex = 0;\n let rightIndex = 0;\n\n while (leftIndex < left.length && rightIndex < right.length) {\n let comparison = comparator(left[leftIndex], right[rightIndex]);\n\n if (comparison <= 0) {\n mergedArray.push(left[leftIndex]);\n leftIndex++;\n } else {\n mergedArray.push(right[rightIndex]);\n rightIndex++;\n }\n }\n\n if (leftIndex < left.length) {\n mergedArray.splice(mergedArray.length, 0, ...left.slice(leftIndex));\n }\n\n if (rightIndex < right.length) {\n mergedArray.splice(mergedArray.length, 0, ...right.slice(rightIndex));\n }\n\n return mergedArray;\n}\n\n/**\n * An implementation of the standard merge sort algorithm.\n *\n * This is necessary because we need a stable sorting algorithm that accepts\n * a general comparator. The built in sort function and Ember's sort functions\n * are not stable, and `_.sortBy` doesn't take a general comparator. Ideally\n * lodash would add a `_.sort` function whose API would mimic this function's.\n *\n * @function\n * @param {Array} array The array to be sorted\n * @param {Comparator} comparator The comparator function to compare elements with.\n * @return {Array} A sorted array\n */\nexport function mergeSort(array, comparator = compare) {\n if (array.length <= 1) {\n return array;\n }\n\n let middleIndex = Math.floor(array.length / 2);\n let leftArray = mergeSort(array.slice(0, middleIndex), comparator);\n let rightArray = mergeSort(array.slice(middleIndex), comparator);\n\n return merge(leftArray, rightArray, comparator);\n}\n\nexport function sortMultiple(itemA, itemB, sorts, compare) {\n let compareValue;\n\n for (let { prop, direction } of sorts) {\n let valueA = get(itemA, prop);\n let valueB = get(itemB, prop);\n\n compareValue =\n direction === 'asc' ? compare(valueA, valueB) : -compare(valueA, valueB);\n\n if (compareValue !== 0) {\n break;\n }\n }\n\n return compareValue;\n}\n\nfunction isExactlyNaN(value) {\n return typeof value === 'number' && isNaN(value);\n}\n\nfunction isEmpty(value) {\n return isNone(value) || isExactlyNaN(value);\n}\n\nfunction orderEmptyValues(itemA, itemB) {\n let aIsEmpty = isEmpty(itemA);\n let bIsEmpty = isEmpty(itemB);\n\n if (aIsEmpty && !bIsEmpty) {\n return -1;\n } else if (bIsEmpty && !aIsEmpty) {\n return 1;\n } else if (isNone(itemA) && isExactlyNaN(itemB)) {\n return -1;\n } else if (isExactlyNaN(itemA) && isNone(itemB)) {\n return 1;\n } else {\n return 0;\n }\n}\n\nexport function compareValues(itemA, itemB) {\n if (isEmpty(itemA) || isEmpty(itemB)) {\n return orderEmptyValues(itemA, itemB);\n }\n\n return compare(itemA, itemB);\n}\n\nexport default compareValues;\n"],"names":["merge","left","right","comparator","mergedArray","leftIndex","rightIndex","length","comparison","push","splice","slice","mergeSort","array","compare","middleIndex","Math","floor","leftArray","rightArray","sortMultiple","itemA","itemB","sorts","compareValue","prop","direction","valueA","get","valueB","isExactlyNaN","value","isNaN","isEmpty","isNone","orderEmptyValues","aIsEmpty","bIsEmpty","compareValues"],"mappings":";;;AAGA,SAASA,KAAKA,CAACC,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAAE;EACtC,IAAIC,WAAW,GAAG,EAAE;EACpB,IAAIC,SAAS,GAAG,CAAC;EACjB,IAAIC,UAAU,GAAG,CAAC;EAElB,OAAOD,SAAS,GAAGJ,IAAI,CAACM,MAAM,IAAID,UAAU,GAAGJ,KAAK,CAACK,MAAM,EAAE;AAC3D,IAAA,IAAIC,UAAU,GAAGL,UAAU,CAACF,IAAI,CAACI,SAAS,CAAC,EAAEH,KAAK,CAACI,UAAU,CAAC,CAAC;IAE/D,IAAIE,UAAU,IAAI,CAAC,EAAE;AACnBJ,MAAAA,WAAW,CAACK,IAAI,CAACR,IAAI,CAACI,SAAS,CAAC,CAAC;AACjCA,MAAAA,SAAS,EAAE;AACb,IAAA,CAAC,MAAM;AACLD,MAAAA,WAAW,CAACK,IAAI,CAACP,KAAK,CAACI,UAAU,CAAC,CAAC;AACnCA,MAAAA,UAAU,EAAE;AACd,IAAA;AACF,EAAA;AAEA,EAAA,IAAID,SAAS,GAAGJ,IAAI,CAACM,MAAM,EAAE;AAC3BH,IAAAA,WAAW,CAACM,MAAM,CAACN,WAAW,CAACG,MAAM,EAAE,CAAC,EAAE,GAAGN,IAAI,CAACU,KAAK,CAACN,SAAS,CAAC,CAAC;AACrE,EAAA;AAEA,EAAA,IAAIC,UAAU,GAAGJ,KA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C9B;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@triptyk/ember-yeti-table",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Lightweight and flexible tables addon.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ember-addon",
|
|
7
|
+
"table",
|
|
8
|
+
"tables",
|
|
9
|
+
"datagrid",
|
|
10
|
+
"yeti"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://miguelcobain.github.io/ember-yeti-table",
|
|
13
|
+
"repository": "https://github.com/miguelcobain/ember-yeti-table",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Miguel Andrade <jmandrade0@gmail.com>",
|
|
16
|
+
"imports": {
|
|
17
|
+
"#src/*": "./src/*"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./addon-main.cjs": "./addon-main.cjs",
|
|
24
|
+
"./*": {
|
|
25
|
+
"default": "./dist/*.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"addon-main.cjs",
|
|
30
|
+
"declarations",
|
|
31
|
+
"dist",
|
|
32
|
+
"src"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@embroider/addon-shim": "^1.10.2",
|
|
36
|
+
"decorator-transforms": "^2.2.2",
|
|
37
|
+
"deepmerge": "^4.3.1",
|
|
38
|
+
"ember-modifier": "^4.2.2",
|
|
39
|
+
"ember-resources": "^7.0.7",
|
|
40
|
+
"reactiveweb": "^1.9.1",
|
|
41
|
+
"@glimmer/component": "^2.0.0",
|
|
42
|
+
"tracked-toolbox": "^2.2.0"
|
|
43
|
+
},
|
|
44
|
+
"volta": {
|
|
45
|
+
"extends": "../package.json"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@babel/core": "^7.25.2",
|
|
49
|
+
"@babel/eslint-parser": "^7.25.1",
|
|
50
|
+
"@babel/runtime": "^7.25.6",
|
|
51
|
+
"@ember/app-tsconfig": "^1.0.0",
|
|
52
|
+
"@ember/library-tsconfig": "^1.0.0",
|
|
53
|
+
"@ember/test-helpers": "^5.2.1",
|
|
54
|
+
"@ember/test-waiters": "^4.1.1",
|
|
55
|
+
"@embroider/addon-dev": "^8.1.0",
|
|
56
|
+
"@embroider/compat": "^4.1.0",
|
|
57
|
+
"@embroider/core": "^4.1.0",
|
|
58
|
+
"@embroider/macros": "^1.18.0",
|
|
59
|
+
"@embroider/vite": "^1.1.5",
|
|
60
|
+
"@eslint/js": "^9.17.0",
|
|
61
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
62
|
+
"babel-plugin-ember-template-compilation": "~4.0.0",
|
|
63
|
+
"concurrently": "^9.0.1",
|
|
64
|
+
"ember-page-title": "^9.0.3",
|
|
65
|
+
"ember-qunit": "^9.0.2",
|
|
66
|
+
"ember-source": "^6.7.0",
|
|
67
|
+
"ember-strict-application-resolver": "^0.1.0",
|
|
68
|
+
"ember-template-lint": "^7.9.0",
|
|
69
|
+
"eslint": "^9.17.0",
|
|
70
|
+
"eslint-config-prettier": "^10.1.5",
|
|
71
|
+
"eslint-plugin-ember": "^12.3.3",
|
|
72
|
+
"eslint-plugin-import": "^2.31.0",
|
|
73
|
+
"eslint-plugin-n": "^17.15.1",
|
|
74
|
+
"globals": "^16.1.0",
|
|
75
|
+
"prettier": "^3.4.2",
|
|
76
|
+
"prettier-plugin-ember-template-tag": "^2.0.4",
|
|
77
|
+
"qunit": "^2.24.1",
|
|
78
|
+
"qunit-dom": "^3.4.0",
|
|
79
|
+
"rollup": "~4.56.0",
|
|
80
|
+
"testem": "^3.15.1",
|
|
81
|
+
"vite": "^7.1.9"
|
|
82
|
+
},
|
|
83
|
+
"ember": {
|
|
84
|
+
"edition": "octane"
|
|
85
|
+
},
|
|
86
|
+
"ember-addon": {
|
|
87
|
+
"version": 2,
|
|
88
|
+
"type": "addon",
|
|
89
|
+
"main": "addon-main.cjs",
|
|
90
|
+
"app-js": {
|
|
91
|
+
"./components/yeti-table.js": "./dist/_app_/components/yeti-table.js",
|
|
92
|
+
"./components/yeti-table/body.js": "./dist/_app_/components/yeti-table/body.js",
|
|
93
|
+
"./components/yeti-table/header.js": "./dist/_app_/components/yeti-table/header.js",
|
|
94
|
+
"./components/yeti-table/pagination.js": "./dist/_app_/components/yeti-table/pagination.js",
|
|
95
|
+
"./components/yeti-table/table.js": "./dist/_app_/components/yeti-table/table.js",
|
|
96
|
+
"./components/yeti-table/tbody.js": "./dist/_app_/components/yeti-table/tbody.js",
|
|
97
|
+
"./components/yeti-table/tbody/row.js": "./dist/_app_/components/yeti-table/tbody/row.js",
|
|
98
|
+
"./components/yeti-table/tbody/row/cell.js": "./dist/_app_/components/yeti-table/tbody/row/cell.js",
|
|
99
|
+
"./components/yeti-table/tfoot.js": "./dist/_app_/components/yeti-table/tfoot.js",
|
|
100
|
+
"./components/yeti-table/tfoot/row.js": "./dist/_app_/components/yeti-table/tfoot/row.js",
|
|
101
|
+
"./components/yeti-table/tfoot/row/cell.js": "./dist/_app_/components/yeti-table/tfoot/row/cell.js",
|
|
102
|
+
"./components/yeti-table/thead.js": "./dist/_app_/components/yeti-table/thead.js",
|
|
103
|
+
"./components/yeti-table/thead/row.js": "./dist/_app_/components/yeti-table/thead/row.js",
|
|
104
|
+
"./components/yeti-table/thead/row/cell.js": "./dist/_app_/components/yeti-table/thead/row/cell.js",
|
|
105
|
+
"./components/yeti-table/thead/row/column.js": "./dist/_app_/components/yeti-table/thead/row/column.js",
|
|
106
|
+
"./themes/default-theme.js": "./dist/_app_/themes/default-theme.js",
|
|
107
|
+
"./utils/create-regex.js": "./dist/_app_/utils/create-regex.js",
|
|
108
|
+
"./utils/filtering-utils.js": "./dist/_app_/utils/filtering-utils.js",
|
|
109
|
+
"./utils/sorting-utils.js": "./dist/_app_/utils/sorting-utils.js"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"scripts": {
|
|
113
|
+
"build": "rollup --config",
|
|
114
|
+
"format": "prettier . --cache --write",
|
|
115
|
+
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
|
|
116
|
+
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefixColors auto && pnpm run format",
|
|
117
|
+
"lint:format": "prettier . --cache --check",
|
|
118
|
+
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
|
119
|
+
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
|
|
120
|
+
"lint:js": "eslint . --cache",
|
|
121
|
+
"lint:js:fix": "eslint . --fix",
|
|
122
|
+
"start": "vite dev"
|
|
123
|
+
}
|
|
124
|
+
}
|
package/src/.gitkeep
ADDED
|
File without changes
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
|
|
3
|
+
import Component from '@glimmer/component';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
Renders a `<tbody>` element and yields the row component, row data and index.
|
|
7
|
+
```hbs
|
|
8
|
+
<table.body as |body person index|>
|
|
9
|
+
<body.row as |row|>
|
|
10
|
+
<row.cell>
|
|
11
|
+
{{person.firstName}} #{{index}}
|
|
12
|
+
</row.cell>
|
|
13
|
+
<row.cell>
|
|
14
|
+
{{person.lastName}}
|
|
15
|
+
</row.cell>
|
|
16
|
+
<row.cell>
|
|
17
|
+
{{person.points}}
|
|
18
|
+
</row.cell>
|
|
19
|
+
</body.row>
|
|
20
|
+
</table.body>
|
|
21
|
+
```
|
|
22
|
+
It can also be used as a blockless component to let yeti table automatically
|
|
23
|
+
unroll thee rows for you, based on the `@prop` arguments you passed in to the
|
|
24
|
+
column definition components.
|
|
25
|
+
```hbs
|
|
26
|
+
<table.body/>
|
|
27
|
+
```
|
|
28
|
+
Remember that this component's block will be rendered once per each item in the `@data` array.
|
|
29
|
+
|
|
30
|
+
@class Body
|
|
31
|
+
@yield {object} body
|
|
32
|
+
@yield {Component} body.row - the row component
|
|
33
|
+
@yield {Object} rowData - one item in the data array
|
|
34
|
+
@yield {number} index
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
// template imports
|
|
38
|
+
import { fn, get, hash } from '@ember/helper';
|
|
39
|
+
import TBodyRow from './tbody/row.gjs';
|
|
40
|
+
|
|
41
|
+
export default class Body extends Component {
|
|
42
|
+
<template>
|
|
43
|
+
<tbody class={{@theme.tbody}} ...attributes>
|
|
44
|
+
{{#if (has-block)}}
|
|
45
|
+
|
|
46
|
+
{{#each @data as |rowData index|}}
|
|
47
|
+
{{yield
|
|
48
|
+
(hash
|
|
49
|
+
row=(component
|
|
50
|
+
TBodyRow theme=@theme onClick=@onRowClick columns=@columns
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
rowData
|
|
54
|
+
index
|
|
55
|
+
}}
|
|
56
|
+
{{/each}}
|
|
57
|
+
|
|
58
|
+
{{else}}
|
|
59
|
+
|
|
60
|
+
{{#each @data as |rowData|}}
|
|
61
|
+
<TBodyRow
|
|
62
|
+
@theme={{@theme}}
|
|
63
|
+
@onClick={{if @onRowClick (fn this.handleRowClick rowData)}}
|
|
64
|
+
@columns={{@columns}}
|
|
65
|
+
as |row|
|
|
66
|
+
>
|
|
67
|
+
|
|
68
|
+
{{#each @columns as |column|}}
|
|
69
|
+
<row.cell @class={{column.columnClass}}>
|
|
70
|
+
{{#if column.prop}}
|
|
71
|
+
{{get rowData column.prop}}
|
|
72
|
+
{{else}}
|
|
73
|
+
{{rowData}}
|
|
74
|
+
{{/if}}
|
|
75
|
+
</row.cell>
|
|
76
|
+
{{/each}}
|
|
77
|
+
</TBodyRow>
|
|
78
|
+
{{/each}}
|
|
79
|
+
{{/if}}
|
|
80
|
+
</tbody>
|
|
81
|
+
</template>
|
|
82
|
+
/**
|
|
83
|
+
* Adds a click action to each row, called with the clicked row's data as an argument.
|
|
84
|
+
* Can be used with both the blockless and block invocations.
|
|
85
|
+
*
|
|
86
|
+
* @argument onRowClick
|
|
87
|
+
* @type Function
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
@action
|
|
91
|
+
handleRowClick(rowData) {
|
|
92
|
+
this.args.onRowClick?.(rowData);
|
|
93
|
+
}
|
|
94
|
+
}
|