Skip to content

Commit

Permalink
feat: upgrade cosmoz-grouped-list
Browse files Browse the repository at this point in the history
  • Loading branch information
cristinecula committed Feb 28, 2024
1 parent 7558a48 commit 40b2748
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 60 deletions.
1 change: 0 additions & 1 deletion cosmoz-omnitable-column-list-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class OmnitableColumnListData extends translatable(mixin(Template, PolymerElemen
this._expanded = !this._expanded;
event.stopPropagation();
event.preventDefault();
this.dispatchEvent(new CustomEvent('expand', { bubbles: true }));
}
}

Expand Down
4 changes: 1 addition & 3 deletions cosmoz-omnitable-column-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
onText,
} from './cosmoz-omnitable-column-list-mixin';
import '@neovici/cosmoz-autocomplete';
import { notifyResize } from './lib/utils';
import { columnSymbol } from './lib/use-dom-columns';

/**
Expand All @@ -41,10 +40,9 @@ class OmnitableColumnList extends listColumnMixin(columnMixin(PolymerElement)) {
};
}

renderCell({ valuePath, textProperty }, { item, index }) {
renderCell({ valuePath, textProperty }, { item }) {
return html`<cosmoz-omnitable-column-list-data
.items=${getTexts(item, valuePath, textProperty)}
@expand=${(event) => notifyResize(event.target, index)}
></cosmoz-omnitable-column-list-data>`;
}

Expand Down
8 changes: 1 addition & 7 deletions cosmoz-omnitable-item-expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { component, useEffect } from '@pionjs/pion';
import { html, nothing } from 'lit-html';
import './cosmoz-omnitable-item-expand-line';
import { notifyResize } from './lib/utils';

const renderExpandList = ({
columns,
Expand All @@ -24,7 +23,7 @@ const renderExpandList = ({
>`
),
ExpandList = (host) => {
const { expanded, index, columns } = host;
const { columns } = host;

useEffect(() => {
if (columns?.length > 0) {
Expand All @@ -35,11 +34,6 @@ const renderExpandList = ({
return () => host.removeAttribute('hidden');
}, [columns?.length]);

useEffect(
() => expanded && requestAnimationFrame(() => notifyResize(host, index)),
[expanded]
);

return Array.isArray(columns) && columns.length > 0 && host.expanded
? renderExpandList(host)
: nothing;
Expand Down
5 changes: 0 additions & 5 deletions lib/use-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,6 @@ export const useList = ({
);
}, []);

useEffect(() => {
host.shadowRoot.querySelector('#groupedList').scrollTarget =
host.shadowRoot.querySelector('#scroller');
}, []);

const { groupOnColumn } = sortAndGroupOptions,
onItemChange = useCallback(
(column, item) => (value) => _onItemChange(host, column, item, value),
Expand Down
11 changes: 2 additions & 9 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
const notifyResize = (target, index) =>
target.dispatchEvent(
new CustomEvent('update-item-size', {
bubbles: true,
detail: { index },
})
),
indexSymbol = Symbol('index');
const indexSymbol = Symbol('index');

export { notifyResize, indexSymbol };
export { indexSymbol };
39 changes: 5 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@neovici/cosmoz-collapse": "^1.1.0",
"@neovici/cosmoz-datetime-input": "^4.0.0",
"@neovici/cosmoz-dropdown": "^4.0.0",
"@neovici/cosmoz-grouped-list": "^7.0.0",
"@neovici/cosmoz-grouped-list": "^8.0.0",
"@neovici/cosmoz-i18next": "^3.1.1",
"@neovici/cosmoz-input": "^4.0.0",
"@neovici/cosmoz-router": "^11.0.0",
Expand Down

0 comments on commit 40b2748

Please sign in to comment.