Skip to content

Commit

Permalink
Dependency Updates and Test fixes (primefaces#5442)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Nov 28, 2023
1 parent c3b5e4d commit 50501d1
Show file tree
Hide file tree
Showing 8 changed files with 728 additions and 483 deletions.
17 changes: 10 additions & 7 deletions components/doc/datatable/lazyloaddoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ export function LazyLoadDoc(props) {
}

//imitate delay of a backend call
networkTimeout = setTimeout(() => {
CustomerService.getCustomers({ lazyEvent: JSON.stringify(lazyState) }).then((data) => {
setTotalRecords(data.totalRecords);
setCustomers(data.customers);
setLoading(false);
});
}, Math.random() * 1000 + 250);
networkTimeout = setTimeout(
() => {
CustomerService.getCustomers({ lazyEvent: JSON.stringify(lazyState) }).then((data) => {
setTotalRecords(data.totalRecords);
setCustomers(data.customers);
setLoading(false);
});
},
Math.random() * 1000 + 250
);
};

const onPage = (event) => {
Expand Down
23 changes: 13 additions & 10 deletions components/doc/datatable/virtualscroll/lazydoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@ export function LazyVirtualScrollDoc(props) {
}

//simulate remote connection with a timeout
loadLazyTimeout = setTimeout(() => {
let _virtualCars = [...virtualCars];
let { first, last } = event;
loadLazyTimeout = setTimeout(
() => {
let _virtualCars = [...virtualCars];
let { first, last } = event;

//load data of required page
const loadedCars = cars.slice(first, last);
//load data of required page
const loadedCars = cars.slice(first, last);

//populate page of virtual cars
Array.prototype.splice.apply(_virtualCars, [...[first, last - first], ...loadedCars]);
//populate page of virtual cars
Array.prototype.splice.apply(_virtualCars, [...[first, last - first], ...loadedCars]);

setVirtualCars(_virtualCars);
setLazyLoading(false);
}, Math.random() * 1000 + 250);
setVirtualCars(_virtualCars);
setLazyLoading(false);
},
Math.random() * 1000 + 250
);
};

const loadingTemplate = (options) => {
Expand Down
25 changes: 14 additions & 11 deletions components/doc/virtualscroller/lazydoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@ export function LazyDoc(props) {
}

//imitate delay of a backend call
loadLazyTimeout.current = setTimeout(() => {
const { first, last } = event;
const _lazyItems = [...lazyItems];

for (let i = first; i < last; i++) {
_lazyItems[i] = `Item #${i}`;
}

setLazyItems(_lazyItems);
setLazyLoading(false);
}, Math.random() * 1000 + 250);
loadLazyTimeout.current = setTimeout(
() => {
const { first, last } = event;
const _lazyItems = [...lazyItems];

for (let i = first; i < last; i++) {
_lazyItems[i] = `Item #${i}`;
}

setLazyItems(_lazyItems);
setLazyLoading(false);
},
Math.random() * 1000 + 250
);
};

const itemTemplate = (item, options) => {
Expand Down
6 changes: 3 additions & 3 deletions components/lib/chip/Chip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Chip', () => {
snapshot(<Chip image="http://google.com/my.png" imageAlt="jest" />, 'image and alt');
snapshot(<Chip icon="pi pi-check" />, 'icon');
snapshot(<Chip label="jest" />, 'label');
test('when removable is true it returns with remove icon', () => {
test('when removable is true the chip is removed when ENTER is pressed', () => {
// Arrange
const removeOn = jest.fn();
const { container } = render(<Chip removable onRemove={removeOn} />);
Expand All @@ -19,13 +19,13 @@ describe('Chip', () => {
const chipRemoveIcon = container.getElementsByClassName('p-chip-remove-icon')[0];

// Act
fireEvent.keyDown(chipRemoveIcon, { key: 'enter', keyCode: 13 });
fireEvent.keyDown(chipRemoveIcon, { key: 'Enter', code: 'Enter' });

// Assert
expect(container).toMatchSnapshot('after remove');
expect(removeOn).toHaveBeenCalledTimes(1);
});
test('when removable is true the chip is removed when ENTER is pressed', () => {
test('when removable is true it returns with remove icon', () => {
// Arrange
const removeOn = jest.fn();
const { container } = render(<Chip removable onRemove={removeOn} />);
Expand Down
53 changes: 5 additions & 48 deletions components/lib/chip/__snapshots__/Chip.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -75,50 +75,7 @@ exports[`Chip label 1`] = `
</div>
`;

exports[`Chip when removable is true it returns with remove icon: after remove 1`] = `
<div>
<div
class="p-chip p-component"
data-pc-name="chip"
data-pc-section="root"
>
<svg
aria-hidden="true"
class="p-icon p-chip-remove-icon"
data-pc-section="removeicon"
fill="none"
height="14"
role="button"
tabindex="0"
viewBox="0 0 14 14"
width="14"
xmlns="http://www.w3.org/2000/svg"
>
<g
clip-path="url(#pr_icon_clip_1)"
>
<path
clip-rule="evenodd"
d="M7 14C5.61553 14 4.26215 13.5895 3.11101 12.8203C1.95987 12.0511 1.06266 10.9579 0.532846 9.67879C0.00303296 8.3997 -0.13559 6.99224 0.134506 5.63437C0.404603 4.2765 1.07129 3.02922 2.05026 2.05026C3.02922 1.07129 4.2765 0.404603 5.63437 0.134506C6.99224 -0.13559 8.3997 0.00303296 9.67879 0.532846C10.9579 1.06266 12.0511 1.95987 12.8203 3.11101C13.5895 4.26215 14 5.61553 14 7C14 8.85652 13.2625 10.637 11.9497 11.9497C10.637 13.2625 8.85652 14 7 14ZM7 1.16667C5.84628 1.16667 4.71846 1.50879 3.75918 2.14976C2.79989 2.79074 2.05222 3.70178 1.61071 4.76768C1.16919 5.83358 1.05367 7.00647 1.27876 8.13803C1.50384 9.26958 2.05941 10.309 2.87521 11.1248C3.69102 11.9406 4.73042 12.4962 5.86198 12.7212C6.99353 12.9463 8.16642 12.8308 9.23232 12.3893C10.2982 11.9478 11.2093 11.2001 11.8502 10.2408C12.4912 9.28154 12.8333 8.15373 12.8333 7C12.8333 5.45291 12.2188 3.96918 11.1248 2.87521C10.0308 1.78125 8.5471 1.16667 7 1.16667ZM4.66662 9.91668C4.58998 9.91704 4.51404 9.90209 4.44325 9.87271C4.37246 9.84333 4.30826 9.8001 4.2544 9.74557C4.14516 9.6362 4.0838 9.48793 4.0838 9.33335C4.0838 9.17876 4.14516 9.0305 4.2544 8.92113L6.17553 7L4.25443 5.07891C4.15139 4.96832 4.09529 4.82207 4.09796 4.67094C4.10063 4.51982 4.16185 4.37563 4.26872 4.26876C4.3756 4.16188 4.51979 4.10066 4.67091 4.09799C4.82204 4.09532 4.96829 4.15142 5.07887 4.25446L6.99997 6.17556L8.92106 4.25446C9.03164 4.15142 9.1779 4.09532 9.32903 4.09799C9.48015 4.10066 9.62434 4.16188 9.73121 4.26876C9.83809 4.37563 9.89931 4.51982 9.90198 4.67094C9.90464 4.82207 9.84855 4.96832 9.74551 5.07891L7.82441 7L9.74554 8.92113C9.85478 9.0305 9.91614 9.17876 9.91614 9.33335C9.91614 9.48793 9.85478 9.6362 9.74554 9.74557C9.69168 9.8001 9.62748 9.84333 9.55669 9.87271C9.4859 9.90209 9.40996 9.91704 9.33332 9.91668C9.25668 9.91704 9.18073 9.90209 9.10995 9.87271C9.03916 9.84333 8.97495 9.8001 8.9211 9.74557L6.99997 7.82444L5.07884 9.74557C5.02499 9.8001 4.96078 9.84333 4.88999 9.87271C4.81921 9.90209 4.74326 9.91704 4.66662 9.91668Z"
fill="currentColor"
fill-rule="evenodd"
/>
</g>
<defs>
<clippath
id="pr_icon_clip_1"
>
<rect
fill="white"
height="14"
width="14"
/>
</clippath>
</defs>
</svg>
</div>
</div>
`;
exports[`Chip when removable is true it returns with remove icon: after remove 1`] = `<div />`;

exports[`Chip when removable is true it returns with remove icon: before remove 1`] = `
<div>
Expand All @@ -140,7 +97,7 @@ exports[`Chip when removable is true it returns with remove icon: before remove
xmlns="http://www.w3.org/2000/svg"
>
<g
clip-path="url(#pr_icon_clip_1)"
clip-path="url(#pr_icon_clip_2)"
>
<path
clip-rule="evenodd"
Expand All @@ -151,7 +108,7 @@ exports[`Chip when removable is true it returns with remove icon: before remove
</g>
<defs>
<clippath
id="pr_icon_clip_1"
id="pr_icon_clip_2"
>
<rect
fill="white"
Expand Down Expand Up @@ -187,7 +144,7 @@ exports[`Chip when removable is true the chip is removed when ENTER is pressed:
xmlns="http://www.w3.org/2000/svg"
>
<g
clip-path="url(#pr_icon_clip_2)"
clip-path="url(#pr_icon_clip_1)"
>
<path
clip-rule="evenodd"
Expand All @@ -198,7 +155,7 @@ exports[`Chip when removable is true the chip is removed when ENTER is pressed:
</g>
<defs>
<clippath
id="pr_icon_clip_2"
id="pr_icon_clip_1"
>
<rect
fill="white"
Expand Down
108 changes: 54 additions & 54 deletions components/lib/passthrough/tailwind/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,32 +341,32 @@ const Tailwind = {
exitActive: '!opacity-0 !scale-75 translate-x-0 -translate-y-full translate-z-0'
}
: props.position === 'bottom'
? {
enter: 'opacity-0 scale-75 translate-y-full',
enterActive: '!opacity-100 !scale-100 !translate-y-0 transition-all duration-200 ease-out',
exit: 'opacity-100 scale-100 transition-all duration-200 ease-out',
exitActive: '!opacity-0 !scale-75 translate-x-0 translate-y-full translate-z-0'
}
: props.position === 'left' || props.position === 'top-left' || props.position === 'bottom-left'
? {
enter: 'opacity-0 scale-75 -translate-x-full translate-y-0 translate-z-0',
enterActive: '!opacity-100 !scale-100 !translate-x-0 transition-all duration-200 ease-out',
exit: 'opacity-100 scale-100 transition-all duration-200 ease-out',
exitActive: '!opacity-0 !scale-75 -translate-x-full translate-y-0 translate-z-0'
}
: props.position === 'right' || props.position === 'top-right' || props.position === 'bottom-right'
? {
enter: 'opacity-0 scale-75 translate-x-full translate-y-0 translate-z-0',
enterActive: '!opacity-100 !scale-100 !translate-x-0 transition-all duration-200 ease-out',
exit: 'opacity-100 scale-100 transition-all duration-200 ease-out',
exitActive: '!opacity-0 !scale-75 translate-x-full translate-y-0 translate-z-0'
}
: {
enter: 'opacity-0 scale-75',
enterActive: '!opacity-100 !scale-100 transition-all duration-200 ease-out',
exit: 'opacity-100 scale-100 transition-all duration-200 ease-out',
exitActive: '!opacity-0 !scale-75'
}
? {
enter: 'opacity-0 scale-75 translate-y-full',
enterActive: '!opacity-100 !scale-100 !translate-y-0 transition-all duration-200 ease-out',
exit: 'opacity-100 scale-100 transition-all duration-200 ease-out',
exitActive: '!opacity-0 !scale-75 translate-x-0 translate-y-full translate-z-0'
}
: props.position === 'left' || props.position === 'top-left' || props.position === 'bottom-left'
? {
enter: 'opacity-0 scale-75 -translate-x-full translate-y-0 translate-z-0',
enterActive: '!opacity-100 !scale-100 !translate-x-0 transition-all duration-200 ease-out',
exit: 'opacity-100 scale-100 transition-all duration-200 ease-out',
exitActive: '!opacity-0 !scale-75 -translate-x-full translate-y-0 translate-z-0'
}
: props.position === 'right' || props.position === 'top-right' || props.position === 'bottom-right'
? {
enter: 'opacity-0 scale-75 translate-x-full translate-y-0 translate-z-0',
enterActive: '!opacity-100 !scale-100 !translate-x-0 transition-all duration-200 ease-out',
exit: 'opacity-100 scale-100 transition-all duration-200 ease-out',
exitActive: '!opacity-0 !scale-75 translate-x-full translate-y-0 translate-z-0'
}
: {
enter: 'opacity-0 scale-75',
enterActive: '!opacity-100 !scale-100 transition-all duration-200 ease-out',
exit: 'opacity-100 scale-100 transition-all duration-200 ease-out',
exitActive: '!opacity-0 !scale-75'
}
};
}
},
Expand Down Expand Up @@ -442,34 +442,34 @@ const Tailwind = {
exitActive: '!opacity-0'
}
: props.position === 'top'
? {
enter: 'translate-x-0 -translate-y-full translate-z-0',
enterActive: '!translate-y-0 transition-transform duration-300',
exit: 'translate-y-0 transition-transform duration-300',
exitActive: 'translate-x-0 !-translate-y-full translate-z-0'
}
: props.position === 'bottom'
? {
enter: 'translate-x-0 translate-y-full translate-z-0',
enterActive: '!translate-y-0 transition-transform duration-300',
exit: 'translate-y-0 transition-transform duration-300',
exitActive: 'translate-x-0 !translate-y-full translate-z-0'
}
: props.position === 'left'
? {
enter: '-translate-x-full translate-y-0 translate-z-0',
enterActive: '!translate-x-0 transition-transform duration-300',
exit: 'translate-x-0 transition-transform duration-300',
exitActive: '!-translate-x-full translate-y-0 translate-z-0'
}
: props.position === 'right'
? {
enter: 'translate-x-full translate-y-0 translate-z-0',
enterActive: '!translate-x-0 transition-transform duration-300',
exit: 'translate-x-0 transition-transform duration-300',
exitActive: '!translate-x-full translate-y-0 translate-z-0'
}
: undefined
? {
enter: 'translate-x-0 -translate-y-full translate-z-0',
enterActive: '!translate-y-0 transition-transform duration-300',
exit: 'translate-y-0 transition-transform duration-300',
exitActive: 'translate-x-0 !-translate-y-full translate-z-0'
}
: props.position === 'bottom'
? {
enter: 'translate-x-0 translate-y-full translate-z-0',
enterActive: '!translate-y-0 transition-transform duration-300',
exit: 'translate-y-0 transition-transform duration-300',
exitActive: 'translate-x-0 !translate-y-full translate-z-0'
}
: props.position === 'left'
? {
enter: '-translate-x-full translate-y-0 translate-z-0',
enterActive: '!translate-x-0 transition-transform duration-300',
exit: 'translate-x-0 transition-transform duration-300',
exitActive: '!-translate-x-full translate-y-0 translate-z-0'
}
: props.position === 'right'
? {
enter: 'translate-x-full translate-y-0 translate-z-0',
enterActive: '!translate-x-0 transition-transform duration-300',
exit: 'translate-x-0 transition-transform duration-300',
exitActive: '!translate-x-full translate-y-0 translate-z-0'
}
: undefined
};
}
},
Expand Down
Loading

0 comments on commit 50501d1

Please sign in to comment.