@descope/web-components-ui 1.0.386 → 1.0.387
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.cjs.js +68 -47
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +68 -47
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/8980.js +5 -2
- package/dist/umd/DescopeDev.js +1 -1
- package/dist/umd/descope-date-field-descope-calendar-index-js.js +1 -1
- package/dist/umd/descope-date-field-index-js.js +1 -1
- package/package.json +2 -2
- package/src/components/descope-date-field/DateFieldClass.js +66 -44
- package/src/components/descope-date-field/descope-calendar/CalendarClass.js +2 -2
- package/src/theme/components/dateField.js +0 -1
package/dist/index.esm.js
CHANGED
@@ -3961,8 +3961,8 @@ const {
|
|
3961
3961
|
weekday: { selector: () => '.weekday' },
|
3962
3962
|
navPrev: { selector: () => '.nav-prev' },
|
3963
3963
|
navNext: { selector: () => '.nav-next' },
|
3964
|
-
navPrevRTL: { selector: () => ':host(
|
3965
|
-
navNextRTL: { selector: () => ':host(
|
3964
|
+
navPrevRTL: { selector: () => ':host([st-host-direction="rtl"]) .nav-prev' },
|
3965
|
+
navNextRTL: { selector: () => ':host([st-host-direction="rtl"]) .nav-next' },
|
3966
3966
|
yearInput: { selector: () => '.year-input' },
|
3967
3967
|
monthInput: { selector: () => '.month-input' },
|
3968
3968
|
};
|
@@ -4503,7 +4503,7 @@ const componentName$R = getComponentName('date-field');
|
|
4503
4503
|
const BASE_SELECTOR = 'vaadin-popover';
|
4504
4504
|
const BaseInputClass$8 = createBaseInputClass({ componentName: componentName$R, baseSelector: BASE_SELECTOR });
|
4505
4505
|
|
4506
|
-
const dateFieldAttrs = ['format', 'opened', 'initial-value'];
|
4506
|
+
const dateFieldAttrs = ['format', 'opened', 'initial-value', 'readonly'];
|
4507
4507
|
const calendarAttrs = ['years-range', 'calendar-months', 'calendar-weekdays'];
|
4508
4508
|
const observedAttrs = [...dateFieldAttrs, ...calendarAttrs];
|
4509
4509
|
|
@@ -4545,19 +4545,16 @@ class RawDateFieldClass extends BaseInputClass$8 {
|
|
4545
4545
|
display: flex;
|
4546
4546
|
align-self: center;
|
4547
4547
|
z-index: 1;
|
4548
|
+
height: 100%;
|
4549
|
+
align-items: center;
|
4548
4550
|
}
|
4549
4551
|
|
4550
|
-
|
4551
|
-
position: absolute;
|
4552
|
-
height: 100%;
|
4553
|
-
width: 0;
|
4554
|
-
z-index: 1;
|
4552
|
+
:host([readonly="true"]) .toggle-calendar {
|
4555
4553
|
pointer-events: none;
|
4556
4554
|
}
|
4557
4555
|
</style>
|
4558
4556
|
<div>
|
4559
4557
|
<descope-text-field>
|
4560
|
-
<span slot="prefix" class="overlay-position-anchor"></span>
|
4561
4558
|
<span slot="suffix" class="toggle-calendar">
|
4562
4559
|
<descope-icon>${calendarIcon}</descope-icon>
|
4563
4560
|
</span>
|
@@ -4568,7 +4565,6 @@ class RawDateFieldClass extends BaseInputClass$8 {
|
|
4568
4565
|
|
4569
4566
|
this.inputElement = this.shadowRoot.querySelector('descope-text-field');
|
4570
4567
|
this.popoverToggleButton = this.inputElement.querySelector('.toggle-calendar');
|
4571
|
-
this.overlayPositionAnchor = this.inputElement.querySelector('.overlay-position-anchor');
|
4572
4568
|
|
4573
4569
|
this.oninvalid = () => {
|
4574
4570
|
this.inputElement.setAttribute('invalid', 'true');
|
@@ -4617,6 +4613,17 @@ class RawDateFieldClass extends BaseInputClass$8 {
|
|
4617
4613
|
return this.overlay?.querySelector('descope-calendar');
|
4618
4614
|
}
|
4619
4615
|
|
4616
|
+
get isRTL() {
|
4617
|
+
const computedStyleDirection = getComputedStyle(this.baseElement).getPropertyValue('direction');
|
4618
|
+
|
4619
|
+
if (computedStyleDirection) {
|
4620
|
+
return computedStyleDirection === 'rtl';
|
4621
|
+
}
|
4622
|
+
|
4623
|
+
// Fallback: If for some reason computed style was not calculated in time, fallback to check on attribute
|
4624
|
+
return this.getAttribute('st-host-direction') === 'rtl';
|
4625
|
+
}
|
4626
|
+
|
4620
4627
|
get value() {
|
4621
4628
|
return this.timestamp;
|
4622
4629
|
}
|
@@ -4697,10 +4704,8 @@ class RawDateFieldClass extends BaseInputClass$8 {
|
|
4697
4704
|
}
|
4698
4705
|
|
4699
4706
|
initPopover() {
|
4700
|
-
this.baseElement.target = this.overlayPositionAnchor;
|
4701
4707
|
this.baseElement.trigger = ['click'];
|
4702
4708
|
this.baseElement.withBackdrop = true;
|
4703
|
-
this.baseElement.noCloseOnOutsideClick = true;
|
4704
4709
|
this.baseElement.renderer = this.#popoverRenderer.bind(this);
|
4705
4710
|
|
4706
4711
|
// block popover events from focusing/blurring the text-field
|
@@ -4710,32 +4715,64 @@ class RawDateFieldClass extends BaseInputClass$8 {
|
|
4710
4715
|
});
|
4711
4716
|
}
|
4712
4717
|
|
4718
|
+
#popoverPosStylesheet;
|
4719
|
+
|
4713
4720
|
#popoverRenderer(root) {
|
4714
4721
|
// popoverRenderer should run only once, when the popover is first rendering.
|
4715
4722
|
if (!root.firstChild) {
|
4723
|
+
this.overlay.positionTarget = this.shadowRoot.querySelector('.toggle-calendar');
|
4724
|
+
|
4716
4725
|
root.appendChild(this.#getPopoverContent());
|
4726
|
+
|
4717
4727
|
// override vaadin's constructed stylesheet which hides the host element
|
4718
4728
|
overrideConstructedStylesheet(this.baseElement);
|
4719
4729
|
|
4720
|
-
|
4721
|
-
|
4730
|
+
this.backdrop.addEventListener('click', this.closePopover.bind(this));
|
4731
|
+
}
|
4722
4732
|
|
4723
|
-
|
4724
|
-
|
4725
|
-
// so vaadin computes the popover position according to the anchor position
|
4726
|
-
// (otherwise it will simply center the popover below the input).
|
4727
|
-
this.#adjustOverlayPosition();
|
4733
|
+
// Hide overlay before adjusting position to prevent flickering
|
4734
|
+
root.style.setProperty('visibility', 'hidden');
|
4728
4735
|
|
4729
|
-
|
4730
|
-
|
4736
|
+
// Wait until overlay is ready
|
4737
|
+
setTimeout(() => {
|
4738
|
+
this.#adjustPopoverPosition(root);
|
4731
4739
|
|
4732
|
-
|
4733
|
-
|
4734
|
-
|
4735
|
-
|
4740
|
+
// Show adjusted overlay
|
4741
|
+
root.style.setProperty('visibility', 'visible');
|
4742
|
+
this.updateCalendarView(root);
|
4743
|
+
}, 100);
|
4744
|
+
}
|
4745
|
+
|
4746
|
+
#adjustPopoverPosition() {
|
4747
|
+
const popover = this.shadowRoot.querySelector('vaadin-popover').shadowRoot;
|
4748
|
+
|
4749
|
+
// Remove previously added stylesheets
|
4750
|
+
this.#popoverPosStylesheet?.remove();
|
4751
|
+
|
4752
|
+
const windowRect = document.body.getBoundingClientRect();
|
4753
|
+
const inputRect = this.getBoundingClientRect();
|
4754
|
+
const calendarRect = this.calendar.getBoundingClientRect();
|
4755
|
+
|
4756
|
+
const side = this.isRTL ? 'right' : 'left';
|
4757
|
+
const offset = inputRect[side] - calendarRect[side];
|
4758
|
+
const availableLeft = calendarRect.left;
|
4759
|
+
const availableRight = windowRect.width - calendarRect.right;
|
4760
|
+
|
4761
|
+
let newOffset;
|
4762
|
+
if (offset > 0) {
|
4763
|
+
newOffset = Math.min(offset, availableRight);
|
4764
|
+
} else {
|
4765
|
+
newOffset = Math.min(Math.abs(offset), availableLeft) * -1;
|
4736
4766
|
}
|
4737
4767
|
|
4738
|
-
this.
|
4768
|
+
this.#popoverPosStylesheet = document.createElement('style');
|
4769
|
+
this.#popoverPosStylesheet.innerHTML = `
|
4770
|
+
vaadin-popover-overlay::part(overlay) {
|
4771
|
+
transform: translateX(${newOffset}px);
|
4772
|
+
}
|
4773
|
+
`;
|
4774
|
+
|
4775
|
+
popover.appendChild(this.#popoverPosStylesheet);
|
4739
4776
|
}
|
4740
4777
|
|
4741
4778
|
#getPopoverContent() {
|
@@ -4751,17 +4788,6 @@ class RawDateFieldClass extends BaseInputClass$8 {
|
|
4751
4788
|
return ele;
|
4752
4789
|
}
|
4753
4790
|
|
4754
|
-
#adjustOverlayPosition() {
|
4755
|
-
const { width: inputEleWidth } = this.inputElement.getClientRects()[0];
|
4756
|
-
const { width: calendarEleWidth } = this.calendar.getClientRects()[0];
|
4757
|
-
const pos = inputEleWidth - calendarEleWidth / 2;
|
4758
|
-
/* eslint-disable no-use-before-define */
|
4759
|
-
this.overlayPositionAnchor.style.setProperty(
|
4760
|
-
DateFieldClass.cssVarList.overlayAnchorPos,
|
4761
|
-
`${pos}px`
|
4762
|
-
);
|
4763
|
-
}
|
4764
|
-
|
4765
4791
|
// the default vaadin behavior is to attach the overlay to the body when opened
|
4766
4792
|
// we do not want that because it's difficult to style the overlay in this way
|
4767
4793
|
// so we override it to open inside the shadow DOM
|
@@ -4845,6 +4871,10 @@ class RawDateFieldClass extends BaseInputClass$8 {
|
|
4845
4871
|
}
|
4846
4872
|
|
4847
4873
|
onFocus() {
|
4874
|
+
if (this.isReadOnly) {
|
4875
|
+
return;
|
4876
|
+
}
|
4877
|
+
|
4848
4878
|
if (!this.inputElement.value) {
|
4849
4879
|
this.inputElement.value = this.format;
|
4850
4880
|
this.setInputSelectionRange();
|
@@ -5082,12 +5112,10 @@ class RawDateFieldClass extends BaseInputClass$8 {
|
|
5082
5112
|
}
|
5083
5113
|
}
|
5084
5114
|
|
5085
|
-
const { host: host$i, input, toggleButton,
|
5115
|
+
const { host: host$i, input, toggleButton, overlay, backdrop } = {
|
5086
5116
|
host: { selector: () => ':host' },
|
5087
5117
|
input: { selector: () => 'descope-text-field' },
|
5088
5118
|
toggleButton: { selector: () => '.toggle-calendar' },
|
5089
|
-
overlayAnchor: { selector: () => ':host .overlay-position-anchor' },
|
5090
|
-
overlayAnchorRTL: { selector: ':host([st-host-direction="rtl"]) .overlay-position-anchor' },
|
5091
5119
|
overlay: { selector: 'vaadin-popover-overlay::part(overlay)' },
|
5092
5120
|
backdrop: { selector: 'vaadin-popover-overlay::part(backdrop)' },
|
5093
5121
|
};
|
@@ -5100,14 +5128,9 @@ const DateFieldClass = compose(
|
|
5100
5128
|
hostWidth: { ...host$i, property: 'width' },
|
5101
5129
|
hostDirection: { ...host$i, property: 'direction' },
|
5102
5130
|
textAlign: { ...input, property: 'text-align' },
|
5103
|
-
overlayAnchorPos: [
|
5104
|
-
{ ...overlayAnchor, property: 'right' },
|
5105
|
-
{ ...overlayAnchorRTL, property: 'left' },
|
5106
|
-
],
|
5107
5131
|
overlayGap: {
|
5108
5132
|
property: () => DateFieldClass.cssVarList.overlayGap,
|
5109
5133
|
},
|
5110
|
-
|
5111
5134
|
overlayBackgroundColor: {
|
5112
5135
|
property: () => DateFieldClass.cssVarList.overlayBackgroundColor,
|
5113
5136
|
},
|
@@ -5139,7 +5162,6 @@ const DateFieldClass = compose(
|
|
5139
5162
|
outlineWidth: { ...overlay },
|
5140
5163
|
outlineColor: { ...overlay },
|
5141
5164
|
outlineStyle: { ...overlay },
|
5142
|
-
direction: { ...overlay },
|
5143
5165
|
},
|
5144
5166
|
}),
|
5145
5167
|
draggableMixin,
|
@@ -17141,7 +17163,6 @@ const dateField = {
|
|
17141
17163
|
[vars$4.overlay.outlineWidth]: '0',
|
17142
17164
|
[vars$4.overlay.outlineColor]: 'transparent',
|
17143
17165
|
[vars$4.overlay.outlineStyle]: 'none',
|
17144
|
-
[vars$4.overlay.direction]: refs.direction,
|
17145
17166
|
[vars$4.overlay.padding]: '0',
|
17146
17167
|
};
|
17147
17168
|
|