@cumulus-ui/components 0.3.1 → 0.4.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/dist/attribute-editor/index.d.ts +5 -0
- package/dist/attribute-editor/index.d.ts.map +1 -0
- package/dist/attribute-editor/internal.d.ts +23 -0
- package/dist/attribute-editor/internal.d.ts.map +1 -0
- package/dist/attribute-editor/styles.d.ts +5 -0
- package/dist/attribute-editor/styles.d.ts.map +1 -0
- package/dist/calendar/index.d.ts +5 -0
- package/dist/calendar/index.d.ts.map +1 -0
- package/dist/calendar/internal.d.ts +35 -0
- package/dist/calendar/internal.d.ts.map +1 -0
- package/dist/calendar/styles.d.ts +5 -0
- package/dist/calendar/styles.d.ts.map +1 -0
- package/dist/date-input/index.d.ts +5 -0
- package/dist/date-input/index.d.ts.map +1 -0
- package/dist/date-input/internal.d.ts +27 -0
- package/dist/date-input/internal.d.ts.map +1 -0
- package/dist/date-input/styles.d.ts +5 -0
- package/dist/date-input/styles.d.ts.map +1 -0
- package/dist/date-picker/index.d.ts +5 -0
- package/dist/date-picker/index.d.ts.map +1 -0
- package/dist/date-picker/internal.d.ts +48 -0
- package/dist/date-picker/internal.d.ts.map +1 -0
- package/dist/date-picker/styles.d.ts +5 -0
- package/dist/date-picker/styles.d.ts.map +1 -0
- package/dist/date-range-picker/index.d.ts +5 -0
- package/dist/date-range-picker/index.d.ts.map +1 -0
- package/dist/date-range-picker/internal.d.ts +70 -0
- package/dist/date-range-picker/internal.d.ts.map +1 -0
- package/dist/date-range-picker/styles.d.ts +5 -0
- package/dist/date-range-picker/styles.d.ts.map +1 -0
- package/dist/file-upload/index.d.ts +5 -0
- package/dist/file-upload/index.d.ts.map +1 -0
- package/dist/file-upload/internal.d.ts +35 -0
- package/dist/file-upload/internal.d.ts.map +1 -0
- package/dist/form/index.d.ts +5 -0
- package/dist/form/index.d.ts.map +1 -0
- package/dist/form/internal.d.ts +17 -0
- package/dist/form/internal.d.ts.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3422 -41
- package/dist/internal/styles/date-range-picker-relative-range.d.ts +2 -0
- package/dist/internal/styles/date-range-picker-relative-range.d.ts.map +1 -0
- package/dist/modal/index.d.ts +5 -0
- package/dist/modal/index.d.ts.map +1 -0
- package/dist/modal/internal.d.ts +24 -0
- package/dist/modal/internal.d.ts.map +1 -0
- package/dist/tag-editor/index.d.ts +5 -0
- package/dist/tag-editor/index.d.ts.map +1 -0
- package/dist/tag-editor/internal.d.ts +32 -0
- package/dist/tag-editor/internal.d.ts.map +1 -0
- package/dist/tag-editor/styles.d.ts +5 -0
- package/dist/tag-editor/styles.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -64,8 +64,8 @@ function FormAssociatedMixin(superClass) {
|
|
|
64
64
|
this._defaultValue = this.value;
|
|
65
65
|
}
|
|
66
66
|
// ── Public API (thin wrappers around ElementInternals) ────────────
|
|
67
|
-
setFormValue(value,
|
|
68
|
-
this._internals.setFormValue(value,
|
|
67
|
+
setFormValue(value, state21) {
|
|
68
|
+
this._internals.setFormValue(value, state21);
|
|
69
69
|
}
|
|
70
70
|
setValidity(flags, message, anchor) {
|
|
71
71
|
if (flags && message) {
|
|
@@ -99,9 +99,9 @@ function FormAssociatedMixin(superClass) {
|
|
|
99
99
|
* @param state - Previously saved value or `FormData` entry.
|
|
100
100
|
* @param _mode - `'restore'` (bfcache) or `'autocomplete'`.
|
|
101
101
|
*/
|
|
102
|
-
formStateRestoreCallback(
|
|
103
|
-
if (typeof
|
|
104
|
-
this.value =
|
|
102
|
+
formStateRestoreCallback(state21, _mode) {
|
|
103
|
+
if (typeof state21 === "string") {
|
|
104
|
+
this.value = state21;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -6096,7 +6096,7 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
|
6096
6096
|
}
|
|
6097
6097
|
return coords;
|
|
6098
6098
|
}
|
|
6099
|
-
async function detectOverflow(
|
|
6099
|
+
async function detectOverflow(state21, options) {
|
|
6100
6100
|
var _await$platform$isEle;
|
|
6101
6101
|
if (options === void 0) {
|
|
6102
6102
|
options = {};
|
|
@@ -6108,14 +6108,14 @@ async function detectOverflow(state18, options) {
|
|
|
6108
6108
|
rects,
|
|
6109
6109
|
elements,
|
|
6110
6110
|
strategy
|
|
6111
|
-
} =
|
|
6111
|
+
} = state21;
|
|
6112
6112
|
const {
|
|
6113
6113
|
boundary = "clippingAncestors",
|
|
6114
6114
|
rootBoundary = "viewport",
|
|
6115
6115
|
elementContext = "floating",
|
|
6116
6116
|
altBoundary = false,
|
|
6117
6117
|
padding = 0
|
|
6118
|
-
} = evaluate(options,
|
|
6118
|
+
} = evaluate(options, state21);
|
|
6119
6119
|
const paddingObject = getPaddingObject(padding);
|
|
6120
6120
|
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
6121
6121
|
const element = elements[altBoundary ? altContext : elementContext];
|
|
@@ -6247,7 +6247,7 @@ var flip = function(options) {
|
|
|
6247
6247
|
return {
|
|
6248
6248
|
name: "flip",
|
|
6249
6249
|
options,
|
|
6250
|
-
async fn(
|
|
6250
|
+
async fn(state21) {
|
|
6251
6251
|
var _middlewareData$arrow, _middlewareData$flip;
|
|
6252
6252
|
const {
|
|
6253
6253
|
placement,
|
|
@@ -6256,7 +6256,7 @@ var flip = function(options) {
|
|
|
6256
6256
|
initialPlacement,
|
|
6257
6257
|
platform: platform2,
|
|
6258
6258
|
elements
|
|
6259
|
-
} =
|
|
6259
|
+
} = state21;
|
|
6260
6260
|
const {
|
|
6261
6261
|
mainAxis: checkMainAxis = true,
|
|
6262
6262
|
crossAxis: checkCrossAxis = true,
|
|
@@ -6265,7 +6265,7 @@ var flip = function(options) {
|
|
|
6265
6265
|
fallbackAxisSideDirection = "none",
|
|
6266
6266
|
flipAlignment = true,
|
|
6267
6267
|
...detectOverflowOptions
|
|
6268
|
-
} = evaluate(options,
|
|
6268
|
+
} = evaluate(options, state21);
|
|
6269
6269
|
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
6270
6270
|
return {};
|
|
6271
6271
|
}
|
|
@@ -6279,7 +6279,7 @@ var flip = function(options) {
|
|
|
6279
6279
|
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
6280
6280
|
}
|
|
6281
6281
|
const placements2 = [initialPlacement, ...fallbackPlacements];
|
|
6282
|
-
const overflow = await platform2.detectOverflow(
|
|
6282
|
+
const overflow = await platform2.detectOverflow(state21, detectOverflowOptions);
|
|
6283
6283
|
const overflows = [];
|
|
6284
6284
|
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
6285
6285
|
if (checkMainAxis) {
|
|
@@ -6350,19 +6350,19 @@ var flip = function(options) {
|
|
|
6350
6350
|
};
|
|
6351
6351
|
};
|
|
6352
6352
|
var originSides = /* @__PURE__ */ new Set(["left", "top"]);
|
|
6353
|
-
async function convertValueToCoords(
|
|
6353
|
+
async function convertValueToCoords(state21, options) {
|
|
6354
6354
|
const {
|
|
6355
6355
|
placement,
|
|
6356
6356
|
platform: platform2,
|
|
6357
6357
|
elements
|
|
6358
|
-
} =
|
|
6358
|
+
} = state21;
|
|
6359
6359
|
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
6360
6360
|
const side = getSide(placement);
|
|
6361
6361
|
const alignment = getAlignment(placement);
|
|
6362
6362
|
const isVertical = getSideAxis(placement) === "y";
|
|
6363
6363
|
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
6364
6364
|
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
6365
|
-
const rawValue = evaluate(options,
|
|
6365
|
+
const rawValue = evaluate(options, state21);
|
|
6366
6366
|
let {
|
|
6367
6367
|
mainAxis,
|
|
6368
6368
|
crossAxis,
|
|
@@ -6394,15 +6394,15 @@ var offset = function(options) {
|
|
|
6394
6394
|
return {
|
|
6395
6395
|
name: "offset",
|
|
6396
6396
|
options,
|
|
6397
|
-
async fn(
|
|
6397
|
+
async fn(state21) {
|
|
6398
6398
|
var _middlewareData$offse, _middlewareData$arrow;
|
|
6399
6399
|
const {
|
|
6400
6400
|
x,
|
|
6401
6401
|
y,
|
|
6402
6402
|
placement,
|
|
6403
6403
|
middlewareData
|
|
6404
|
-
} =
|
|
6405
|
-
const diffCoords = await convertValueToCoords(
|
|
6404
|
+
} = state21;
|
|
6405
|
+
const diffCoords = await convertValueToCoords(state21, options);
|
|
6406
6406
|
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
6407
6407
|
return {};
|
|
6408
6408
|
}
|
|
@@ -6424,13 +6424,13 @@ var shift = function(options) {
|
|
|
6424
6424
|
return {
|
|
6425
6425
|
name: "shift",
|
|
6426
6426
|
options,
|
|
6427
|
-
async fn(
|
|
6427
|
+
async fn(state21) {
|
|
6428
6428
|
const {
|
|
6429
6429
|
x,
|
|
6430
6430
|
y,
|
|
6431
6431
|
placement,
|
|
6432
6432
|
platform: platform2
|
|
6433
|
-
} =
|
|
6433
|
+
} = state21;
|
|
6434
6434
|
const {
|
|
6435
6435
|
mainAxis: checkMainAxis = true,
|
|
6436
6436
|
crossAxis: checkCrossAxis = false,
|
|
@@ -6447,12 +6447,12 @@ var shift = function(options) {
|
|
|
6447
6447
|
}
|
|
6448
6448
|
},
|
|
6449
6449
|
...detectOverflowOptions
|
|
6450
|
-
} = evaluate(options,
|
|
6450
|
+
} = evaluate(options, state21);
|
|
6451
6451
|
const coords = {
|
|
6452
6452
|
x,
|
|
6453
6453
|
y
|
|
6454
6454
|
};
|
|
6455
|
-
const overflow = await platform2.detectOverflow(
|
|
6455
|
+
const overflow = await platform2.detectOverflow(state21, detectOverflowOptions);
|
|
6456
6456
|
const crossAxis = getSideAxis(getSide(placement));
|
|
6457
6457
|
const mainAxis = getOppositeAxis(crossAxis);
|
|
6458
6458
|
let mainAxisCoord = coords[mainAxis];
|
|
@@ -6472,7 +6472,7 @@ var shift = function(options) {
|
|
|
6472
6472
|
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
6473
6473
|
}
|
|
6474
6474
|
const limitedCoords = limiter.fn({
|
|
6475
|
-
...
|
|
6475
|
+
...state21,
|
|
6476
6476
|
[mainAxis]: mainAxisCoord,
|
|
6477
6477
|
[crossAxis]: crossAxisCoord
|
|
6478
6478
|
});
|
|
@@ -6563,8 +6563,8 @@ var containRe = /paint|layout|strict|content/;
|
|
|
6563
6563
|
var isNotNone = (value) => !!value && value !== "none";
|
|
6564
6564
|
var isWebKitValue;
|
|
6565
6565
|
function isContainingBlock(elementOrCss) {
|
|
6566
|
-
const
|
|
6567
|
-
return isNotNone(
|
|
6566
|
+
const css139 = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
|
|
6567
|
+
return isNotNone(css139.transform) || isNotNone(css139.translate) || isNotNone(css139.scale) || isNotNone(css139.rotate) || isNotNone(css139.perspective) || !isWebKit() && (isNotNone(css139.backdropFilter) || isNotNone(css139.filter)) || willChangeRe.test(css139.willChange || "") || containRe.test(css139.contain || "");
|
|
6568
6568
|
}
|
|
6569
6569
|
function getContainingBlock(element) {
|
|
6570
6570
|
let currentNode = getParentNode(element);
|
|
@@ -6649,9 +6649,9 @@ function getFrameElement(win) {
|
|
|
6649
6649
|
|
|
6650
6650
|
// node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
|
|
6651
6651
|
function getCssDimensions(element) {
|
|
6652
|
-
const
|
|
6653
|
-
let width = parseFloat(
|
|
6654
|
-
let height = parseFloat(
|
|
6652
|
+
const css139 = getComputedStyle2(element);
|
|
6653
|
+
let width = parseFloat(css139.width) || 0;
|
|
6654
|
+
let height = parseFloat(css139.height) || 0;
|
|
6655
6655
|
const hasOffset = isHTMLElement(element);
|
|
6656
6656
|
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
6657
6657
|
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
@@ -6745,9 +6745,9 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
6745
6745
|
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
6746
6746
|
const iframeScale = getScale(currentIFrame);
|
|
6747
6747
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
6748
|
-
const
|
|
6749
|
-
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(
|
|
6750
|
-
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(
|
|
6748
|
+
const css139 = getComputedStyle2(currentIFrame);
|
|
6749
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css139.paddingLeft)) * iframeScale.x;
|
|
6750
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css139.paddingTop)) * iframeScale.y;
|
|
6751
6751
|
x *= iframeScale.x;
|
|
6752
6752
|
y *= iframeScale.y;
|
|
6753
6753
|
width *= iframeScale.x;
|
|
@@ -6824,15 +6824,15 @@ function getClientRects(element) {
|
|
|
6824
6824
|
return Array.from(element.getClientRects());
|
|
6825
6825
|
}
|
|
6826
6826
|
function getDocumentRect(element) {
|
|
6827
|
-
const
|
|
6827
|
+
const html65 = getDocumentElement(element);
|
|
6828
6828
|
const scroll = getNodeScroll(element);
|
|
6829
6829
|
const body = element.ownerDocument.body;
|
|
6830
|
-
const width = max(
|
|
6831
|
-
const height = max(
|
|
6830
|
+
const width = max(html65.scrollWidth, html65.clientWidth, body.scrollWidth, body.clientWidth);
|
|
6831
|
+
const height = max(html65.scrollHeight, html65.clientHeight, body.scrollHeight, body.clientHeight);
|
|
6832
6832
|
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
6833
6833
|
const y = -scroll.scrollTop;
|
|
6834
6834
|
if (getComputedStyle2(body).direction === "rtl") {
|
|
6835
|
-
x += max(
|
|
6835
|
+
x += max(html65.clientWidth, body.clientWidth) - width;
|
|
6836
6836
|
}
|
|
6837
6837
|
return {
|
|
6838
6838
|
width,
|
|
@@ -6844,10 +6844,10 @@ function getDocumentRect(element) {
|
|
|
6844
6844
|
var SCROLLBAR_MAX = 25;
|
|
6845
6845
|
function getViewportRect(element, strategy) {
|
|
6846
6846
|
const win = getWindow(element);
|
|
6847
|
-
const
|
|
6847
|
+
const html65 = getDocumentElement(element);
|
|
6848
6848
|
const visualViewport = win.visualViewport;
|
|
6849
|
-
let width =
|
|
6850
|
-
let height =
|
|
6849
|
+
let width = html65.clientWidth;
|
|
6850
|
+
let height = html65.clientHeight;
|
|
6851
6851
|
let x = 0;
|
|
6852
6852
|
let y = 0;
|
|
6853
6853
|
if (visualViewport) {
|
|
@@ -6859,13 +6859,13 @@ function getViewportRect(element, strategy) {
|
|
|
6859
6859
|
y = visualViewport.offsetTop;
|
|
6860
6860
|
}
|
|
6861
6861
|
}
|
|
6862
|
-
const windowScrollbarX = getWindowScrollBarX(
|
|
6862
|
+
const windowScrollbarX = getWindowScrollBarX(html65);
|
|
6863
6863
|
if (windowScrollbarX <= 0) {
|
|
6864
|
-
const doc =
|
|
6864
|
+
const doc = html65.ownerDocument;
|
|
6865
6865
|
const body = doc.body;
|
|
6866
6866
|
const bodyStyles = getComputedStyle(body);
|
|
6867
6867
|
const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
6868
|
-
const clippingStableScrollbarWidth = Math.abs(
|
|
6868
|
+
const clippingStableScrollbarWidth = Math.abs(html65.clientWidth - body.clientWidth - bodyMarginInline);
|
|
6869
6869
|
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
|
6870
6870
|
width -= clippingStableScrollbarWidth;
|
|
6871
6871
|
}
|
|
@@ -9417,6 +9417,13 @@ import { createContext as createContext2 } from "@lit/context";
|
|
|
9417
9417
|
var formFieldContext = createContext2(
|
|
9418
9418
|
/* @__PURE__ */ Symbol("form-field-context")
|
|
9419
9419
|
);
|
|
9420
|
+
var defaultFormFieldContext = {
|
|
9421
|
+
controlId: "",
|
|
9422
|
+
ariaLabelledby: "",
|
|
9423
|
+
ariaDescribedby: "",
|
|
9424
|
+
invalid: false,
|
|
9425
|
+
warning: false
|
|
9426
|
+
};
|
|
9420
9427
|
|
|
9421
9428
|
// src/form-field/styles.ts
|
|
9422
9429
|
import { css as css61 } from "lit";
|
|
@@ -19836,9 +19843,3375 @@ __decorateClass([
|
|
|
19836
19843
|
var CsTable = class extends CsTableInternal {
|
|
19837
19844
|
};
|
|
19838
19845
|
customElements.define("cs-table", CsTable);
|
|
19846
|
+
|
|
19847
|
+
// src/form/internal.ts
|
|
19848
|
+
import { css as css120, html as html55, nothing as nothing29 } from "lit";
|
|
19849
|
+
import { property as property54 } from "lit/decorators.js";
|
|
19850
|
+
|
|
19851
|
+
// src/form/styles.ts
|
|
19852
|
+
import { css as css119 } from "lit";
|
|
19853
|
+
var componentStyles53 = css119`
|
|
19854
|
+
.root {
|
|
19855
|
+
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
19856
|
+
line-height: var(--line-height-body-m-2mh3ke, 20px);
|
|
19857
|
+
color: var(--color-text-body-default-vvtq8u, #0f141a);
|
|
19858
|
+
font-weight: 400;
|
|
19859
|
+
font-family: var(--font-family-base-gmnpzl, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
19860
|
+
-webkit-font-smoothing: auto;
|
|
19861
|
+
-moz-osx-font-smoothing: auto;
|
|
19862
|
+
}
|
|
19863
|
+
|
|
19864
|
+
.header {
|
|
19865
|
+
margin-block-end: var(--space-scaled-m-m892r9, 16px);
|
|
19866
|
+
}
|
|
19867
|
+
|
|
19868
|
+
.footer {
|
|
19869
|
+
margin-block-start: var(--space-scaled-l-sej05l, 20px);
|
|
19870
|
+
}
|
|
19871
|
+
|
|
19872
|
+
.actions-section {
|
|
19873
|
+
display: flex;
|
|
19874
|
+
flex-direction: row-reverse;
|
|
19875
|
+
justify-content: space-between;
|
|
19876
|
+
flex-wrap: wrap;
|
|
19877
|
+
margin-inline-start: calc(-1 * var(--space-scaled-m-m892r9, 16px));
|
|
19878
|
+
margin-block-end: calc(-1 * var(--space-scaled-m-m892r9, 16px));
|
|
19879
|
+
}
|
|
19880
|
+
|
|
19881
|
+
.secondary-actions {
|
|
19882
|
+
min-inline-size: 1px;
|
|
19883
|
+
margin-inline-start: var(--space-scaled-m-m892r9, 16px);
|
|
19884
|
+
margin-block-end: var(--space-scaled-m-m892r9, 16px);
|
|
19885
|
+
}
|
|
19886
|
+
|
|
19887
|
+
.actions {
|
|
19888
|
+
min-inline-size: 1px;
|
|
19889
|
+
margin-inline-start: var(--space-scaled-m-m892r9, 16px);
|
|
19890
|
+
margin-block-end: var(--space-scaled-m-m892r9, 16px);
|
|
19891
|
+
}
|
|
19892
|
+
`;
|
|
19893
|
+
|
|
19894
|
+
// src/form/internal.ts
|
|
19895
|
+
var hostStyles54 = css120`:host { display: block; }`;
|
|
19896
|
+
var CsFormInternal = class extends CsBaseElement {
|
|
19897
|
+
constructor() {
|
|
19898
|
+
super(...arguments);
|
|
19899
|
+
this.header = "";
|
|
19900
|
+
this.errorText = "";
|
|
19901
|
+
this.errorIconAriaLabel = "";
|
|
19902
|
+
this.variant = "embedded";
|
|
19903
|
+
this._hasActions = false;
|
|
19904
|
+
this._hasSecondaryActions = false;
|
|
19905
|
+
this._onActionsSlotChange = (e) => {
|
|
19906
|
+
const slot = e.target;
|
|
19907
|
+
this._hasActions = slot.assignedNodes({ flatten: true }).length > 0;
|
|
19908
|
+
this.requestUpdate();
|
|
19909
|
+
};
|
|
19910
|
+
this._onSecondaryActionsSlotChange = (e) => {
|
|
19911
|
+
const slot = e.target;
|
|
19912
|
+
this._hasSecondaryActions = slot.assignedNodes({ flatten: true }).length > 0;
|
|
19913
|
+
this.requestUpdate();
|
|
19914
|
+
};
|
|
19915
|
+
}
|
|
19916
|
+
static {
|
|
19917
|
+
this.styles = [sharedStyles, componentStyles53, hostStyles54];
|
|
19918
|
+
}
|
|
19919
|
+
render() {
|
|
19920
|
+
const hasError = !!this.errorText;
|
|
19921
|
+
const hasFooter = this._hasActions || this._hasSecondaryActions;
|
|
19922
|
+
return html55`
|
|
19923
|
+
<div class="root">
|
|
19924
|
+
${this.header ? html55`<div class="header"><slot name="header">${this.header}</slot></div>` : html55`<slot name="header"></slot>`}
|
|
19925
|
+
|
|
19926
|
+
<div class="content">
|
|
19927
|
+
${hasError ? html55`
|
|
19928
|
+
<cs-alert
|
|
19929
|
+
type="error"
|
|
19930
|
+
status-icon-aria-label=${this.errorIconAriaLabel || "Error"}
|
|
19931
|
+
>${this.errorText}</cs-alert>
|
|
19932
|
+
` : nothing29}
|
|
19933
|
+
<slot></slot>
|
|
19934
|
+
</div>
|
|
19935
|
+
|
|
19936
|
+
${hasFooter ? html55`
|
|
19937
|
+
<div class="footer">
|
|
19938
|
+
<div class="actions-section">
|
|
19939
|
+
<div class="actions">
|
|
19940
|
+
<slot name="actions" @slotchange=${this._onActionsSlotChange}></slot>
|
|
19941
|
+
</div>
|
|
19942
|
+
<div class="secondary-actions">
|
|
19943
|
+
<slot name="secondaryActions" @slotchange=${this._onSecondaryActionsSlotChange}></slot>
|
|
19944
|
+
</div>
|
|
19945
|
+
</div>
|
|
19946
|
+
</div>
|
|
19947
|
+
` : html55`
|
|
19948
|
+
<slot name="actions" @slotchange=${this._onActionsSlotChange} style="display:none"></slot>
|
|
19949
|
+
<slot name="secondaryActions" @slotchange=${this._onSecondaryActionsSlotChange} style="display:none"></slot>
|
|
19950
|
+
`}
|
|
19951
|
+
</div>
|
|
19952
|
+
`;
|
|
19953
|
+
}
|
|
19954
|
+
};
|
|
19955
|
+
__decorateClass([
|
|
19956
|
+
property54({ type: String })
|
|
19957
|
+
], CsFormInternal.prototype, "header", 2);
|
|
19958
|
+
__decorateClass([
|
|
19959
|
+
property54({ type: String })
|
|
19960
|
+
], CsFormInternal.prototype, "errorText", 2);
|
|
19961
|
+
__decorateClass([
|
|
19962
|
+
property54({ type: String })
|
|
19963
|
+
], CsFormInternal.prototype, "errorIconAriaLabel", 2);
|
|
19964
|
+
__decorateClass([
|
|
19965
|
+
property54({ type: String })
|
|
19966
|
+
], CsFormInternal.prototype, "variant", 2);
|
|
19967
|
+
|
|
19968
|
+
// src/form/index.ts
|
|
19969
|
+
var CsForm = class extends CsFormInternal {
|
|
19970
|
+
};
|
|
19971
|
+
customElements.define("cs-form", CsForm);
|
|
19972
|
+
|
|
19973
|
+
// src/modal/internal.ts
|
|
19974
|
+
import { css as css122, html as html56 } from "lit";
|
|
19975
|
+
import { property as property55 } from "lit/decorators.js";
|
|
19976
|
+
import { classMap as classMap45 } from "lit/directives/class-map.js";
|
|
19977
|
+
import { ifDefined as ifDefined27 } from "lit/directives/if-defined.js";
|
|
19978
|
+
|
|
19979
|
+
// src/modal/styles.ts
|
|
19980
|
+
import { css as css121 } from "lit";
|
|
19981
|
+
var componentStyles54 = css121`
|
|
19982
|
+
@keyframes awsui_modal-slide-up_1d2i7_rypew_1 {
|
|
19983
|
+
0% {
|
|
19984
|
+
transform: translate(0, 10px);
|
|
19985
|
+
}
|
|
19986
|
+
100% {
|
|
19987
|
+
transform: translate(0, 0);
|
|
19988
|
+
}
|
|
19989
|
+
}
|
|
19990
|
+
.dialog {
|
|
19991
|
+
animation: awsui_modal-slide-up_1d2i7_rypew_1 var(--motion-duration-slow-zji5vl, 180ms) ease-out, awsui_awsui-motion-fade-in-0_1d2i7_rypew_1 var(--motion-duration-slow-zji5vl, 180ms) ease-out;
|
|
19992
|
+
animation-delay: var(--motion-duration-fast-unntf6, 90ms);
|
|
19993
|
+
animation-fill-mode: both;
|
|
19994
|
+
}
|
|
19995
|
+
@keyframes awsui_awsui-motion-fade-in-0_1d2i7_rypew_1 {
|
|
19996
|
+
from {
|
|
19997
|
+
opacity: 0;
|
|
19998
|
+
}
|
|
19999
|
+
to {
|
|
20000
|
+
opacity: 1;
|
|
20001
|
+
}
|
|
20002
|
+
}
|
|
20003
|
+
@media (prefers-reduced-motion: reduce) {
|
|
20004
|
+
.dialog {
|
|
20005
|
+
animation: none;
|
|
20006
|
+
transition: none;
|
|
20007
|
+
}
|
|
20008
|
+
}
|
|
20009
|
+
.awsui-motion-disabled .dialog, .awsui-mode-entering .dialog {
|
|
20010
|
+
animation: none;
|
|
20011
|
+
transition: none;
|
|
20012
|
+
}
|
|
20013
|
+
.dialog.refresh {
|
|
20014
|
+
animation: awsui_awsui-motion-scale-popup_1d2i7_rypew_1, awsui_awsui-motion-fade-in-0_1d2i7_rypew_1;
|
|
20015
|
+
animation-duration: var(--motion-duration-refresh-only-fast-zfibh6, 115ms);
|
|
20016
|
+
animation-timing-function: var(--motion-easing-refresh-only-a-ccyqaz, cubic-bezier(0, 0, 0, 1));
|
|
20017
|
+
animation-fill-mode: both;
|
|
20018
|
+
}
|
|
20019
|
+
@keyframes awsui_awsui-motion-fade-in-0_1d2i7_rypew_1 {
|
|
20020
|
+
from {
|
|
20021
|
+
opacity: 0;
|
|
20022
|
+
}
|
|
20023
|
+
to {
|
|
20024
|
+
opacity: 1;
|
|
20025
|
+
}
|
|
20026
|
+
}
|
|
20027
|
+
@keyframes awsui_awsui-motion-scale-popup_1d2i7_rypew_1 {
|
|
20028
|
+
0% {
|
|
20029
|
+
transform: scale(0.95);
|
|
20030
|
+
}
|
|
20031
|
+
100% {
|
|
20032
|
+
transform: scale(1);
|
|
20033
|
+
}
|
|
20034
|
+
}
|
|
20035
|
+
@media (prefers-reduced-motion: reduce) {
|
|
20036
|
+
.dialog.refresh {
|
|
20037
|
+
animation: none;
|
|
20038
|
+
transition: none;
|
|
20039
|
+
}
|
|
20040
|
+
}
|
|
20041
|
+
.awsui-motion-disabled .dialog.refresh, .awsui-mode-entering .dialog.refresh {
|
|
20042
|
+
animation: none;
|
|
20043
|
+
transition: none;
|
|
20044
|
+
}
|
|
20045
|
+
|
|
20046
|
+
.root {
|
|
20047
|
+
animation: awsui_awsui-motion-fade-in_1d2i7_rypew_1 var(--motion-duration-extra-slow-29bqym, 270ms) ease-out;
|
|
20048
|
+
animation-fill-mode: both;
|
|
20049
|
+
}
|
|
20050
|
+
@keyframes awsui_awsui-motion-fade-in_1d2i7_rypew_1 {
|
|
20051
|
+
from {
|
|
20052
|
+
opacity: 0.2;
|
|
20053
|
+
}
|
|
20054
|
+
to {
|
|
20055
|
+
opacity: 1;
|
|
20056
|
+
}
|
|
20057
|
+
}
|
|
20058
|
+
@media (prefers-reduced-motion: reduce) {
|
|
20059
|
+
.root {
|
|
20060
|
+
animation: none;
|
|
20061
|
+
transition: none;
|
|
20062
|
+
}
|
|
20063
|
+
}
|
|
20064
|
+
.awsui-motion-disabled .root, .awsui-mode-entering .root {
|
|
20065
|
+
animation: none;
|
|
20066
|
+
transition: none;
|
|
20067
|
+
}
|
|
20068
|
+
.root.refresh {
|
|
20069
|
+
animation-duration: var(--motion-duration-refresh-only-fast-zfibh6, 115ms);
|
|
20070
|
+
}
|
|
20071
|
+
@media (prefers-reduced-motion: reduce) {
|
|
20072
|
+
.root.refresh {
|
|
20073
|
+
animation: none;
|
|
20074
|
+
transition: none;
|
|
20075
|
+
}
|
|
20076
|
+
}
|
|
20077
|
+
.awsui-motion-disabled .root.refresh, .awsui-mode-entering .root.refresh {
|
|
20078
|
+
animation: none;
|
|
20079
|
+
transition: none;
|
|
20080
|
+
}
|
|
20081
|
+
|
|
20082
|
+
.root {
|
|
20083
|
+
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
20084
|
+
line-height: var(--line-height-body-m-2mh3ke, 20px);
|
|
20085
|
+
color: var(--color-text-body-default-vvtq8u, #0f141a);
|
|
20086
|
+
font-weight: 400;
|
|
20087
|
+
font-family: var(--font-family-base-gmnpzl, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
20088
|
+
-webkit-font-smoothing: auto;
|
|
20089
|
+
-moz-osx-font-smoothing: auto;
|
|
20090
|
+
background-color: var(--color-background-modal-overlay-d7uby0, rgba(35, 43, 55, 0.7));
|
|
20091
|
+
display: flex;
|
|
20092
|
+
align-items: center;
|
|
20093
|
+
justify-items: center;
|
|
20094
|
+
inset: 0;
|
|
20095
|
+
position: fixed;
|
|
20096
|
+
z-index: 5000;
|
|
20097
|
+
outline: 0;
|
|
20098
|
+
overflow: auto;
|
|
20099
|
+
cursor: pointer;
|
|
20100
|
+
}
|
|
20101
|
+
.root.hidden {
|
|
20102
|
+
display: none;
|
|
20103
|
+
}
|
|
20104
|
+
|
|
20105
|
+
.focus-lock {
|
|
20106
|
+
align-self: flex-start;
|
|
20107
|
+
margin-inline: auto;
|
|
20108
|
+
padding-block: var(--space-s-tvghoh, 12px);
|
|
20109
|
+
padding-inline: 0;
|
|
20110
|
+
z-index: 5000;
|
|
20111
|
+
pointer-events: none;
|
|
20112
|
+
}
|
|
20113
|
+
.focus-lock.position-top {
|
|
20114
|
+
margin-block-start: 0;
|
|
20115
|
+
}
|
|
20116
|
+
.focus-lock.position-center {
|
|
20117
|
+
margin-block: auto;
|
|
20118
|
+
}
|
|
20119
|
+
|
|
20120
|
+
.dialog {
|
|
20121
|
+
position: static;
|
|
20122
|
+
inset-block-start: 0;
|
|
20123
|
+
transform: translate(0, 0);
|
|
20124
|
+
inline-size: calc(100vw - var(--space-s-tvghoh, 12px) * 2);
|
|
20125
|
+
box-sizing: border-box;
|
|
20126
|
+
outline: none;
|
|
20127
|
+
z-index: 5000;
|
|
20128
|
+
pointer-events: all;
|
|
20129
|
+
}
|
|
20130
|
+
.dialog.small {
|
|
20131
|
+
max-inline-size: 320px;
|
|
20132
|
+
}
|
|
20133
|
+
.dialog.medium {
|
|
20134
|
+
max-inline-size: 600px;
|
|
20135
|
+
}
|
|
20136
|
+
.dialog.large {
|
|
20137
|
+
max-inline-size: 820px;
|
|
20138
|
+
}
|
|
20139
|
+
.dialog.x-large {
|
|
20140
|
+
max-inline-size: 1024px;
|
|
20141
|
+
}
|
|
20142
|
+
.dialog.xx-large {
|
|
20143
|
+
max-inline-size: 1280px;
|
|
20144
|
+
}
|
|
20145
|
+
.dialog.custom-width {
|
|
20146
|
+
max-inline-size: var(--awsui-modal-custom-width-6b9ypa);
|
|
20147
|
+
}
|
|
20148
|
+
.dialog.max.breakpoint-xs {
|
|
20149
|
+
max-inline-size: calc(100vw - (8 * 10px + var(--space-xxxl-aut1u7, 40px)));
|
|
20150
|
+
margin-block: auto;
|
|
20151
|
+
margin-inline: auto;
|
|
20152
|
+
}
|
|
20153
|
+
.dialog.custom-height {
|
|
20154
|
+
block-size: var(--awsui-modal-custom-height-6b9ypa);
|
|
20155
|
+
max-block-size: calc(100vh - 2 * var(--space-s-tvghoh, 12px));
|
|
20156
|
+
}
|
|
20157
|
+
|
|
20158
|
+
.container {
|
|
20159
|
+
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
20160
|
+
line-height: var(--line-height-body-m-2mh3ke, 20px);
|
|
20161
|
+
color: var(--color-text-body-default-vvtq8u, #0f141a);
|
|
20162
|
+
font-weight: 400;
|
|
20163
|
+
font-family: var(--font-family-base-gmnpzl, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
20164
|
+
-webkit-font-smoothing: auto;
|
|
20165
|
+
-moz-osx-font-smoothing: auto;
|
|
20166
|
+
display: block;
|
|
20167
|
+
background-color: var(--color-background-container-content-6u8rvp, #ffffff);
|
|
20168
|
+
word-wrap: break-word;
|
|
20169
|
+
border-block-start: var(--border-container-top-width-n1eke6, 0px) solid var(--color-border-container-top-k3vmoz, transparent);
|
|
20170
|
+
border-start-start-radius: var(--border-radius-container-nsfwmm, 16px);
|
|
20171
|
+
border-start-end-radius: var(--border-radius-container-nsfwmm, 16px);
|
|
20172
|
+
border-end-start-radius: var(--border-radius-container-nsfwmm, 16px);
|
|
20173
|
+
border-end-end-radius: var(--border-radius-container-nsfwmm, 16px);
|
|
20174
|
+
box-shadow: var(--shadow-modal-kwgqht, 0px 4px 20px 1px rgba(0, 7, 22, 0.1));
|
|
20175
|
+
}
|
|
20176
|
+
.container.custom-height-container {
|
|
20177
|
+
display: flex;
|
|
20178
|
+
flex-direction: column;
|
|
20179
|
+
block-size: 100%;
|
|
20180
|
+
}
|
|
20181
|
+
|
|
20182
|
+
.content {
|
|
20183
|
+
padding-block-start: var(--space-container-content-top-1wtqrc, 4px);
|
|
20184
|
+
padding-block-end: var(--space-modal-content-bottom-nl6ceq, 16px);
|
|
20185
|
+
padding-inline: var(--space-modal-horizontal-y5hnwp, 20px);
|
|
20186
|
+
}
|
|
20187
|
+
.content.no-paddings {
|
|
20188
|
+
padding-block: 0;
|
|
20189
|
+
padding-inline: 0;
|
|
20190
|
+
}
|
|
20191
|
+
.content.custom-height-content {
|
|
20192
|
+
flex-grow: 1;
|
|
20193
|
+
overflow-y: auto;
|
|
20194
|
+
}
|
|
20195
|
+
|
|
20196
|
+
.header {
|
|
20197
|
+
padding-block-start: var(--space-container-header-top-am4vzw, 12px);
|
|
20198
|
+
padding-block-end: var(--space-container-header-bottom-2taq8v, 8px);
|
|
20199
|
+
padding-inline: var(--space-modal-horizontal-y5hnwp, 20px);
|
|
20200
|
+
background-color: var(--color-background-container-header-gs3mbe, #ffffff);
|
|
20201
|
+
border-block-end: 1px solid var(--color-border-container-divider-9huz1a, transparent);
|
|
20202
|
+
border-start-start-radius: var(--border-radius-container-nsfwmm, 16px);
|
|
20203
|
+
border-start-end-radius: var(--border-radius-container-nsfwmm, 16px);
|
|
20204
|
+
border-end-start-radius: 0;
|
|
20205
|
+
border-end-end-radius: 0;
|
|
20206
|
+
}
|
|
20207
|
+
|
|
20208
|
+
.footer {
|
|
20209
|
+
border-block-start: var(--border-divider-section-width-uwo8my, 1px) solid var(--color-border-divider-default-nr68jt, #c6c6cd);
|
|
20210
|
+
padding-block: var(--space-scaled-s-8ozaad, 12px);
|
|
20211
|
+
padding-inline: var(--space-container-horizontal-nqrzyh, 20px);
|
|
20212
|
+
background-color: var(--color-background-container-content-6u8rvp, #ffffff);
|
|
20213
|
+
position: sticky;
|
|
20214
|
+
inset-block-end: 0;
|
|
20215
|
+
z-index: 800;
|
|
20216
|
+
}
|
|
20217
|
+
.footer--rounded {
|
|
20218
|
+
border-start-start-radius: 0;
|
|
20219
|
+
border-start-end-radius: 0;
|
|
20220
|
+
border-end-start-radius: var(--border-radius-container-nsfwmm, 16px);
|
|
20221
|
+
border-end-end-radius: var(--border-radius-container-nsfwmm, 16px);
|
|
20222
|
+
}
|
|
20223
|
+
.footer:after {
|
|
20224
|
+
content: "";
|
|
20225
|
+
display: table;
|
|
20226
|
+
clear: both;
|
|
20227
|
+
}
|
|
20228
|
+
|
|
20229
|
+
.modal-open {
|
|
20230
|
+
overflow: hidden;
|
|
20231
|
+
/*
|
|
20232
|
+
* When padding-right is added to account for scrollbar being turned
|
|
20233
|
+
* off by overflow:hidden, that padding will go offscreen and have no
|
|
20234
|
+
* effect if box-sizing is content-box and body width is 100%. Set
|
|
20235
|
+
* border-box to avoid this; this should be safe as box-sizing isn't
|
|
20236
|
+
* inherited by child elements normally.
|
|
20237
|
+
*/
|
|
20238
|
+
box-sizing: border-box;
|
|
20239
|
+
}
|
|
20240
|
+
`;
|
|
20241
|
+
|
|
20242
|
+
// src/modal/internal.ts
|
|
20243
|
+
var hostStyles55 = css122`:host { display: block; }`;
|
|
20244
|
+
var CsModalInternal = class extends CsBaseElement {
|
|
20245
|
+
constructor() {
|
|
20246
|
+
super(...arguments);
|
|
20247
|
+
this.visible = false;
|
|
20248
|
+
this.size = "medium";
|
|
20249
|
+
this.header = "";
|
|
20250
|
+
this.closeAriaLabel = "Close";
|
|
20251
|
+
this.disableContentPaddings = false;
|
|
20252
|
+
this.position = "center";
|
|
20253
|
+
this._hasFooter = false;
|
|
20254
|
+
this._onFooterSlotChange = (e) => {
|
|
20255
|
+
const slot = e.target;
|
|
20256
|
+
this._hasFooter = slot.assignedNodes({ flatten: true }).length > 0;
|
|
20257
|
+
this.requestUpdate();
|
|
20258
|
+
};
|
|
20259
|
+
this._onKeyDown = (e) => {
|
|
20260
|
+
if (e.key === "Escape" && this.visible) {
|
|
20261
|
+
e.stopPropagation();
|
|
20262
|
+
this._dismiss("keyboard");
|
|
20263
|
+
}
|
|
20264
|
+
};
|
|
20265
|
+
this._onBackdropClick = (e) => {
|
|
20266
|
+
if (e.target === e.currentTarget) {
|
|
20267
|
+
this._dismiss("overlay");
|
|
20268
|
+
}
|
|
20269
|
+
};
|
|
20270
|
+
this._onCloseClick = () => {
|
|
20271
|
+
this._dismiss("closeButton");
|
|
20272
|
+
};
|
|
20273
|
+
}
|
|
20274
|
+
static {
|
|
20275
|
+
this.styles = [sharedStyles, componentStyles54, hostStyles55];
|
|
20276
|
+
}
|
|
20277
|
+
connectedCallback() {
|
|
20278
|
+
super.connectedCallback();
|
|
20279
|
+
this.addEventListener("keydown", this._onKeyDown);
|
|
20280
|
+
}
|
|
20281
|
+
disconnectedCallback() {
|
|
20282
|
+
super.disconnectedCallback();
|
|
20283
|
+
this.removeEventListener("keydown", this._onKeyDown);
|
|
20284
|
+
}
|
|
20285
|
+
_dismiss(reason) {
|
|
20286
|
+
const detail = { reason };
|
|
20287
|
+
fireNonCancelableEvent(this, "dismiss", detail);
|
|
20288
|
+
}
|
|
20289
|
+
render() {
|
|
20290
|
+
const rootClasses = {
|
|
20291
|
+
"root": true,
|
|
20292
|
+
"hidden": !this.visible
|
|
20293
|
+
};
|
|
20294
|
+
const focusLockClasses = {
|
|
20295
|
+
"focus-lock": true,
|
|
20296
|
+
[`position-${this.position}`]: true
|
|
20297
|
+
};
|
|
20298
|
+
const dialogClasses = {
|
|
20299
|
+
"dialog": true,
|
|
20300
|
+
[this.size]: true
|
|
20301
|
+
};
|
|
20302
|
+
const contentClasses = {
|
|
20303
|
+
"content": true,
|
|
20304
|
+
"no-paddings": this.disableContentPaddings
|
|
20305
|
+
};
|
|
20306
|
+
const footerClasses = {
|
|
20307
|
+
"footer": true,
|
|
20308
|
+
"footer--rounded": true
|
|
20309
|
+
};
|
|
20310
|
+
return html56`
|
|
20311
|
+
<div
|
|
20312
|
+
class=${classMap45(rootClasses)}
|
|
20313
|
+
@click=${this._onBackdropClick}
|
|
20314
|
+
>
|
|
20315
|
+
<div class=${classMap45(focusLockClasses)}>
|
|
20316
|
+
<div
|
|
20317
|
+
class=${classMap45(dialogClasses)}
|
|
20318
|
+
role="dialog"
|
|
20319
|
+
aria-modal="true"
|
|
20320
|
+
aria-label=${ifDefined27(this.header || void 0)}
|
|
20321
|
+
>
|
|
20322
|
+
<div class="container">
|
|
20323
|
+
<div class="header">
|
|
20324
|
+
<div style="display:flex;align-items:center;justify-content:space-between;width:100%">
|
|
20325
|
+
<div style="flex:1;min-width:0">
|
|
20326
|
+
<slot name="header">${this.header}</slot>
|
|
20327
|
+
</div>
|
|
20328
|
+
<cs-button
|
|
20329
|
+
variant="icon"
|
|
20330
|
+
icon-name="close"
|
|
20331
|
+
aria-label=${this.closeAriaLabel}
|
|
20332
|
+
@click=${this._onCloseClick}
|
|
20333
|
+
></cs-button>
|
|
20334
|
+
</div>
|
|
20335
|
+
</div>
|
|
20336
|
+
|
|
20337
|
+
<div class=${classMap45(contentClasses)}>
|
|
20338
|
+
<slot></slot>
|
|
20339
|
+
</div>
|
|
20340
|
+
|
|
20341
|
+
${this._hasFooter ? html56`<div class=${classMap45(footerClasses)}><slot name="footer" @slotchange=${this._onFooterSlotChange}></slot></div>` : html56`<slot name="footer" @slotchange=${this._onFooterSlotChange} style="display:none"></slot>`}
|
|
20342
|
+
</div>
|
|
20343
|
+
</div>
|
|
20344
|
+
</div>
|
|
20345
|
+
</div>
|
|
20346
|
+
`;
|
|
20347
|
+
}
|
|
20348
|
+
};
|
|
20349
|
+
__decorateClass([
|
|
20350
|
+
property55({ type: Boolean, reflect: true })
|
|
20351
|
+
], CsModalInternal.prototype, "visible", 2);
|
|
20352
|
+
__decorateClass([
|
|
20353
|
+
property55({ type: String, reflect: true })
|
|
20354
|
+
], CsModalInternal.prototype, "size", 2);
|
|
20355
|
+
__decorateClass([
|
|
20356
|
+
property55({ type: String })
|
|
20357
|
+
], CsModalInternal.prototype, "header", 2);
|
|
20358
|
+
__decorateClass([
|
|
20359
|
+
property55({ type: String })
|
|
20360
|
+
], CsModalInternal.prototype, "closeAriaLabel", 2);
|
|
20361
|
+
__decorateClass([
|
|
20362
|
+
property55({ type: Boolean })
|
|
20363
|
+
], CsModalInternal.prototype, "disableContentPaddings", 2);
|
|
20364
|
+
__decorateClass([
|
|
20365
|
+
property55({ type: String })
|
|
20366
|
+
], CsModalInternal.prototype, "position", 2);
|
|
20367
|
+
|
|
20368
|
+
// src/modal/index.ts
|
|
20369
|
+
var CsModal = class extends CsModalInternal {
|
|
20370
|
+
};
|
|
20371
|
+
customElements.define("cs-modal", CsModal);
|
|
20372
|
+
|
|
20373
|
+
// src/file-upload/internal.ts
|
|
20374
|
+
import { css as css124, html as html57, nothing as nothing30 } from "lit";
|
|
20375
|
+
import { property as property56 } from "lit/decorators.js";
|
|
20376
|
+
import { classMap as classMap46 } from "lit/directives/class-map.js";
|
|
20377
|
+
import { ifDefined as ifDefined28 } from "lit/directives/if-defined.js";
|
|
20378
|
+
|
|
20379
|
+
// src/file-upload/styles.ts
|
|
20380
|
+
import { css as css123 } from "lit";
|
|
20381
|
+
var componentStyles55 = css123`
|
|
20382
|
+
.hints {
|
|
20383
|
+
margin-block-start: var(--space-static-xxs-ns94dp, 4px);
|
|
20384
|
+
}
|
|
20385
|
+
`;
|
|
20386
|
+
|
|
20387
|
+
// src/file-upload/internal.ts
|
|
20388
|
+
var hostStyles56 = css124`:host { display: block; }`;
|
|
20389
|
+
var fileListStyles = css124`
|
|
20390
|
+
.file-upload-root {
|
|
20391
|
+
display: flex;
|
|
20392
|
+
flex-direction: column;
|
|
20393
|
+
gap: var(--space-xs-ymlm0b, 8px);
|
|
20394
|
+
}
|
|
20395
|
+
.label {
|
|
20396
|
+
font-weight: 700;
|
|
20397
|
+
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
20398
|
+
line-height: var(--line-height-body-m-2mh3ke, 20px);
|
|
20399
|
+
color: var(--color-text-form-label-2ul0mm, #0f141a);
|
|
20400
|
+
margin-block-end: var(--space-xxs-p4when, 4px);
|
|
20401
|
+
}
|
|
20402
|
+
.file-list {
|
|
20403
|
+
display: flex;
|
|
20404
|
+
flex-direction: column;
|
|
20405
|
+
gap: var(--space-xs-ymlm0b, 8px);
|
|
20406
|
+
list-style: none;
|
|
20407
|
+
margin: 0;
|
|
20408
|
+
padding: 0;
|
|
20409
|
+
}
|
|
20410
|
+
.file-list-horizontal {
|
|
20411
|
+
flex-direction: row;
|
|
20412
|
+
flex-wrap: wrap;
|
|
20413
|
+
}
|
|
20414
|
+
.file-item {
|
|
20415
|
+
display: flex;
|
|
20416
|
+
align-items: center;
|
|
20417
|
+
gap: var(--space-xs-ymlm0b, 8px);
|
|
20418
|
+
padding: var(--space-xxs-p4when, 4px) var(--space-xs-ymlm0b, 8px);
|
|
20419
|
+
border: 1px solid var(--color-border-input-default-nviccl, #c6c6cd);
|
|
20420
|
+
border-radius: var(--border-radius-item-1xihb0, 8px);
|
|
20421
|
+
background: var(--color-background-container-content-6u8rvp, #ffffff);
|
|
20422
|
+
min-width: 0;
|
|
20423
|
+
}
|
|
20424
|
+
.file-item-error {
|
|
20425
|
+
border-color: var(--color-text-status-error-cjhm35, #db0000);
|
|
20426
|
+
}
|
|
20427
|
+
.file-info {
|
|
20428
|
+
flex: 1;
|
|
20429
|
+
min-width: 0;
|
|
20430
|
+
overflow: hidden;
|
|
20431
|
+
}
|
|
20432
|
+
.file-name {
|
|
20433
|
+
white-space: nowrap;
|
|
20434
|
+
overflow: hidden;
|
|
20435
|
+
text-overflow: ellipsis;
|
|
20436
|
+
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
20437
|
+
line-height: var(--line-height-body-m-2mh3ke, 20px);
|
|
20438
|
+
}
|
|
20439
|
+
.file-metadata {
|
|
20440
|
+
font-size: var(--font-size-body-s-h7kcgl, 12px);
|
|
20441
|
+
color: var(--color-text-body-secondary-5wt35c, #687078);
|
|
20442
|
+
line-height: var(--line-height-body-s-0ycq7b, 16px);
|
|
20443
|
+
}
|
|
20444
|
+
.file-error {
|
|
20445
|
+
font-size: var(--font-size-body-s-h7kcgl, 12px);
|
|
20446
|
+
color: var(--color-text-status-error-cjhm35, #db0000);
|
|
20447
|
+
line-height: var(--line-height-body-s-0ycq7b, 16px);
|
|
20448
|
+
}
|
|
20449
|
+
.file-thumbnail {
|
|
20450
|
+
width: 32px;
|
|
20451
|
+
height: 32px;
|
|
20452
|
+
object-fit: cover;
|
|
20453
|
+
border-radius: 4px;
|
|
20454
|
+
}
|
|
20455
|
+
.dismiss-button {
|
|
20456
|
+
display: inline-flex;
|
|
20457
|
+
align-items: center;
|
|
20458
|
+
justify-content: center;
|
|
20459
|
+
background: none;
|
|
20460
|
+
border: none;
|
|
20461
|
+
cursor: pointer;
|
|
20462
|
+
padding: 2px;
|
|
20463
|
+
color: var(--color-text-body-secondary-5wt35c, #687078);
|
|
20464
|
+
border-radius: 4px;
|
|
20465
|
+
flex-shrink: 0;
|
|
20466
|
+
}
|
|
20467
|
+
.dismiss-button:hover {
|
|
20468
|
+
color: var(--color-text-body-default-vvtq8u, #0f141a);
|
|
20469
|
+
background: var(--color-background-button-normal-hover-h21rio, rgba(0, 7, 22, 0.05));
|
|
20470
|
+
}
|
|
20471
|
+
.constraint-text {
|
|
20472
|
+
font-size: var(--font-size-body-s-h7kcgl, 12px);
|
|
20473
|
+
color: var(--color-text-body-secondary-5wt35c, #687078);
|
|
20474
|
+
line-height: var(--line-height-body-s-0ycq7b, 16px);
|
|
20475
|
+
}
|
|
20476
|
+
.error-text {
|
|
20477
|
+
font-size: var(--font-size-body-s-h7kcgl, 12px);
|
|
20478
|
+
color: var(--color-text-status-error-cjhm35, #db0000);
|
|
20479
|
+
line-height: var(--line-height-body-s-0ycq7b, 16px);
|
|
20480
|
+
}
|
|
20481
|
+
`;
|
|
20482
|
+
var CsFileUploadInternal = class extends CsBaseElement {
|
|
20483
|
+
constructor() {
|
|
20484
|
+
super(...arguments);
|
|
20485
|
+
this.value = [];
|
|
20486
|
+
this.multiple = false;
|
|
20487
|
+
this.disabled = false;
|
|
20488
|
+
this.showFileLastModified = false;
|
|
20489
|
+
this.showFileSize = false;
|
|
20490
|
+
this.showFileThumbnail = false;
|
|
20491
|
+
this.errorText = "";
|
|
20492
|
+
this.constraintText = "";
|
|
20493
|
+
this.ariaLabel = null;
|
|
20494
|
+
this.label = "";
|
|
20495
|
+
this.fileTokenAlignment = "vertical";
|
|
20496
|
+
this._thumbnailUrls = /* @__PURE__ */ new Map();
|
|
20497
|
+
this._onFileInputChange = (e) => {
|
|
20498
|
+
const detail = e.detail;
|
|
20499
|
+
if (detail?.value) {
|
|
20500
|
+
const newFiles = this.multiple ? [...this.value, ...detail.value] : [...detail.value];
|
|
20501
|
+
fireNonCancelableEvent(
|
|
20502
|
+
this,
|
|
20503
|
+
"change",
|
|
20504
|
+
{ value: newFiles }
|
|
20505
|
+
);
|
|
20506
|
+
}
|
|
20507
|
+
};
|
|
20508
|
+
}
|
|
20509
|
+
static {
|
|
20510
|
+
this.styles = [sharedStyles, componentStyles55, fileListStyles, hostStyles56];
|
|
20511
|
+
}
|
|
20512
|
+
disconnectedCallback() {
|
|
20513
|
+
super.disconnectedCallback();
|
|
20514
|
+
for (const url of this._thumbnailUrls.values()) {
|
|
20515
|
+
URL.revokeObjectURL(url);
|
|
20516
|
+
}
|
|
20517
|
+
this._thumbnailUrls.clear();
|
|
20518
|
+
}
|
|
20519
|
+
focus(options) {
|
|
20520
|
+
const fileInput = this.shadowRoot?.querySelector("cs-file-input");
|
|
20521
|
+
fileInput?.focus(options);
|
|
20522
|
+
}
|
|
20523
|
+
_onRemoveFile(index) {
|
|
20524
|
+
const removedFile = this.value[index];
|
|
20525
|
+
const newFiles = this.value.filter((_, i) => i !== index);
|
|
20526
|
+
if (removedFile && this._thumbnailUrls.has(removedFile)) {
|
|
20527
|
+
URL.revokeObjectURL(this._thumbnailUrls.get(removedFile));
|
|
20528
|
+
this._thumbnailUrls.delete(removedFile);
|
|
20529
|
+
}
|
|
20530
|
+
fireNonCancelableEvent(
|
|
20531
|
+
this,
|
|
20532
|
+
"change",
|
|
20533
|
+
{ value: newFiles }
|
|
20534
|
+
);
|
|
20535
|
+
}
|
|
20536
|
+
_getThumbnailUrl(file) {
|
|
20537
|
+
if (!this._thumbnailUrls.has(file)) {
|
|
20538
|
+
this._thumbnailUrls.set(file, URL.createObjectURL(file));
|
|
20539
|
+
}
|
|
20540
|
+
return this._thumbnailUrls.get(file);
|
|
20541
|
+
}
|
|
20542
|
+
_formatFileSize(bytes) {
|
|
20543
|
+
if (this.i18nStrings?.formatFileSize) {
|
|
20544
|
+
return this.i18nStrings.formatFileSize(bytes);
|
|
20545
|
+
}
|
|
20546
|
+
if (bytes < 1024) return `${bytes} bytes`;
|
|
20547
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
20548
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
20549
|
+
}
|
|
20550
|
+
_formatLastModified(date) {
|
|
20551
|
+
if (this.i18nStrings?.formatFileLastModified) {
|
|
20552
|
+
return this.i18nStrings.formatFileLastModified(date);
|
|
20553
|
+
}
|
|
20554
|
+
return date.toLocaleDateString();
|
|
20555
|
+
}
|
|
20556
|
+
_getRemoveAriaLabel(index, fileName) {
|
|
20557
|
+
if (this.i18nStrings?.removeFileAriaLabel) {
|
|
20558
|
+
return this.i18nStrings.removeFileAriaLabel(index, fileName);
|
|
20559
|
+
}
|
|
20560
|
+
return `Remove ${fileName}`;
|
|
20561
|
+
}
|
|
20562
|
+
_renderFileItem(file, index) {
|
|
20563
|
+
const error = this.fileErrors?.[index] ?? null;
|
|
20564
|
+
const isImage = file.type.startsWith("image/");
|
|
20565
|
+
const itemClasses = {
|
|
20566
|
+
"file-item": true,
|
|
20567
|
+
"file-item-error": !!error
|
|
20568
|
+
};
|
|
20569
|
+
return html57`
|
|
20570
|
+
<li class=${classMap46(itemClasses)}>
|
|
20571
|
+
${this.showFileThumbnail && isImage ? html57`<img class="file-thumbnail" src=${this._getThumbnailUrl(file)} alt="" />` : nothing30}
|
|
20572
|
+
<div class="file-info">
|
|
20573
|
+
<div class="file-name">${file.name}</div>
|
|
20574
|
+
<div class="file-metadata">
|
|
20575
|
+
${this.showFileSize ? html57`<span>${this._formatFileSize(file.size)}</span>` : nothing30}
|
|
20576
|
+
${this.showFileSize && this.showFileLastModified ? html57`<span> · </span>` : nothing30}
|
|
20577
|
+
${this.showFileLastModified ? html57`<span>${this._formatLastModified(new Date(file.lastModified))}</span>` : nothing30}
|
|
20578
|
+
</div>
|
|
20579
|
+
${error ? html57`<div class="file-error">${error}</div>` : nothing30}
|
|
20580
|
+
</div>
|
|
20581
|
+
<button
|
|
20582
|
+
class="dismiss-button"
|
|
20583
|
+
type="button"
|
|
20584
|
+
aria-label=${this._getRemoveAriaLabel(index, file.name)}
|
|
20585
|
+
@click=${() => this._onRemoveFile(index)}
|
|
20586
|
+
>
|
|
20587
|
+
<cs-icon name="close" size="small"></cs-icon>
|
|
20588
|
+
</button>
|
|
20589
|
+
</li>
|
|
20590
|
+
`;
|
|
20591
|
+
}
|
|
20592
|
+
render() {
|
|
20593
|
+
const hasFiles = this.value.length > 0;
|
|
20594
|
+
const uploadButtonText = this.i18nStrings?.uploadButtonText ? this.i18nStrings.uploadButtonText(this.multiple) : this.multiple ? "Choose files" : "Choose file";
|
|
20595
|
+
const listClasses = {
|
|
20596
|
+
"file-list": true,
|
|
20597
|
+
"file-list-horizontal": this.fileTokenAlignment === "horizontal"
|
|
20598
|
+
};
|
|
20599
|
+
return html57`
|
|
20600
|
+
<div class="file-upload-root">
|
|
20601
|
+
${this.label ? html57`<label class="label">${this.label}</label>` : nothing30}
|
|
20602
|
+
|
|
20603
|
+
<cs-file-input
|
|
20604
|
+
variant="button"
|
|
20605
|
+
accept=${ifDefined28(this.accept || void 0)}
|
|
20606
|
+
?multiple=${this.multiple}
|
|
20607
|
+
?disabled=${this.disabled}
|
|
20608
|
+
aria-label=${this.ariaLabel || uploadButtonText}
|
|
20609
|
+
@change=${this._onFileInputChange}
|
|
20610
|
+
>${uploadButtonText}</cs-file-input>
|
|
20611
|
+
|
|
20612
|
+
${this.constraintText ? html57`<div class="constraint-text hints">${this.constraintText}</div>` : nothing30}
|
|
20613
|
+
|
|
20614
|
+
${this.errorText ? html57`<div class="error-text">${this.errorText}</div>` : nothing30}
|
|
20615
|
+
|
|
20616
|
+
${hasFiles ? html57`
|
|
20617
|
+
<ul class=${classMap46(listClasses)} role="list">
|
|
20618
|
+
${this.value.map((file, i) => this._renderFileItem(file, i))}
|
|
20619
|
+
</ul>
|
|
20620
|
+
` : nothing30}
|
|
20621
|
+
</div>
|
|
20622
|
+
`;
|
|
20623
|
+
}
|
|
20624
|
+
};
|
|
20625
|
+
__decorateClass([
|
|
20626
|
+
property56({ attribute: false })
|
|
20627
|
+
], CsFileUploadInternal.prototype, "value", 2);
|
|
20628
|
+
__decorateClass([
|
|
20629
|
+
property56({ type: String })
|
|
20630
|
+
], CsFileUploadInternal.prototype, "accept", 2);
|
|
20631
|
+
__decorateClass([
|
|
20632
|
+
property56({ type: Boolean, reflect: true })
|
|
20633
|
+
], CsFileUploadInternal.prototype, "multiple", 2);
|
|
20634
|
+
__decorateClass([
|
|
20635
|
+
property56({ type: Boolean, reflect: true })
|
|
20636
|
+
], CsFileUploadInternal.prototype, "disabled", 2);
|
|
20637
|
+
__decorateClass([
|
|
20638
|
+
property56({ type: Boolean })
|
|
20639
|
+
], CsFileUploadInternal.prototype, "showFileLastModified", 2);
|
|
20640
|
+
__decorateClass([
|
|
20641
|
+
property56({ type: Boolean })
|
|
20642
|
+
], CsFileUploadInternal.prototype, "showFileSize", 2);
|
|
20643
|
+
__decorateClass([
|
|
20644
|
+
property56({ type: Boolean })
|
|
20645
|
+
], CsFileUploadInternal.prototype, "showFileThumbnail", 2);
|
|
20646
|
+
__decorateClass([
|
|
20647
|
+
property56({ attribute: false })
|
|
20648
|
+
], CsFileUploadInternal.prototype, "fileErrors", 2);
|
|
20649
|
+
__decorateClass([
|
|
20650
|
+
property56({ type: String })
|
|
20651
|
+
], CsFileUploadInternal.prototype, "errorText", 2);
|
|
20652
|
+
__decorateClass([
|
|
20653
|
+
property56({ type: String })
|
|
20654
|
+
], CsFileUploadInternal.prototype, "constraintText", 2);
|
|
20655
|
+
__decorateClass([
|
|
20656
|
+
property56({ type: String })
|
|
20657
|
+
], CsFileUploadInternal.prototype, "ariaLabel", 2);
|
|
20658
|
+
__decorateClass([
|
|
20659
|
+
property56({ type: String })
|
|
20660
|
+
], CsFileUploadInternal.prototype, "label", 2);
|
|
20661
|
+
__decorateClass([
|
|
20662
|
+
property56({ attribute: false })
|
|
20663
|
+
], CsFileUploadInternal.prototype, "i18nStrings", 2);
|
|
20664
|
+
__decorateClass([
|
|
20665
|
+
property56({ type: String })
|
|
20666
|
+
], CsFileUploadInternal.prototype, "fileTokenAlignment", 2);
|
|
20667
|
+
|
|
20668
|
+
// src/file-upload/index.ts
|
|
20669
|
+
var CsFileUpload = class extends CsFileUploadInternal {
|
|
20670
|
+
};
|
|
20671
|
+
customElements.define("cs-file-upload", CsFileUpload);
|
|
20672
|
+
|
|
20673
|
+
// src/calendar/internal.ts
|
|
20674
|
+
import { css as css126, html as html58, nothing as nothing31 } from "lit";
|
|
20675
|
+
import { property as property57, state as state18 } from "lit/decorators.js";
|
|
20676
|
+
import { classMap as classMap47 } from "lit/directives/class-map.js";
|
|
20677
|
+
import { ifDefined as ifDefined29 } from "lit/directives/if-defined.js";
|
|
20678
|
+
|
|
20679
|
+
// src/calendar/styles.ts
|
|
20680
|
+
import { css as css125 } from "lit";
|
|
20681
|
+
var componentStyles56 = css125`
|
|
20682
|
+
.calendar {
|
|
20683
|
+
animation: awsui_awsui-motion-fade-in-0_1ykar_1p0hg_1 var(--motion-duration-show-quick-tyvnyw, 135ms) var(--motion-easing-show-quick-9hlj8q, ease-out);
|
|
20684
|
+
animation-fill-mode: both;
|
|
20685
|
+
}
|
|
20686
|
+
@keyframes awsui_awsui-motion-fade-in-0_1ykar_1p0hg_1 {
|
|
20687
|
+
from {
|
|
20688
|
+
opacity: 0;
|
|
20689
|
+
}
|
|
20690
|
+
to {
|
|
20691
|
+
opacity: 1;
|
|
20692
|
+
}
|
|
20693
|
+
}
|
|
20694
|
+
@media (prefers-reduced-motion: reduce) {
|
|
20695
|
+
.calendar {
|
|
20696
|
+
animation: none;
|
|
20697
|
+
transition: none;
|
|
20698
|
+
}
|
|
20699
|
+
}
|
|
20700
|
+
.awsui-motion-disabled .calendar, .awsui-mode-entering .calendar {
|
|
20701
|
+
animation: none;
|
|
20702
|
+
transition: none;
|
|
20703
|
+
}
|
|
20704
|
+
|
|
20705
|
+
.calendar {
|
|
20706
|
+
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
20707
|
+
line-height: var(--line-height-body-m-2mh3ke, 20px);
|
|
20708
|
+
color: var(--color-text-body-default-vvtq8u, #0f141a);
|
|
20709
|
+
font-weight: 400;
|
|
20710
|
+
font-family: var(--font-family-base-gmnpzl, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
20711
|
+
-webkit-font-smoothing: auto;
|
|
20712
|
+
-moz-osx-font-smoothing: auto;
|
|
20713
|
+
display: block;
|
|
20714
|
+
inline-size: var(--size-calendar-grid-width-hv3136, 238px);
|
|
20715
|
+
overflow: auto;
|
|
20716
|
+
}
|
|
20717
|
+
.calendar-inner {
|
|
20718
|
+
margin-block: var(--space-xs-ymlm0b, 8px);
|
|
20719
|
+
margin-inline: var(--space-xs-ymlm0b, 8px);
|
|
20720
|
+
}
|
|
20721
|
+
.calendar-header {
|
|
20722
|
+
display: flex;
|
|
20723
|
+
justify-content: space-between;
|
|
20724
|
+
align-items: center;
|
|
20725
|
+
}
|
|
20726
|
+
.calendar-header-title {
|
|
20727
|
+
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
20728
|
+
line-height: var(--line-height-body-m-2mh3ke, 20px);
|
|
20729
|
+
font-weight: 700;
|
|
20730
|
+
color: var(--color-text-dropdown-item-default-f1jr9u, #0f141a);
|
|
20731
|
+
margin-block: 0;
|
|
20732
|
+
margin-inline: 0;
|
|
20733
|
+
}
|
|
20734
|
+
.calendar-next-btn {
|
|
20735
|
+
/* used for identifying element */
|
|
20736
|
+
}
|
|
20737
|
+
.calendar-prev-btn {
|
|
20738
|
+
/* used for identifying element */
|
|
20739
|
+
}
|
|
20740
|
+
.calendar-grid {
|
|
20741
|
+
inline-size: 100%;
|
|
20742
|
+
table-layout: fixed;
|
|
20743
|
+
}
|
|
20744
|
+
.calendar-grid:not(.calendar-grid-dense) {
|
|
20745
|
+
border-spacing: var(--space-calendar-grid-gutter-zojo6r, 6px);
|
|
20746
|
+
padding-block: var(--space-xs-ymlm0b, 8px);
|
|
20747
|
+
padding-inline: var(--space-xs-ymlm0b, 8px);
|
|
20748
|
+
}
|
|
20749
|
+
.calendar-grid-dense {
|
|
20750
|
+
border-spacing: 0;
|
|
20751
|
+
}
|
|
20752
|
+
.calendar-grid-cell {
|
|
20753
|
+
word-break: break-word;
|
|
20754
|
+
text-align: center;
|
|
20755
|
+
font-weight: unset;
|
|
20756
|
+
}
|
|
20757
|
+
.calendar-date-header {
|
|
20758
|
+
padding-block-start: var(--space-s-tvghoh, 12px);
|
|
20759
|
+
padding-block-end: var(--space-xxs-hwfkai, 4px);
|
|
20760
|
+
padding-inline: 0;
|
|
20761
|
+
color: var(--color-text-calendar-month-ea0e93, #656871);
|
|
20762
|
+
font-size: var(--font-size-body-s-smc8cv, 12px);
|
|
20763
|
+
line-height: var(--line-height-body-s-nu5hx1, 16px);
|
|
20764
|
+
letter-spacing: var(--letter-spacing-body-s-gq78ok, 0.005em);
|
|
20765
|
+
}
|
|
20766
|
+
.calendar-date {
|
|
20767
|
+
border-block-end: 1px solid var(--color-border-calendar-grid-67r4w4, transparent);
|
|
20768
|
+
border-inline-end: 1px solid var(--color-border-calendar-grid-67r4w4, transparent);
|
|
20769
|
+
padding-block: var(--space-xxs-hwfkai, 4px);
|
|
20770
|
+
padding-inline: 0;
|
|
20771
|
+
color: var(--color-text-dropdown-item-disabled-8m65hf, #b4b4bb);
|
|
20772
|
+
position: relative;
|
|
20773
|
+
}
|
|
20774
|
+
.calendar-date:first-child {
|
|
20775
|
+
border-inline-start: 1px solid var(--color-border-calendar-grid-67r4w4, transparent);
|
|
20776
|
+
}
|
|
20777
|
+
.calendar-date-enabled {
|
|
20778
|
+
cursor: pointer;
|
|
20779
|
+
color: var(--color-text-dropdown-item-secondary-v12lfh, #656871);
|
|
20780
|
+
}
|
|
20781
|
+
.calendar-date-enabled::after {
|
|
20782
|
+
border-start-start-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20783
|
+
border-start-end-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20784
|
+
border-end-start-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20785
|
+
border-end-end-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20786
|
+
}
|
|
20787
|
+
.calendar-date-enabled.calendar-date-current-page {
|
|
20788
|
+
color: var(--color-text-dropdown-item-default-f1jr9u, #0f141a);
|
|
20789
|
+
}
|
|
20790
|
+
.calendar-date-enabled.calendar-date-current-page:hover {
|
|
20791
|
+
border-start-start-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20792
|
+
border-start-end-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20793
|
+
border-end-start-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20794
|
+
border-end-end-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20795
|
+
color: var(--color-text-calendar-date-hover-3fcriv, #0f141a);
|
|
20796
|
+
background-color: var(--color-background-dropdown-item-hover-yunepc, #f3f3f7);
|
|
20797
|
+
}
|
|
20798
|
+
.calendar-date-enabled.calendar-date-current-page:hover:not(.calendar-date-selected)::after {
|
|
20799
|
+
border-block: var(--border-item-width-miijiw, 2px) solid var(--color-border-dropdown-item-hover-aqfuxq, #8c8c94);
|
|
20800
|
+
border-inline: var(--border-item-width-miijiw, 2px) solid var(--color-border-dropdown-item-hover-aqfuxq, #8c8c94);
|
|
20801
|
+
}
|
|
20802
|
+
.calendar-date-current {
|
|
20803
|
+
border-start-start-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20804
|
+
border-start-end-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20805
|
+
border-end-start-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20806
|
+
border-end-end-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20807
|
+
background-color: var(--color-background-calendar-current-date-sk0f6i, #f3f3f7);
|
|
20808
|
+
font-weight: 700;
|
|
20809
|
+
}
|
|
20810
|
+
.calendar-date::after {
|
|
20811
|
+
content: "";
|
|
20812
|
+
position: absolute;
|
|
20813
|
+
z-index: 1;
|
|
20814
|
+
background-color: transparent;
|
|
20815
|
+
inset-block-start: calc(-1 * var(--border-item-width-miijiw, 2px));
|
|
20816
|
+
inset-inline-start: calc(-1 * var(--border-item-width-miijiw, 2px));
|
|
20817
|
+
inset-inline-end: calc(-1 * var(--border-item-width-miijiw, 2px));
|
|
20818
|
+
}
|
|
20819
|
+
.calendar-date:not(.calendar-date-dense)::after {
|
|
20820
|
+
inset-block-end: calc(-1 * var(--border-item-width-miijiw, 2px));
|
|
20821
|
+
inset-inline-start: calc(-1 * var(--border-item-width-miijiw, 2px));
|
|
20822
|
+
}
|
|
20823
|
+
.calendar-date-dense::after {
|
|
20824
|
+
inset-block-end: -1px;
|
|
20825
|
+
inset-inline-start: -1px;
|
|
20826
|
+
}
|
|
20827
|
+
.calendar-date > .date-inner {
|
|
20828
|
+
position: relative;
|
|
20829
|
+
z-index: 1;
|
|
20830
|
+
}
|
|
20831
|
+
.calendar-date:focus {
|
|
20832
|
+
outline: none;
|
|
20833
|
+
}
|
|
20834
|
+
:host-context([data-awsui-focus-visible=true]) .calendar-date:focus:focus {
|
|
20835
|
+
position: relative;
|
|
20836
|
+
}
|
|
20837
|
+
:host-context([data-awsui-focus-visible=true]) .calendar-date:focus:focus {
|
|
20838
|
+
outline: 2px dotted transparent;
|
|
20839
|
+
outline-offset: calc(var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px) - 1px);
|
|
20840
|
+
}
|
|
20841
|
+
:host-context([data-awsui-focus-visible=true]) .calendar-date:focus:focus::before {
|
|
20842
|
+
content: " ";
|
|
20843
|
+
display: block;
|
|
20844
|
+
position: absolute;
|
|
20845
|
+
inset-inline-start: calc(-1 * var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px));
|
|
20846
|
+
inset-block-start: calc(-1 * var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px));
|
|
20847
|
+
inline-size: calc(100% + var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px) + var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px));
|
|
20848
|
+
block-size: calc(100% + var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px) + var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px));
|
|
20849
|
+
border-start-start-radius: var(--border-radius-calendar-day-focus-ring-xvvbuc, 3px);
|
|
20850
|
+
border-start-end-radius: var(--border-radius-calendar-day-focus-ring-xvvbuc, 3px);
|
|
20851
|
+
border-end-start-radius: var(--border-radius-calendar-day-focus-ring-xvvbuc, 3px);
|
|
20852
|
+
border-end-end-radius: var(--border-radius-calendar-day-focus-ring-xvvbuc, 3px);
|
|
20853
|
+
box-shadow: 0 0 0 2px var(--color-border-item-focused-uk47pl, #006ce0);
|
|
20854
|
+
}
|
|
20855
|
+
:host-context([data-awsui-focus-visible=true]) .calendar-date:focus:focus::before {
|
|
20856
|
+
z-index: 2;
|
|
20857
|
+
}
|
|
20858
|
+
.calendar-date-selected {
|
|
20859
|
+
border-color: transparent;
|
|
20860
|
+
position: relative;
|
|
20861
|
+
z-index: 2;
|
|
20862
|
+
font-weight: 700;
|
|
20863
|
+
}
|
|
20864
|
+
:host-context([data-awsui-focus-visible=true]) .calendar-date-selected:focus:focus {
|
|
20865
|
+
position: relative;
|
|
20866
|
+
}
|
|
20867
|
+
:host-context([data-awsui-focus-visible=true]) .calendar-date-selected:focus:focus {
|
|
20868
|
+
outline: 2px dotted transparent;
|
|
20869
|
+
outline-offset: calc(var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px) - 1px);
|
|
20870
|
+
}
|
|
20871
|
+
:host-context([data-awsui-focus-visible=true]) .calendar-date-selected:focus:focus::before {
|
|
20872
|
+
content: " ";
|
|
20873
|
+
display: block;
|
|
20874
|
+
position: absolute;
|
|
20875
|
+
inset-inline-start: calc(-1 * var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px));
|
|
20876
|
+
inset-block-start: calc(-1 * var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px));
|
|
20877
|
+
inline-size: calc(100% + var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px) + var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px));
|
|
20878
|
+
block-size: calc(100% + var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px) + var(--space-calendar-grid-focus-outline-gutter-vvh43m, -5px));
|
|
20879
|
+
border-start-start-radius: var(--border-radius-calendar-day-focus-ring-xvvbuc, 3px);
|
|
20880
|
+
border-start-end-radius: var(--border-radius-calendar-day-focus-ring-xvvbuc, 3px);
|
|
20881
|
+
border-end-start-radius: var(--border-radius-calendar-day-focus-ring-xvvbuc, 3px);
|
|
20882
|
+
border-end-end-radius: var(--border-radius-calendar-day-focus-ring-xvvbuc, 3px);
|
|
20883
|
+
box-shadow: 0 0 0 2px var(--color-border-calendar-grid-selected-focus-ring-jk1fb0, #f9f9fa);
|
|
20884
|
+
}
|
|
20885
|
+
:host-context([data-awsui-focus-visible=true]) .calendar-date-selected:focus:focus::before {
|
|
20886
|
+
z-index: 2;
|
|
20887
|
+
}
|
|
20888
|
+
.calendar-date-selected::after {
|
|
20889
|
+
border-start-start-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20890
|
+
border-start-end-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20891
|
+
border-end-start-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20892
|
+
border-end-end-radius: var(--border-radius-item-iwaia5, 8px);
|
|
20893
|
+
background-color: var(--color-background-control-checked-ka7kc2, #006ce0);
|
|
20894
|
+
border-block: var(--border-item-width-miijiw, 2px) solid var(--color-background-control-checked-ka7kc2, #006ce0);
|
|
20895
|
+
border-inline: var(--border-item-width-miijiw, 2px) solid var(--color-background-control-checked-ka7kc2, #006ce0);
|
|
20896
|
+
}
|
|
20897
|
+
.calendar-date-selected > .date-inner {
|
|
20898
|
+
z-index: 2;
|
|
20899
|
+
color: var(--color-background-control-default-4jb21l, #ffffff);
|
|
20900
|
+
position: relative;
|
|
20901
|
+
}
|
|
20902
|
+
.calendar-row:first-child > .calendar-date {
|
|
20903
|
+
border-block-start: 1px solid var(--color-border-calendar-grid-67r4w4, transparent);
|
|
20904
|
+
}
|
|
20905
|
+
|
|
20906
|
+
.disabled-reason-tooltip {
|
|
20907
|
+
/* used in test-utils or tests */
|
|
20908
|
+
}
|
|
20909
|
+
`;
|
|
20910
|
+
|
|
20911
|
+
// src/calendar/internal.ts
|
|
20912
|
+
var hostStyles57 = css126`:host { display: block; }`;
|
|
20913
|
+
function pad2(n) {
|
|
20914
|
+
return String(n).padStart(2, "0");
|
|
20915
|
+
}
|
|
20916
|
+
function toISODate(d) {
|
|
20917
|
+
return `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
|
|
20918
|
+
}
|
|
20919
|
+
function todayISO() {
|
|
20920
|
+
return toISODate(/* @__PURE__ */ new Date());
|
|
20921
|
+
}
|
|
20922
|
+
var CsCalendarInternal = class extends CsBaseElement {
|
|
20923
|
+
constructor() {
|
|
20924
|
+
super(...arguments);
|
|
20925
|
+
this.value = "";
|
|
20926
|
+
this.locale = "en-US";
|
|
20927
|
+
this.startOfWeek = 0;
|
|
20928
|
+
this.granularity = "day";
|
|
20929
|
+
this.ariaLabel = null;
|
|
20930
|
+
this.ariaLabelledby = null;
|
|
20931
|
+
this.ariaDescribedby = null;
|
|
20932
|
+
this._displayedMonth = (/* @__PURE__ */ new Date()).getMonth();
|
|
20933
|
+
this._displayedYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
20934
|
+
this._focusedDate = "";
|
|
20935
|
+
this._onPrevClick = (e) => {
|
|
20936
|
+
if (!(e instanceof CustomEvent)) return;
|
|
20937
|
+
this._onPrevMonth();
|
|
20938
|
+
};
|
|
20939
|
+
this._onNextClick = (e) => {
|
|
20940
|
+
if (!(e instanceof CustomEvent)) return;
|
|
20941
|
+
this._onNextMonth();
|
|
20942
|
+
};
|
|
20943
|
+
this._onGridKeyDown = (e) => {
|
|
20944
|
+
let focused = this._focusedDate || this.value;
|
|
20945
|
+
if (!focused) {
|
|
20946
|
+
focused = `${this._displayedYear}-${pad2(this._displayedMonth + 1)}-01`;
|
|
20947
|
+
}
|
|
20948
|
+
const [y, m, d] = focused.split("-").map(Number);
|
|
20949
|
+
const date = new Date(y, m - 1, d);
|
|
20950
|
+
let handled = true;
|
|
20951
|
+
switch (e.key) {
|
|
20952
|
+
case "ArrowLeft":
|
|
20953
|
+
date.setDate(date.getDate() - 1);
|
|
20954
|
+
break;
|
|
20955
|
+
case "ArrowRight":
|
|
20956
|
+
date.setDate(date.getDate() + 1);
|
|
20957
|
+
break;
|
|
20958
|
+
case "ArrowUp":
|
|
20959
|
+
date.setDate(date.getDate() - 7);
|
|
20960
|
+
break;
|
|
20961
|
+
case "ArrowDown":
|
|
20962
|
+
date.setDate(date.getDate() + 7);
|
|
20963
|
+
break;
|
|
20964
|
+
case "PageUp":
|
|
20965
|
+
if (e.shiftKey) {
|
|
20966
|
+
date.setFullYear(date.getFullYear() - 1);
|
|
20967
|
+
} else {
|
|
20968
|
+
date.setMonth(date.getMonth() - 1);
|
|
20969
|
+
}
|
|
20970
|
+
break;
|
|
20971
|
+
case "PageDown":
|
|
20972
|
+
if (e.shiftKey) {
|
|
20973
|
+
date.setFullYear(date.getFullYear() + 1);
|
|
20974
|
+
} else {
|
|
20975
|
+
date.setMonth(date.getMonth() + 1);
|
|
20976
|
+
}
|
|
20977
|
+
break;
|
|
20978
|
+
case "Enter":
|
|
20979
|
+
case " ":
|
|
20980
|
+
e.preventDefault();
|
|
20981
|
+
this._selectDate(focused);
|
|
20982
|
+
return;
|
|
20983
|
+
default:
|
|
20984
|
+
handled = false;
|
|
20985
|
+
}
|
|
20986
|
+
if (handled) {
|
|
20987
|
+
e.preventDefault();
|
|
20988
|
+
const newDate = toISODate(date);
|
|
20989
|
+
this._focusedDate = newDate;
|
|
20990
|
+
this._displayedMonth = date.getMonth();
|
|
20991
|
+
this._displayedYear = date.getFullYear();
|
|
20992
|
+
this.updateComplete.then(() => {
|
|
20993
|
+
const cell = this.shadowRoot?.querySelector(
|
|
20994
|
+
`[data-date="${newDate}"]`
|
|
20995
|
+
);
|
|
20996
|
+
cell?.focus();
|
|
20997
|
+
});
|
|
20998
|
+
}
|
|
20999
|
+
};
|
|
21000
|
+
}
|
|
21001
|
+
static {
|
|
21002
|
+
this.styles = [sharedStyles, componentStyles56, hostStyles57];
|
|
21003
|
+
}
|
|
21004
|
+
willUpdate(changed) {
|
|
21005
|
+
super.willUpdate(changed);
|
|
21006
|
+
if (changed.has("value") && this.value) {
|
|
21007
|
+
const parts = this.value.split("-");
|
|
21008
|
+
if (parts.length >= 2) {
|
|
21009
|
+
const year = parseInt(parts[0], 10);
|
|
21010
|
+
const month = parseInt(parts[1], 10) - 1;
|
|
21011
|
+
if (!isNaN(year) && !isNaN(month)) {
|
|
21012
|
+
this._displayedYear = year;
|
|
21013
|
+
this._displayedMonth = month;
|
|
21014
|
+
}
|
|
21015
|
+
}
|
|
21016
|
+
}
|
|
21017
|
+
}
|
|
21018
|
+
_getMonthTitle() {
|
|
21019
|
+
const date = new Date(this._displayedYear, this._displayedMonth, 1);
|
|
21020
|
+
return new Intl.DateTimeFormat(this.locale, {
|
|
21021
|
+
month: "long",
|
|
21022
|
+
year: "numeric"
|
|
21023
|
+
}).format(date);
|
|
21024
|
+
}
|
|
21025
|
+
_getDayNames() {
|
|
21026
|
+
const formatter = new Intl.DateTimeFormat(this.locale, { weekday: "short" });
|
|
21027
|
+
const names = [];
|
|
21028
|
+
for (let i = 0; i < 7; i++) {
|
|
21029
|
+
const dayIndex = (this.startOfWeek + i) % 7;
|
|
21030
|
+
const date = new Date(2017, 0, 1 + dayIndex);
|
|
21031
|
+
names.push(formatter.format(date));
|
|
21032
|
+
}
|
|
21033
|
+
return names;
|
|
21034
|
+
}
|
|
21035
|
+
_getCalendarWeeks() {
|
|
21036
|
+
const year = this._displayedYear;
|
|
21037
|
+
const month = this._displayedMonth;
|
|
21038
|
+
const firstOfMonth = new Date(year, month, 1);
|
|
21039
|
+
const today = todayISO();
|
|
21040
|
+
let startOffset = firstOfMonth.getDay() - this.startOfWeek;
|
|
21041
|
+
if (startOffset < 0) startOffset += 7;
|
|
21042
|
+
const weeks = [];
|
|
21043
|
+
const cursor = new Date(year, month, 1 - startOffset);
|
|
21044
|
+
for (let w = 0; w < 6; w++) {
|
|
21045
|
+
const days = [];
|
|
21046
|
+
for (let d = 0; d < 7; d++) {
|
|
21047
|
+
const dateStr = toISODate(cursor);
|
|
21048
|
+
days.push({
|
|
21049
|
+
date: dateStr,
|
|
21050
|
+
day: cursor.getDate(),
|
|
21051
|
+
currentMonth: cursor.getMonth() === month,
|
|
21052
|
+
today: dateStr === today
|
|
21053
|
+
});
|
|
21054
|
+
cursor.setDate(cursor.getDate() + 1);
|
|
21055
|
+
}
|
|
21056
|
+
weeks.push(days);
|
|
21057
|
+
}
|
|
21058
|
+
return weeks;
|
|
21059
|
+
}
|
|
21060
|
+
_isEnabled(dateStr) {
|
|
21061
|
+
if (!this.isDateEnabled) return true;
|
|
21062
|
+
const [y, m, d] = dateStr.split("-").map(Number);
|
|
21063
|
+
return this.isDateEnabled(new Date(y, m - 1, d));
|
|
21064
|
+
}
|
|
21065
|
+
_onPrevMonth() {
|
|
21066
|
+
if (this._displayedMonth === 0) {
|
|
21067
|
+
this._displayedMonth = 11;
|
|
21068
|
+
this._displayedYear--;
|
|
21069
|
+
} else {
|
|
21070
|
+
this._displayedMonth--;
|
|
21071
|
+
}
|
|
21072
|
+
}
|
|
21073
|
+
_onNextMonth() {
|
|
21074
|
+
if (this._displayedMonth === 11) {
|
|
21075
|
+
this._displayedMonth = 0;
|
|
21076
|
+
this._displayedYear++;
|
|
21077
|
+
} else {
|
|
21078
|
+
this._displayedMonth++;
|
|
21079
|
+
}
|
|
21080
|
+
}
|
|
21081
|
+
_selectDate(dateStr) {
|
|
21082
|
+
if (!this._isEnabled(dateStr)) return;
|
|
21083
|
+
this.value = dateStr;
|
|
21084
|
+
fireNonCancelableEvent(
|
|
21085
|
+
this,
|
|
21086
|
+
"change",
|
|
21087
|
+
{ value: dateStr }
|
|
21088
|
+
);
|
|
21089
|
+
}
|
|
21090
|
+
_onDateClick(dateStr) {
|
|
21091
|
+
this._selectDate(dateStr);
|
|
21092
|
+
}
|
|
21093
|
+
_getTabIndex(day) {
|
|
21094
|
+
if (day.date === this.value) return 0;
|
|
21095
|
+
if (day.date === this._focusedDate) return 0;
|
|
21096
|
+
if (!this.value && !this._focusedDate && day.today && day.currentMonth)
|
|
21097
|
+
return 0;
|
|
21098
|
+
return -1;
|
|
21099
|
+
}
|
|
21100
|
+
render() {
|
|
21101
|
+
const weeks = this._getCalendarWeeks();
|
|
21102
|
+
const dayNames = this._getDayNames();
|
|
21103
|
+
const monthTitle = this._getMonthTitle();
|
|
21104
|
+
const prevLabel = this.i18nStrings?.previousMonthAriaLabel ?? "Previous month";
|
|
21105
|
+
const nextLabel = this.i18nStrings?.nextMonthAriaLabel ?? "Next month";
|
|
21106
|
+
return html58`
|
|
21107
|
+
<div
|
|
21108
|
+
class="calendar"
|
|
21109
|
+
role="group"
|
|
21110
|
+
aria-label=${ifDefined29(this.ariaLabel || void 0)}
|
|
21111
|
+
aria-labelledby=${ifDefined29(
|
|
21112
|
+
!this.ariaLabel ? this.ariaLabelledby || void 0 : void 0
|
|
21113
|
+
)}
|
|
21114
|
+
aria-describedby=${ifDefined29(this.ariaDescribedby || void 0)}
|
|
21115
|
+
>
|
|
21116
|
+
<div class="calendar-inner">
|
|
21117
|
+
<div class="calendar-header">
|
|
21118
|
+
<cs-button
|
|
21119
|
+
class="calendar-prev-btn"
|
|
21120
|
+
variant="icon"
|
|
21121
|
+
icon-name="angle-left"
|
|
21122
|
+
aria-label=${prevLabel}
|
|
21123
|
+
@click=${this._onPrevClick}
|
|
21124
|
+
></cs-button>
|
|
21125
|
+
<span class="calendar-header-title">${monthTitle}</span>
|
|
21126
|
+
<cs-button
|
|
21127
|
+
class="calendar-next-btn"
|
|
21128
|
+
variant="icon"
|
|
21129
|
+
icon-name="angle-right"
|
|
21130
|
+
aria-label=${nextLabel}
|
|
21131
|
+
@click=${this._onNextClick}
|
|
21132
|
+
></cs-button>
|
|
21133
|
+
</div>
|
|
21134
|
+
<table
|
|
21135
|
+
class="calendar-grid"
|
|
21136
|
+
role="grid"
|
|
21137
|
+
@keydown=${this._onGridKeyDown}
|
|
21138
|
+
>
|
|
21139
|
+
<thead>
|
|
21140
|
+
<tr>
|
|
21141
|
+
${dayNames.map(
|
|
21142
|
+
(name) => html58`
|
|
21143
|
+
<th class="calendar-grid-cell calendar-date-header" scope="col">
|
|
21144
|
+
${name}
|
|
21145
|
+
</th>
|
|
21146
|
+
`
|
|
21147
|
+
)}
|
|
21148
|
+
</tr>
|
|
21149
|
+
</thead>
|
|
21150
|
+
<tbody>
|
|
21151
|
+
${weeks.map(
|
|
21152
|
+
(week) => html58`
|
|
21153
|
+
<tr class="calendar-row">
|
|
21154
|
+
${week.map((day) => {
|
|
21155
|
+
const isSelected = day.date === this.value;
|
|
21156
|
+
const isEnabled = day.currentMonth && this._isEnabled(day.date);
|
|
21157
|
+
const classes = {
|
|
21158
|
+
"calendar-date": true,
|
|
21159
|
+
"calendar-date-current-page": day.currentMonth,
|
|
21160
|
+
"calendar-date-current": day.today,
|
|
21161
|
+
"calendar-date-selected": isSelected,
|
|
21162
|
+
"calendar-date-enabled": isEnabled
|
|
21163
|
+
};
|
|
21164
|
+
return html58`
|
|
21165
|
+
<td
|
|
21166
|
+
class=${classMap47(classes)}
|
|
21167
|
+
role="gridcell"
|
|
21168
|
+
tabindex=${this._getTabIndex(day)}
|
|
21169
|
+
aria-selected=${isSelected ? "true" : "false"}
|
|
21170
|
+
aria-disabled=${!isEnabled ? "true" : nothing31}
|
|
21171
|
+
data-date=${day.date}
|
|
21172
|
+
@click=${() => this._onDateClick(day.date)}
|
|
21173
|
+
>
|
|
21174
|
+
<span class="date-inner">${day.day}</span>
|
|
21175
|
+
</td>
|
|
21176
|
+
`;
|
|
21177
|
+
})}
|
|
21178
|
+
</tr>
|
|
21179
|
+
`
|
|
21180
|
+
)}
|
|
21181
|
+
</tbody>
|
|
21182
|
+
</table>
|
|
21183
|
+
</div>
|
|
21184
|
+
</div>
|
|
21185
|
+
`;
|
|
21186
|
+
}
|
|
21187
|
+
};
|
|
21188
|
+
__decorateClass([
|
|
21189
|
+
property57({ type: String })
|
|
21190
|
+
], CsCalendarInternal.prototype, "value", 2);
|
|
21191
|
+
__decorateClass([
|
|
21192
|
+
property57({ type: String })
|
|
21193
|
+
], CsCalendarInternal.prototype, "locale", 2);
|
|
21194
|
+
__decorateClass([
|
|
21195
|
+
property57({ type: Number })
|
|
21196
|
+
], CsCalendarInternal.prototype, "startOfWeek", 2);
|
|
21197
|
+
__decorateClass([
|
|
21198
|
+
property57({ type: String })
|
|
21199
|
+
], CsCalendarInternal.prototype, "granularity", 2);
|
|
21200
|
+
__decorateClass([
|
|
21201
|
+
property57({ attribute: false })
|
|
21202
|
+
], CsCalendarInternal.prototype, "isDateEnabled", 2);
|
|
21203
|
+
__decorateClass([
|
|
21204
|
+
property57({ attribute: false })
|
|
21205
|
+
], CsCalendarInternal.prototype, "dateDisabledReason", 2);
|
|
21206
|
+
__decorateClass([
|
|
21207
|
+
property57({ type: String })
|
|
21208
|
+
], CsCalendarInternal.prototype, "ariaLabel", 2);
|
|
21209
|
+
__decorateClass([
|
|
21210
|
+
property57({ type: String })
|
|
21211
|
+
], CsCalendarInternal.prototype, "ariaLabelledby", 2);
|
|
21212
|
+
__decorateClass([
|
|
21213
|
+
property57({ type: String })
|
|
21214
|
+
], CsCalendarInternal.prototype, "ariaDescribedby", 2);
|
|
21215
|
+
__decorateClass([
|
|
21216
|
+
property57({ attribute: false })
|
|
21217
|
+
], CsCalendarInternal.prototype, "i18nStrings", 2);
|
|
21218
|
+
__decorateClass([
|
|
21219
|
+
state18()
|
|
21220
|
+
], CsCalendarInternal.prototype, "_displayedMonth", 2);
|
|
21221
|
+
__decorateClass([
|
|
21222
|
+
state18()
|
|
21223
|
+
], CsCalendarInternal.prototype, "_displayedYear", 2);
|
|
21224
|
+
__decorateClass([
|
|
21225
|
+
state18()
|
|
21226
|
+
], CsCalendarInternal.prototype, "_focusedDate", 2);
|
|
21227
|
+
|
|
21228
|
+
// src/calendar/index.ts
|
|
21229
|
+
var CsCalendar = class extends CsCalendarInternal {
|
|
21230
|
+
};
|
|
21231
|
+
customElements.define("cs-calendar", CsCalendar);
|
|
21232
|
+
|
|
21233
|
+
// src/date-input/internal.ts
|
|
21234
|
+
import { css as css128, html as html59 } from "lit";
|
|
21235
|
+
import { property as property58 } from "lit/decorators.js";
|
|
21236
|
+
import { classMap as classMap48 } from "lit/directives/class-map.js";
|
|
21237
|
+
import { ifDefined as ifDefined30 } from "lit/directives/if-defined.js";
|
|
21238
|
+
import { consume as consume2 } from "@lit/context";
|
|
21239
|
+
|
|
21240
|
+
// src/date-input/styles.ts
|
|
21241
|
+
import { css as css127 } from "lit";
|
|
21242
|
+
var componentStyles57 = css127`
|
|
21243
|
+
|
|
21244
|
+
`;
|
|
21245
|
+
|
|
21246
|
+
// src/date-input/internal.ts
|
|
21247
|
+
var Base9 = FormAssociatedMixin(CsBaseElement);
|
|
21248
|
+
var hostStyles58 = css128`:host { display: block; }`;
|
|
21249
|
+
var CsDateInputInternal = class extends Base9 {
|
|
21250
|
+
constructor() {
|
|
21251
|
+
super(...arguments);
|
|
21252
|
+
this._formFieldCtx = defaultFormFieldContext;
|
|
21253
|
+
this.value = "";
|
|
21254
|
+
this.placeholder = "YYYY/MM/DD";
|
|
21255
|
+
this.readOnly = false;
|
|
21256
|
+
this.invalid = false;
|
|
21257
|
+
this.warning = false;
|
|
21258
|
+
this.autoFocus = false;
|
|
21259
|
+
this.ariaLabel = null;
|
|
21260
|
+
this.ariaDescribedby = null;
|
|
21261
|
+
this._onInput = (e) => {
|
|
21262
|
+
const target = e.target;
|
|
21263
|
+
this.value = target.value;
|
|
21264
|
+
fireNonCancelableEvent(
|
|
21265
|
+
this,
|
|
21266
|
+
"change",
|
|
21267
|
+
{ value: this.value }
|
|
21268
|
+
);
|
|
21269
|
+
};
|
|
21270
|
+
this._onBlur = () => {
|
|
21271
|
+
fireNonCancelableEvent(this, "blur", null);
|
|
21272
|
+
};
|
|
21273
|
+
this._onFocus = () => {
|
|
21274
|
+
fireNonCancelableEvent(this, "focus", null);
|
|
21275
|
+
};
|
|
21276
|
+
}
|
|
21277
|
+
static {
|
|
21278
|
+
this.styles = [sharedStyles, componentStyles57, hostStyles58];
|
|
21279
|
+
}
|
|
21280
|
+
focus(options) {
|
|
21281
|
+
this._getInput()?.focus(options);
|
|
21282
|
+
}
|
|
21283
|
+
select() {
|
|
21284
|
+
this._getInput()?.select();
|
|
21285
|
+
}
|
|
21286
|
+
_getInput() {
|
|
21287
|
+
return this.shadowRoot?.querySelector("input");
|
|
21288
|
+
}
|
|
21289
|
+
get _isInvalid() {
|
|
21290
|
+
return this.invalid || this._formFieldCtx.invalid;
|
|
21291
|
+
}
|
|
21292
|
+
get _isWarning() {
|
|
21293
|
+
return (this.warning || this._formFieldCtx.warning) && !this._isInvalid;
|
|
21294
|
+
}
|
|
21295
|
+
get _resolvedAriaDescribedby() {
|
|
21296
|
+
const parts = [];
|
|
21297
|
+
if (this.ariaDescribedby) parts.push(this.ariaDescribedby);
|
|
21298
|
+
if (this._formFieldCtx.ariaDescribedby)
|
|
21299
|
+
parts.push(this._formFieldCtx.ariaDescribedby);
|
|
21300
|
+
return parts.length ? parts.join(" ") : void 0;
|
|
21301
|
+
}
|
|
21302
|
+
render() {
|
|
21303
|
+
const inputClasses = {
|
|
21304
|
+
input: true,
|
|
21305
|
+
"input-readonly": this.readOnly,
|
|
21306
|
+
"input-invalid": this._isInvalid,
|
|
21307
|
+
"input-warning": this._isWarning,
|
|
21308
|
+
"input-disabled": this.disabled,
|
|
21309
|
+
"input-type-text": true
|
|
21310
|
+
};
|
|
21311
|
+
const controlId = this._formFieldCtx.controlId || void 0;
|
|
21312
|
+
const ariaLabelledby = this._formFieldCtx.ariaLabelledby || void 0;
|
|
21313
|
+
return html59`
|
|
21314
|
+
<div class="root">
|
|
21315
|
+
<div class="input-container">
|
|
21316
|
+
<input
|
|
21317
|
+
class=${classMap48(inputClasses)}
|
|
21318
|
+
type="text"
|
|
21319
|
+
.value=${this.value}
|
|
21320
|
+
placeholder=${ifDefined30(this.placeholder || void 0)}
|
|
21321
|
+
?disabled=${this.disabled}
|
|
21322
|
+
?readonly=${this.readOnly}
|
|
21323
|
+
?autofocus=${this.autoFocus}
|
|
21324
|
+
id=${ifDefined30(controlId)}
|
|
21325
|
+
aria-label=${ifDefined30(this.ariaLabel || void 0)}
|
|
21326
|
+
aria-labelledby=${ifDefined30(
|
|
21327
|
+
!this.ariaLabel ? ariaLabelledby : void 0
|
|
21328
|
+
)}
|
|
21329
|
+
aria-describedby=${ifDefined30(this._resolvedAriaDescribedby)}
|
|
21330
|
+
aria-invalid=${ifDefined30(this._isInvalid ? "true" : void 0)}
|
|
21331
|
+
@input=${this._onInput}
|
|
21332
|
+
@blur=${this._onBlur}
|
|
21333
|
+
@focus=${this._onFocus}
|
|
21334
|
+
/>
|
|
21335
|
+
</div>
|
|
21336
|
+
</div>
|
|
21337
|
+
`;
|
|
21338
|
+
}
|
|
21339
|
+
};
|
|
21340
|
+
__decorateClass([
|
|
21341
|
+
consume2({ context: formFieldContext, subscribe: true })
|
|
21342
|
+
], CsDateInputInternal.prototype, "_formFieldCtx", 2);
|
|
21343
|
+
__decorateClass([
|
|
21344
|
+
property58({ type: String })
|
|
21345
|
+
], CsDateInputInternal.prototype, "value", 2);
|
|
21346
|
+
__decorateClass([
|
|
21347
|
+
property58({ type: String })
|
|
21348
|
+
], CsDateInputInternal.prototype, "placeholder", 2);
|
|
21349
|
+
__decorateClass([
|
|
21350
|
+
property58({ type: Boolean, reflect: true })
|
|
21351
|
+
], CsDateInputInternal.prototype, "readOnly", 2);
|
|
21352
|
+
__decorateClass([
|
|
21353
|
+
property58({ type: Boolean, reflect: true })
|
|
21354
|
+
], CsDateInputInternal.prototype, "invalid", 2);
|
|
21355
|
+
__decorateClass([
|
|
21356
|
+
property58({ type: Boolean, reflect: true })
|
|
21357
|
+
], CsDateInputInternal.prototype, "warning", 2);
|
|
21358
|
+
__decorateClass([
|
|
21359
|
+
property58({ type: Boolean })
|
|
21360
|
+
], CsDateInputInternal.prototype, "autoFocus", 2);
|
|
21361
|
+
__decorateClass([
|
|
21362
|
+
property58({ type: String })
|
|
21363
|
+
], CsDateInputInternal.prototype, "ariaLabel", 2);
|
|
21364
|
+
__decorateClass([
|
|
21365
|
+
property58({ type: String })
|
|
21366
|
+
], CsDateInputInternal.prototype, "ariaDescribedby", 2);
|
|
21367
|
+
|
|
21368
|
+
// src/date-input/index.ts
|
|
21369
|
+
var CsDateInput = class extends CsDateInputInternal {
|
|
21370
|
+
};
|
|
21371
|
+
customElements.define("cs-date-input", CsDateInput);
|
|
21372
|
+
|
|
21373
|
+
// src/date-picker/internal.ts
|
|
21374
|
+
import { css as css130, html as html60, nothing as nothing32 } from "lit";
|
|
21375
|
+
import { property as property59, state as state19, query as query7 } from "lit/decorators.js";
|
|
21376
|
+
import { ifDefined as ifDefined31 } from "lit/directives/if-defined.js";
|
|
21377
|
+
import { consume as consume3 } from "@lit/context";
|
|
21378
|
+
|
|
21379
|
+
// src/date-picker/styles.ts
|
|
21380
|
+
import { css as css129 } from "lit";
|
|
21381
|
+
var componentStyles58 = css129`
|
|
21382
|
+
.root {
|
|
21383
|
+
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
21384
|
+
line-height: var(--line-height-body-m-2mh3ke, 20px);
|
|
21385
|
+
color: var(--color-text-body-default-vvtq8u, #0f141a);
|
|
21386
|
+
font-weight: 400;
|
|
21387
|
+
font-family: var(--font-family-base-gmnpzl, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
21388
|
+
-webkit-font-smoothing: auto;
|
|
21389
|
+
-moz-osx-font-smoothing: auto;
|
|
21390
|
+
}
|
|
21391
|
+
|
|
21392
|
+
.focus-lock {
|
|
21393
|
+
display: contents;
|
|
21394
|
+
}
|
|
21395
|
+
|
|
21396
|
+
.calendar {
|
|
21397
|
+
overflow: auto;
|
|
21398
|
+
}
|
|
21399
|
+
.calendar:focus {
|
|
21400
|
+
outline: none;
|
|
21401
|
+
}
|
|
21402
|
+
:host-context([data-awsui-focus-visible=true]) .calendar:focus {
|
|
21403
|
+
outline: 2px dotted transparent;
|
|
21404
|
+
outline-offset: 2px;
|
|
21405
|
+
border-start-start-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21406
|
+
border-start-end-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21407
|
+
border-end-start-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21408
|
+
border-end-end-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21409
|
+
box-shadow: 0 0 0 2px var(--color-border-item-focused-uk47pl, #006ce0);
|
|
21410
|
+
}
|
|
21411
|
+
|
|
21412
|
+
.date-picker-container {
|
|
21413
|
+
position: relative;
|
|
21414
|
+
max-inline-size: 234px;
|
|
21415
|
+
}
|
|
21416
|
+
|
|
21417
|
+
.date-picker-trigger {
|
|
21418
|
+
display: flex;
|
|
21419
|
+
}
|
|
21420
|
+
|
|
21421
|
+
.date-picker-input {
|
|
21422
|
+
padding-inline-end: var(--space-xs-ymlm0b, 8px);
|
|
21423
|
+
inline-size: 100%;
|
|
21424
|
+
}
|
|
21425
|
+
`;
|
|
21426
|
+
|
|
21427
|
+
// src/date-picker/internal.ts
|
|
21428
|
+
var Base10 = FormAssociatedMixin(CsBaseElement);
|
|
21429
|
+
var hostStyles59 = css130`:host { display: block; }`;
|
|
21430
|
+
var dropdownStyles3 = css130`
|
|
21431
|
+
.dropdown {
|
|
21432
|
+
position: fixed;
|
|
21433
|
+
z-index: 1000;
|
|
21434
|
+
background: var(--color-background-dropdown-item-default-x1j8rl, #ffffff);
|
|
21435
|
+
border: 1px solid var(--color-border-dropdown-maqkj1, #8c8c94);
|
|
21436
|
+
border-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21437
|
+
box-shadow: var(--shadow-dropdown-ld783s, 0px 4px 20px 1px rgba(0, 7, 22, 0.1));
|
|
21438
|
+
padding: 0;
|
|
21439
|
+
}
|
|
21440
|
+
`;
|
|
21441
|
+
var CsDatePickerInternal = class extends Base10 {
|
|
21442
|
+
constructor() {
|
|
21443
|
+
super(...arguments);
|
|
21444
|
+
this._formFieldCtx = defaultFormFieldContext;
|
|
21445
|
+
this.value = "";
|
|
21446
|
+
this.placeholder = "YYYY/MM/DD";
|
|
21447
|
+
this.locale = "en-US";
|
|
21448
|
+
this.startOfWeek = 0;
|
|
21449
|
+
this.granularity = "day";
|
|
21450
|
+
this.readOnly = false;
|
|
21451
|
+
this.invalid = false;
|
|
21452
|
+
this.warning = false;
|
|
21453
|
+
this.autoFocus = false;
|
|
21454
|
+
this.ariaLabel = null;
|
|
21455
|
+
this._open = false;
|
|
21456
|
+
this._cleanupOutsideClick = null;
|
|
21457
|
+
this._onInputChange = (e) => {
|
|
21458
|
+
e.stopPropagation();
|
|
21459
|
+
this.value = e.detail.value;
|
|
21460
|
+
fireNonCancelableEvent(
|
|
21461
|
+
this,
|
|
21462
|
+
"change",
|
|
21463
|
+
{ value: this.value }
|
|
21464
|
+
);
|
|
21465
|
+
};
|
|
21466
|
+
this._onCalendarChange = (e) => {
|
|
21467
|
+
e.stopPropagation();
|
|
21468
|
+
this.value = e.detail.value;
|
|
21469
|
+
this._open = false;
|
|
21470
|
+
fireNonCancelableEvent(
|
|
21471
|
+
this,
|
|
21472
|
+
"change",
|
|
21473
|
+
{ value: this.value }
|
|
21474
|
+
);
|
|
21475
|
+
this.focus();
|
|
21476
|
+
};
|
|
21477
|
+
this._onToggleClick = (e) => {
|
|
21478
|
+
if (!(e instanceof CustomEvent)) return;
|
|
21479
|
+
this._onToggleCalendar();
|
|
21480
|
+
};
|
|
21481
|
+
this._onToggleCalendar = () => {
|
|
21482
|
+
if (this.disabled || this.readOnly) return;
|
|
21483
|
+
this._open = !this._open;
|
|
21484
|
+
};
|
|
21485
|
+
this._onHostKeyDown = (e) => {
|
|
21486
|
+
if (e.key === "Escape" && this._open) {
|
|
21487
|
+
e.stopPropagation();
|
|
21488
|
+
this._open = false;
|
|
21489
|
+
this.focus();
|
|
21490
|
+
}
|
|
21491
|
+
};
|
|
21492
|
+
}
|
|
21493
|
+
static {
|
|
21494
|
+
this.styles = [sharedStyles, componentStyles58, dropdownStyles3, hostStyles59];
|
|
21495
|
+
}
|
|
21496
|
+
connectedCallback() {
|
|
21497
|
+
super.connectedCallback();
|
|
21498
|
+
this.addEventListener("keydown", this._onHostKeyDown);
|
|
21499
|
+
}
|
|
21500
|
+
disconnectedCallback() {
|
|
21501
|
+
super.disconnectedCallback();
|
|
21502
|
+
this.removeEventListener("keydown", this._onHostKeyDown);
|
|
21503
|
+
this._removeOutsideClickListener();
|
|
21504
|
+
}
|
|
21505
|
+
updated(changed) {
|
|
21506
|
+
super.updated(changed);
|
|
21507
|
+
if (changed.has("_open")) {
|
|
21508
|
+
if (this._open) {
|
|
21509
|
+
this._updateDropdownPosition();
|
|
21510
|
+
this._addOutsideClickListener();
|
|
21511
|
+
} else {
|
|
21512
|
+
this._removeOutsideClickListener();
|
|
21513
|
+
}
|
|
21514
|
+
}
|
|
21515
|
+
}
|
|
21516
|
+
focus(options) {
|
|
21517
|
+
const dateInput = this.shadowRoot?.querySelector("cs-date-input");
|
|
21518
|
+
dateInput?.focus(options);
|
|
21519
|
+
}
|
|
21520
|
+
get _isInvalid() {
|
|
21521
|
+
return this.invalid || this._formFieldCtx.invalid;
|
|
21522
|
+
}
|
|
21523
|
+
get _isWarning() {
|
|
21524
|
+
return (this.warning || this._formFieldCtx.warning) && !this._isInvalid;
|
|
21525
|
+
}
|
|
21526
|
+
async _updateDropdownPosition() {
|
|
21527
|
+
await this.updateComplete;
|
|
21528
|
+
if (!this._triggerEl || !this._dropdownEl) return;
|
|
21529
|
+
const { x, y } = await computePosition2(
|
|
21530
|
+
this._triggerEl,
|
|
21531
|
+
this._dropdownEl,
|
|
21532
|
+
{
|
|
21533
|
+
placement: "bottom-start",
|
|
21534
|
+
strategy: "fixed",
|
|
21535
|
+
middleware: [offset2(4), flip2({ padding: 8 }), shift2({ padding: 8 })]
|
|
21536
|
+
}
|
|
21537
|
+
);
|
|
21538
|
+
Object.assign(this._dropdownEl.style, {
|
|
21539
|
+
left: `${x}px`,
|
|
21540
|
+
top: `${y}px`
|
|
21541
|
+
});
|
|
21542
|
+
}
|
|
21543
|
+
_addOutsideClickListener() {
|
|
21544
|
+
this._removeOutsideClickListener();
|
|
21545
|
+
const handler = (e) => {
|
|
21546
|
+
const path = e.composedPath();
|
|
21547
|
+
if (!path.includes(this)) {
|
|
21548
|
+
this._open = false;
|
|
21549
|
+
}
|
|
21550
|
+
};
|
|
21551
|
+
requestAnimationFrame(() => {
|
|
21552
|
+
document.addEventListener("click", handler, true);
|
|
21553
|
+
this._cleanupOutsideClick = () => {
|
|
21554
|
+
document.removeEventListener("click", handler, true);
|
|
21555
|
+
};
|
|
21556
|
+
});
|
|
21557
|
+
}
|
|
21558
|
+
_removeOutsideClickListener() {
|
|
21559
|
+
this._cleanupOutsideClick?.();
|
|
21560
|
+
this._cleanupOutsideClick = null;
|
|
21561
|
+
}
|
|
21562
|
+
_getOpenCalendarLabel() {
|
|
21563
|
+
if (this.i18nStrings?.openCalendarAriaLabel) {
|
|
21564
|
+
return this.i18nStrings.openCalendarAriaLabel(this.value || null);
|
|
21565
|
+
}
|
|
21566
|
+
if (this.openCalendarAriaLabel) {
|
|
21567
|
+
return this.openCalendarAriaLabel(this.value || null);
|
|
21568
|
+
}
|
|
21569
|
+
return "Open calendar";
|
|
21570
|
+
}
|
|
21571
|
+
render() {
|
|
21572
|
+
return html60`
|
|
21573
|
+
<div class="root">
|
|
21574
|
+
<div class="date-picker-container">
|
|
21575
|
+
<div class="date-picker-trigger">
|
|
21576
|
+
<div class="date-picker-input">
|
|
21577
|
+
<cs-date-input
|
|
21578
|
+
.value=${this.value}
|
|
21579
|
+
placeholder=${this.placeholder}
|
|
21580
|
+
?disabled=${this.disabled}
|
|
21581
|
+
?read-only=${this.readOnly}
|
|
21582
|
+
?invalid=${this._isInvalid}
|
|
21583
|
+
?warning=${this._isWarning}
|
|
21584
|
+
aria-label=${ifDefined31(this.ariaLabel || void 0)}
|
|
21585
|
+
@change=${this._onInputChange}
|
|
21586
|
+
></cs-date-input>
|
|
21587
|
+
</div>
|
|
21588
|
+
<cs-button
|
|
21589
|
+
variant="icon"
|
|
21590
|
+
icon-name="calendar"
|
|
21591
|
+
?disabled=${this.disabled || this.readOnly}
|
|
21592
|
+
aria-label=${this._getOpenCalendarLabel()}
|
|
21593
|
+
aria-expanded=${this._open ? "true" : "false"}
|
|
21594
|
+
@click=${this._onToggleClick}
|
|
21595
|
+
></cs-button>
|
|
21596
|
+
</div>
|
|
21597
|
+
${this._open ? html60`
|
|
21598
|
+
<div class="dropdown">
|
|
21599
|
+
<div class="calendar" tabindex="-1">
|
|
21600
|
+
<cs-calendar
|
|
21601
|
+
.value=${this.value}
|
|
21602
|
+
locale=${this.locale}
|
|
21603
|
+
start-of-week=${this.startOfWeek}
|
|
21604
|
+
.isDateEnabled=${this.isDateEnabled}
|
|
21605
|
+
.i18nStrings=${this.i18nStrings}
|
|
21606
|
+
aria-label=${ifDefined31(this.ariaLabel || void 0)}
|
|
21607
|
+
@change=${this._onCalendarChange}
|
|
21608
|
+
></cs-calendar>
|
|
21609
|
+
</div>
|
|
21610
|
+
</div>
|
|
21611
|
+
` : nothing32}
|
|
21612
|
+
</div>
|
|
21613
|
+
</div>
|
|
21614
|
+
`;
|
|
21615
|
+
}
|
|
21616
|
+
};
|
|
21617
|
+
__decorateClass([
|
|
21618
|
+
consume3({ context: formFieldContext, subscribe: true })
|
|
21619
|
+
], CsDatePickerInternal.prototype, "_formFieldCtx", 2);
|
|
21620
|
+
__decorateClass([
|
|
21621
|
+
property59({ type: String })
|
|
21622
|
+
], CsDatePickerInternal.prototype, "value", 2);
|
|
21623
|
+
__decorateClass([
|
|
21624
|
+
property59({ type: String })
|
|
21625
|
+
], CsDatePickerInternal.prototype, "placeholder", 2);
|
|
21626
|
+
__decorateClass([
|
|
21627
|
+
property59({ type: String })
|
|
21628
|
+
], CsDatePickerInternal.prototype, "locale", 2);
|
|
21629
|
+
__decorateClass([
|
|
21630
|
+
property59({ type: Number })
|
|
21631
|
+
], CsDatePickerInternal.prototype, "startOfWeek", 2);
|
|
21632
|
+
__decorateClass([
|
|
21633
|
+
property59({ type: String })
|
|
21634
|
+
], CsDatePickerInternal.prototype, "granularity", 2);
|
|
21635
|
+
__decorateClass([
|
|
21636
|
+
property59({ attribute: false })
|
|
21637
|
+
], CsDatePickerInternal.prototype, "isDateEnabled", 2);
|
|
21638
|
+
__decorateClass([
|
|
21639
|
+
property59({ attribute: false })
|
|
21640
|
+
], CsDatePickerInternal.prototype, "openCalendarAriaLabel", 2);
|
|
21641
|
+
__decorateClass([
|
|
21642
|
+
property59({ type: Boolean, reflect: true })
|
|
21643
|
+
], CsDatePickerInternal.prototype, "readOnly", 2);
|
|
21644
|
+
__decorateClass([
|
|
21645
|
+
property59({ type: Boolean, reflect: true })
|
|
21646
|
+
], CsDatePickerInternal.prototype, "invalid", 2);
|
|
21647
|
+
__decorateClass([
|
|
21648
|
+
property59({ type: Boolean, reflect: true })
|
|
21649
|
+
], CsDatePickerInternal.prototype, "warning", 2);
|
|
21650
|
+
__decorateClass([
|
|
21651
|
+
property59({ type: Boolean })
|
|
21652
|
+
], CsDatePickerInternal.prototype, "autoFocus", 2);
|
|
21653
|
+
__decorateClass([
|
|
21654
|
+
property59({ type: String })
|
|
21655
|
+
], CsDatePickerInternal.prototype, "ariaLabel", 2);
|
|
21656
|
+
__decorateClass([
|
|
21657
|
+
property59({ attribute: false })
|
|
21658
|
+
], CsDatePickerInternal.prototype, "i18nStrings", 2);
|
|
21659
|
+
__decorateClass([
|
|
21660
|
+
state19()
|
|
21661
|
+
], CsDatePickerInternal.prototype, "_open", 2);
|
|
21662
|
+
__decorateClass([
|
|
21663
|
+
query7(".date-picker-trigger")
|
|
21664
|
+
], CsDatePickerInternal.prototype, "_triggerEl", 2);
|
|
21665
|
+
__decorateClass([
|
|
21666
|
+
query7(".dropdown")
|
|
21667
|
+
], CsDatePickerInternal.prototype, "_dropdownEl", 2);
|
|
21668
|
+
|
|
21669
|
+
// src/date-picker/index.ts
|
|
21670
|
+
var CsDatePicker = class extends CsDatePickerInternal {
|
|
21671
|
+
};
|
|
21672
|
+
customElements.define("cs-date-picker", CsDatePicker);
|
|
21673
|
+
|
|
21674
|
+
// src/date-range-picker/internal.ts
|
|
21675
|
+
import { css as css133, html as html61, nothing as nothing33 } from "lit";
|
|
21676
|
+
import { property as property60, state as state20, query as query8 } from "lit/decorators.js";
|
|
21677
|
+
import { classMap as classMap49 } from "lit/directives/class-map.js";
|
|
21678
|
+
import { ifDefined as ifDefined32 } from "lit/directives/if-defined.js";
|
|
21679
|
+
|
|
21680
|
+
// src/date-range-picker/styles.ts
|
|
21681
|
+
import { css as css131 } from "lit";
|
|
21682
|
+
var componentStyles59 = css131`
|
|
21683
|
+
.calendar {
|
|
21684
|
+
animation: awsui_awsui-motion-fade-in-0_mgja0_1ueys_1 var(--motion-duration-show-quick-tyvnyw, 135ms) var(--motion-easing-show-quick-9hlj8q, ease-out);
|
|
21685
|
+
animation-fill-mode: both;
|
|
21686
|
+
}
|
|
21687
|
+
@keyframes awsui_awsui-motion-fade-in-0_mgja0_1ueys_1 {
|
|
21688
|
+
from {
|
|
21689
|
+
opacity: 0;
|
|
21690
|
+
}
|
|
21691
|
+
to {
|
|
21692
|
+
opacity: 1;
|
|
21693
|
+
}
|
|
21694
|
+
}
|
|
21695
|
+
@media (prefers-reduced-motion: reduce) {
|
|
21696
|
+
.calendar {
|
|
21697
|
+
animation: none;
|
|
21698
|
+
transition: none;
|
|
21699
|
+
}
|
|
21700
|
+
}
|
|
21701
|
+
.awsui-motion-disabled .calendar, .awsui-mode-entering .calendar {
|
|
21702
|
+
animation: none;
|
|
21703
|
+
transition: none;
|
|
21704
|
+
}
|
|
21705
|
+
|
|
21706
|
+
.root {
|
|
21707
|
+
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
21708
|
+
line-height: var(--line-height-body-m-2mh3ke, 20px);
|
|
21709
|
+
color: var(--color-text-body-default-vvtq8u, #0f141a);
|
|
21710
|
+
font-weight: 400;
|
|
21711
|
+
font-family: var(--font-family-base-gmnpzl, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
21712
|
+
-webkit-font-smoothing: auto;
|
|
21713
|
+
-moz-osx-font-smoothing: auto;
|
|
21714
|
+
}
|
|
21715
|
+
.root:not(.wide) {
|
|
21716
|
+
max-inline-size: 32em;
|
|
21717
|
+
}
|
|
21718
|
+
.root.wide {
|
|
21719
|
+
max-inline-size: 39em;
|
|
21720
|
+
}
|
|
21721
|
+
|
|
21722
|
+
.focus-lock {
|
|
21723
|
+
display: contents;
|
|
21724
|
+
}
|
|
21725
|
+
|
|
21726
|
+
.trigger-flexbox {
|
|
21727
|
+
display: flex;
|
|
21728
|
+
}
|
|
21729
|
+
|
|
21730
|
+
.calendar-container {
|
|
21731
|
+
inline-size: calc(2 * var(--size-calendar-grid-width-hv3136, 238px) + var(--space-xs-ymlm0b, 8px));
|
|
21732
|
+
}
|
|
21733
|
+
.calendar-container.one-grid {
|
|
21734
|
+
inline-size: var(--size-calendar-grid-width-hv3136, 238px);
|
|
21735
|
+
}
|
|
21736
|
+
|
|
21737
|
+
.calendar-header {
|
|
21738
|
+
display: flex;
|
|
21739
|
+
justify-content: space-between;
|
|
21740
|
+
align-items: center;
|
|
21741
|
+
position: relative;
|
|
21742
|
+
}
|
|
21743
|
+
.calendar-header-pages-wrapper {
|
|
21744
|
+
position: absolute;
|
|
21745
|
+
inset: 0;
|
|
21746
|
+
margin-block: 0;
|
|
21747
|
+
margin-inline: 0;
|
|
21748
|
+
display: flex;
|
|
21749
|
+
justify-content: space-around;
|
|
21750
|
+
align-items: center;
|
|
21751
|
+
flex: 1;
|
|
21752
|
+
pointer-events: none;
|
|
21753
|
+
}
|
|
21754
|
+
.calendar-header-page {
|
|
21755
|
+
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
21756
|
+
line-height: var(--line-height-body-m-2mh3ke, 20px);
|
|
21757
|
+
font-weight: 700;
|
|
21758
|
+
color: var(--color-text-body-default-vvtq8u, #0f141a);
|
|
21759
|
+
display: flex;
|
|
21760
|
+
pointer-events: auto;
|
|
21761
|
+
}
|
|
21762
|
+
|
|
21763
|
+
.date-and-time-container {
|
|
21764
|
+
display: grid;
|
|
21765
|
+
grid-template-columns: repeat(auto-fit, minmax(var(--size-calendar-grid-width-hv3136, 238px), 1fr));
|
|
21766
|
+
gap: var(--space-xs-ymlm0b, 8px);
|
|
21767
|
+
}
|
|
21768
|
+
|
|
21769
|
+
.date-and-time-wrapper {
|
|
21770
|
+
inline-size: var(--size-calendar-grid-width-hv3136, 238px);
|
|
21771
|
+
display: grid;
|
|
21772
|
+
gap: var(--space-xs-ymlm0b, 8px);
|
|
21773
|
+
grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
|
|
21774
|
+
}
|
|
21775
|
+
|
|
21776
|
+
.footer {
|
|
21777
|
+
display: flex;
|
|
21778
|
+
flex-wrap: wrap;
|
|
21779
|
+
justify-content: flex-end;
|
|
21780
|
+
border-block-start: 1px solid var(--color-border-dropdown-item-default-kape37, #c6c6cd);
|
|
21781
|
+
padding-block-start: 0;
|
|
21782
|
+
padding-block-end: var(--space-s-tvghoh, 12px);
|
|
21783
|
+
padding-inline: var(--space-l-2ud1p3, 20px);
|
|
21784
|
+
}
|
|
21785
|
+
.footer.has-clear-button {
|
|
21786
|
+
justify-content: space-between;
|
|
21787
|
+
}
|
|
21788
|
+
.footer.one-grid {
|
|
21789
|
+
padding-block-start: 0;
|
|
21790
|
+
padding-block-end: var(--space-s-tvghoh, 12px);
|
|
21791
|
+
padding-inline: var(--space-xs-ymlm0b, 8px);
|
|
21792
|
+
}
|
|
21793
|
+
|
|
21794
|
+
.footer-button-wrapper {
|
|
21795
|
+
padding-block-start: var(--space-s-tvghoh, 12px);
|
|
21796
|
+
}
|
|
21797
|
+
.footer-button-wrapper:last-child {
|
|
21798
|
+
margin-inline-start: auto;
|
|
21799
|
+
}
|
|
21800
|
+
|
|
21801
|
+
.icon-wrapper {
|
|
21802
|
+
color: var(--color-text-interactive-default-ugh9wp, #424650);
|
|
21803
|
+
margin-inline-end: var(--space-xs-ymlm0b, 8px);
|
|
21804
|
+
}
|
|
21805
|
+
|
|
21806
|
+
.label {
|
|
21807
|
+
cursor: default;
|
|
21808
|
+
}
|
|
21809
|
+
|
|
21810
|
+
.label.label-enabled:hover > .trigger-flexbox > .icon-wrapper {
|
|
21811
|
+
color: var(--color-text-interactive-hover-6naf7i, #0f141a);
|
|
21812
|
+
}
|
|
21813
|
+
|
|
21814
|
+
.label-text {
|
|
21815
|
+
color: var(--color-text-input-placeholder-dclg8u, #656871);
|
|
21816
|
+
font-style: italic;
|
|
21817
|
+
}
|
|
21818
|
+
|
|
21819
|
+
.label-token-nowrap {
|
|
21820
|
+
white-space: nowrap;
|
|
21821
|
+
}
|
|
21822
|
+
|
|
21823
|
+
.dropdown {
|
|
21824
|
+
overflow: auto;
|
|
21825
|
+
border-block-start: 1px solid var(--color-border-container-top-k3vmoz, transparent);
|
|
21826
|
+
border-block-end: 1px solid var(--color-border-container-top-k3vmoz, transparent);
|
|
21827
|
+
border-start-start-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21828
|
+
border-start-end-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21829
|
+
border-end-start-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21830
|
+
border-end-end-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21831
|
+
}
|
|
21832
|
+
.dropdown:focus {
|
|
21833
|
+
outline: none;
|
|
21834
|
+
}
|
|
21835
|
+
:host-context([data-awsui-focus-visible=true]) .dropdown:focus {
|
|
21836
|
+
outline: 2px dotted transparent;
|
|
21837
|
+
outline-offset: 2px;
|
|
21838
|
+
border-start-start-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21839
|
+
border-start-end-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21840
|
+
border-end-start-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21841
|
+
border-end-end-radius: var(--border-radius-dropdown-fgc2a1, 8px);
|
|
21842
|
+
box-shadow: 0 0 0 2px var(--color-border-item-focused-uk47pl, #006ce0);
|
|
21843
|
+
}
|
|
21844
|
+
|
|
21845
|
+
.dropdown-content {
|
|
21846
|
+
background-color: var(--color-background-container-content-6u8rvp, #ffffff);
|
|
21847
|
+
inline-size: calc(2 * var(--size-calendar-grid-width-hv3136, 238px) + var(--space-xs-ymlm0b, 8px) + 2 * var(--space-l-2ud1p3, 20px));
|
|
21848
|
+
}
|
|
21849
|
+
.dropdown-content.one-grid {
|
|
21850
|
+
inline-size: calc(var(--size-calendar-grid-width-hv3136, 238px) + 2 * var(--space-l-2ud1p3, 20px));
|
|
21851
|
+
}
|
|
21852
|
+
`;
|
|
21853
|
+
|
|
21854
|
+
// src/internal/styles/date-range-picker-relative-range.ts
|
|
21855
|
+
import { css as css132 } from "lit";
|
|
21856
|
+
var dateRangePickerRelativeRangeStyles = css132`
|
|
21857
|
+
.date-range-picker-relative-range--custom-range {
|
|
21858
|
+
padding-inline-start: calc(14px + var(--space-xs-ymlm0b, 8px));
|
|
21859
|
+
display: flex;
|
|
21860
|
+
inline-size: 80%;
|
|
21861
|
+
}
|
|
21862
|
+
|
|
21863
|
+
.date-range-picker-relative-range--custom-range--no-padding {
|
|
21864
|
+
padding-inline-start: 0;
|
|
21865
|
+
}
|
|
21866
|
+
|
|
21867
|
+
.date-range-picker-relative-range--custom-range-form-controls {
|
|
21868
|
+
display: flex;
|
|
21869
|
+
inline-size: 100%;
|
|
21870
|
+
}
|
|
21871
|
+
.date-range-picker-relative-range--custom-range-form-controls > .date-range-picker-relative-range--custom-range-duration,
|
|
21872
|
+
.date-range-picker-relative-range--custom-range-form-controls > .date-range-picker-relative-range--custom-range-unit {
|
|
21873
|
+
inline-size: 50%;
|
|
21874
|
+
}
|
|
21875
|
+
.date-range-picker-relative-range--custom-range-form-controls > .date-range-picker-relative-range--custom-range-duration {
|
|
21876
|
+
margin-inline-end: var(--space-xs-ymlm0b, 8px);
|
|
21877
|
+
}
|
|
21878
|
+
.date-range-picker-relative-range--custom-range-form-controls.date-range-picker-relative-range--vertical {
|
|
21879
|
+
flex-direction: column;
|
|
21880
|
+
}
|
|
21881
|
+
.date-range-picker-relative-range--custom-range-form-controls.date-range-picker-relative-range--vertical > .date-range-picker-relative-range--custom-range-duration,
|
|
21882
|
+
.date-range-picker-relative-range--custom-range-form-controls.date-range-picker-relative-range--vertical > .date-range-picker-relative-range--custom-range-unit {
|
|
21883
|
+
inline-size: 100%;
|
|
21884
|
+
}
|
|
21885
|
+
.date-range-picker-relative-range--custom-range-form-controls.date-range-picker-relative-range--vertical > .date-range-picker-relative-range--custom-range-unit {
|
|
21886
|
+
margin-block-start: var(--space-s-tvghoh, 12px);
|
|
21887
|
+
}
|
|
21888
|
+
`;
|
|
21889
|
+
|
|
21890
|
+
// src/date-range-picker/internal.ts
|
|
21891
|
+
var Base11 = FormAssociatedMixin(CsBaseElement);
|
|
21892
|
+
var hostStyles60 = css133`:host { display: block; }`;
|
|
21893
|
+
function getDaysInMonth(year, month) {
|
|
21894
|
+
return new Date(year, month + 1, 0).getDate();
|
|
21895
|
+
}
|
|
21896
|
+
function getStartDayOfMonth(year, month, startOfWeek) {
|
|
21897
|
+
const day = new Date(year, month, 1).getDay();
|
|
21898
|
+
return (day - startOfWeek + 7) % 7;
|
|
21899
|
+
}
|
|
21900
|
+
function getMonthName(year, month, locale) {
|
|
21901
|
+
const date = new Date(year, month, 1);
|
|
21902
|
+
try {
|
|
21903
|
+
return date.toLocaleDateString(locale || void 0, { month: "long", year: "numeric" });
|
|
21904
|
+
} catch {
|
|
21905
|
+
return date.toLocaleDateString(void 0, { month: "long", year: "numeric" });
|
|
21906
|
+
}
|
|
21907
|
+
}
|
|
21908
|
+
function toDateString(year, month, day) {
|
|
21909
|
+
const m = String(month + 1).padStart(2, "0");
|
|
21910
|
+
const d = String(day).padStart(2, "0");
|
|
21911
|
+
return `${year}-${m}-${d}`;
|
|
21912
|
+
}
|
|
21913
|
+
function parseDateString(str) {
|
|
21914
|
+
const parts = str.split("T")[0].split("-");
|
|
21915
|
+
if (parts.length < 3) return null;
|
|
21916
|
+
const year = parseInt(parts[0], 10);
|
|
21917
|
+
const month = parseInt(parts[1], 10) - 1;
|
|
21918
|
+
const day = parseInt(parts[2], 10);
|
|
21919
|
+
if (isNaN(year) || isNaN(month) || isNaN(day)) return null;
|
|
21920
|
+
return { year, month, day };
|
|
21921
|
+
}
|
|
21922
|
+
function formatDisplayValue(value, relativeOptions, formatRelativeRange) {
|
|
21923
|
+
if (!value) return "";
|
|
21924
|
+
if (value.type === "absolute") {
|
|
21925
|
+
const start = value.startDate.split("T")[0];
|
|
21926
|
+
const end = value.endDate.split("T")[0];
|
|
21927
|
+
return `${start} \u2014 ${end}`;
|
|
21928
|
+
}
|
|
21929
|
+
if (formatRelativeRange) {
|
|
21930
|
+
return formatRelativeRange(value);
|
|
21931
|
+
}
|
|
21932
|
+
const match = relativeOptions.find(
|
|
21933
|
+
(o) => o.key === value.key
|
|
21934
|
+
);
|
|
21935
|
+
if (match) {
|
|
21936
|
+
return `Last ${match.amount} ${match.unit}${match.amount !== 1 ? "s" : ""}`;
|
|
21937
|
+
}
|
|
21938
|
+
return `Last ${value.amount} ${value.unit}${value.amount !== 1 ? "s" : ""}`;
|
|
21939
|
+
}
|
|
21940
|
+
var DAY_LABELS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
21941
|
+
var CsDateRangePickerInternal = class extends Base11 {
|
|
21942
|
+
constructor() {
|
|
21943
|
+
super(...arguments);
|
|
21944
|
+
this.value = "";
|
|
21945
|
+
this.rangeValue = null;
|
|
21946
|
+
this.relativeOptions = [];
|
|
21947
|
+
this.startOfWeek = 0;
|
|
21948
|
+
this.placeholder = "";
|
|
21949
|
+
this.invalid = false;
|
|
21950
|
+
this.rangeSelectorMode = "default";
|
|
21951
|
+
this.ariaLabel = null;
|
|
21952
|
+
this._open = false;
|
|
21953
|
+
this._mode = "absolute";
|
|
21954
|
+
this._errorMessage = "";
|
|
21955
|
+
this._leftYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
21956
|
+
this._leftMonth = (/* @__PURE__ */ new Date()).getMonth();
|
|
21957
|
+
this._rangeStart = null;
|
|
21958
|
+
this._rangeEnd = null;
|
|
21959
|
+
this._hoverDate = null;
|
|
21960
|
+
this._selectedRelativeKey = null;
|
|
21961
|
+
this._cleanupOutsideClick = null;
|
|
21962
|
+
// ── Event handlers ──────────────────────────────────────────────────
|
|
21963
|
+
this._onTriggerClick = () => {
|
|
21964
|
+
if (this.disabled) return;
|
|
21965
|
+
this._open = !this._open;
|
|
21966
|
+
if (this._open) {
|
|
21967
|
+
this._errorMessage = "";
|
|
21968
|
+
this._syncFromValue();
|
|
21969
|
+
if (!this.rangeValue) {
|
|
21970
|
+
const now = /* @__PURE__ */ new Date();
|
|
21971
|
+
this._leftYear = now.getFullYear();
|
|
21972
|
+
this._leftMonth = now.getMonth();
|
|
21973
|
+
this._rangeStart = null;
|
|
21974
|
+
this._rangeEnd = null;
|
|
21975
|
+
this._selectedRelativeKey = null;
|
|
21976
|
+
}
|
|
21977
|
+
}
|
|
21978
|
+
};
|
|
21979
|
+
this._onKeyDown = (e) => {
|
|
21980
|
+
if (e.key === "Escape" && this._open) {
|
|
21981
|
+
e.stopPropagation();
|
|
21982
|
+
this._open = false;
|
|
21983
|
+
this._triggerEl?.focus();
|
|
21984
|
+
}
|
|
21985
|
+
};
|
|
21986
|
+
this._onPrevMonth = () => {
|
|
21987
|
+
if (this._leftMonth === 0) {
|
|
21988
|
+
this._leftMonth = 11;
|
|
21989
|
+
this._leftYear--;
|
|
21990
|
+
} else {
|
|
21991
|
+
this._leftMonth--;
|
|
21992
|
+
}
|
|
21993
|
+
};
|
|
21994
|
+
this._onNextMonth = () => {
|
|
21995
|
+
if (this._leftMonth === 11) {
|
|
21996
|
+
this._leftMonth = 0;
|
|
21997
|
+
this._leftYear++;
|
|
21998
|
+
} else {
|
|
21999
|
+
this._leftMonth++;
|
|
22000
|
+
}
|
|
22001
|
+
};
|
|
22002
|
+
this._onApply = () => {
|
|
22003
|
+
let newValue = null;
|
|
22004
|
+
if (this._effectiveMode === "absolute") {
|
|
22005
|
+
if (!this._rangeStart || !this._rangeEnd) {
|
|
22006
|
+
this._errorMessage = "Please select both start and end dates.";
|
|
22007
|
+
return;
|
|
22008
|
+
}
|
|
22009
|
+
newValue = {
|
|
22010
|
+
type: "absolute",
|
|
22011
|
+
startDate: this._rangeStart,
|
|
22012
|
+
endDate: this._rangeEnd
|
|
22013
|
+
};
|
|
22014
|
+
} else {
|
|
22015
|
+
const option = this.relativeOptions.find((o) => o.key === this._selectedRelativeKey);
|
|
22016
|
+
if (!option) {
|
|
22017
|
+
this._errorMessage = "Please select a relative range.";
|
|
22018
|
+
return;
|
|
22019
|
+
}
|
|
22020
|
+
newValue = {
|
|
22021
|
+
type: "relative",
|
|
22022
|
+
key: option.key,
|
|
22023
|
+
amount: option.amount,
|
|
22024
|
+
unit: option.unit
|
|
22025
|
+
};
|
|
22026
|
+
}
|
|
22027
|
+
if (this.isValidRange) {
|
|
22028
|
+
const result = this.isValidRange(newValue);
|
|
22029
|
+
if (!result.valid) {
|
|
22030
|
+
this._errorMessage = result.errorMessage;
|
|
22031
|
+
return;
|
|
22032
|
+
}
|
|
22033
|
+
}
|
|
22034
|
+
this.rangeValue = newValue;
|
|
22035
|
+
this.value = JSON.stringify(newValue);
|
|
22036
|
+
fireNonCancelableEvent(
|
|
22037
|
+
this,
|
|
22038
|
+
"change",
|
|
22039
|
+
{ value: newValue }
|
|
22040
|
+
);
|
|
22041
|
+
this._open = false;
|
|
22042
|
+
this._triggerEl?.focus();
|
|
22043
|
+
};
|
|
22044
|
+
this._onCancel = () => {
|
|
22045
|
+
this._open = false;
|
|
22046
|
+
this._errorMessage = "";
|
|
22047
|
+
this._triggerEl?.focus();
|
|
22048
|
+
};
|
|
22049
|
+
}
|
|
22050
|
+
static {
|
|
22051
|
+
this.styles = [
|
|
22052
|
+
sharedStyles,
|
|
22053
|
+
componentStyles59,
|
|
22054
|
+
dateRangePickerRelativeRangeStyles,
|
|
22055
|
+
hostStyles60
|
|
22056
|
+
];
|
|
22057
|
+
}
|
|
22058
|
+
// ── Computed ────────────────────────────────────────────────────────
|
|
22059
|
+
get _rightYear() {
|
|
22060
|
+
return this._leftMonth === 11 ? this._leftYear + 1 : this._leftYear;
|
|
22061
|
+
}
|
|
22062
|
+
get _rightMonth() {
|
|
22063
|
+
return (this._leftMonth + 1) % 12;
|
|
22064
|
+
}
|
|
22065
|
+
get _showModeSwitch() {
|
|
22066
|
+
return this.rangeSelectorMode === "default";
|
|
22067
|
+
}
|
|
22068
|
+
get _isAbsoluteOnly() {
|
|
22069
|
+
return this.rangeSelectorMode === "absolute-only";
|
|
22070
|
+
}
|
|
22071
|
+
get _isRelativeOnly() {
|
|
22072
|
+
return this.rangeSelectorMode === "relative-only";
|
|
22073
|
+
}
|
|
22074
|
+
get _effectiveMode() {
|
|
22075
|
+
if (this._isAbsoluteOnly) return "absolute";
|
|
22076
|
+
if (this._isRelativeOnly) return "relative";
|
|
22077
|
+
return this._mode;
|
|
22078
|
+
}
|
|
22079
|
+
// ── Lifecycle ───────────────────────────────────────────────────────
|
|
22080
|
+
connectedCallback() {
|
|
22081
|
+
super.connectedCallback();
|
|
22082
|
+
this.addEventListener("keydown", this._onKeyDown);
|
|
22083
|
+
}
|
|
22084
|
+
disconnectedCallback() {
|
|
22085
|
+
super.disconnectedCallback();
|
|
22086
|
+
this.removeEventListener("keydown", this._onKeyDown);
|
|
22087
|
+
this._removeOutsideClickListener();
|
|
22088
|
+
}
|
|
22089
|
+
updated(changed) {
|
|
22090
|
+
super.updated(changed);
|
|
22091
|
+
if (changed.has("_open")) {
|
|
22092
|
+
if (this._open) {
|
|
22093
|
+
this._updatePosition();
|
|
22094
|
+
this._addOutsideClickListener();
|
|
22095
|
+
} else {
|
|
22096
|
+
this._removeOutsideClickListener();
|
|
22097
|
+
}
|
|
22098
|
+
}
|
|
22099
|
+
}
|
|
22100
|
+
willUpdate(changed) {
|
|
22101
|
+
super.willUpdate(changed);
|
|
22102
|
+
if (changed.has("rangeValue") && this.rangeValue) {
|
|
22103
|
+
this._syncFromValue();
|
|
22104
|
+
}
|
|
22105
|
+
}
|
|
22106
|
+
focus(options) {
|
|
22107
|
+
this._triggerEl?.focus(options);
|
|
22108
|
+
}
|
|
22109
|
+
// ── Sync value to internal state ────────────────────────────────────
|
|
22110
|
+
_syncFromValue() {
|
|
22111
|
+
const v = this.rangeValue;
|
|
22112
|
+
if (!v) return;
|
|
22113
|
+
if (v.type === "absolute") {
|
|
22114
|
+
this._mode = "absolute";
|
|
22115
|
+
this._rangeStart = v.startDate.split("T")[0];
|
|
22116
|
+
this._rangeEnd = v.endDate.split("T")[0];
|
|
22117
|
+
const parsed = parseDateString(v.startDate);
|
|
22118
|
+
if (parsed) {
|
|
22119
|
+
this._leftYear = parsed.year;
|
|
22120
|
+
this._leftMonth = parsed.month;
|
|
22121
|
+
}
|
|
22122
|
+
} else {
|
|
22123
|
+
this._mode = "relative";
|
|
22124
|
+
this._selectedRelativeKey = v.key ?? null;
|
|
22125
|
+
}
|
|
22126
|
+
}
|
|
22127
|
+
_onModeSwitch(mode) {
|
|
22128
|
+
this._mode = mode;
|
|
22129
|
+
this._errorMessage = "";
|
|
22130
|
+
}
|
|
22131
|
+
_onDayClick(dateStr) {
|
|
22132
|
+
if (!this._rangeStart || this._rangeEnd) {
|
|
22133
|
+
this._rangeStart = dateStr;
|
|
22134
|
+
this._rangeEnd = null;
|
|
22135
|
+
this._hoverDate = null;
|
|
22136
|
+
} else {
|
|
22137
|
+
if (dateStr < this._rangeStart) {
|
|
22138
|
+
this._rangeEnd = this._rangeStart;
|
|
22139
|
+
this._rangeStart = dateStr;
|
|
22140
|
+
} else {
|
|
22141
|
+
this._rangeEnd = dateStr;
|
|
22142
|
+
}
|
|
22143
|
+
this._hoverDate = null;
|
|
22144
|
+
}
|
|
22145
|
+
}
|
|
22146
|
+
_onDayHover(dateStr) {
|
|
22147
|
+
if (this._rangeStart && !this._rangeEnd) {
|
|
22148
|
+
this._hoverDate = dateStr;
|
|
22149
|
+
}
|
|
22150
|
+
}
|
|
22151
|
+
_onRelativeSelect(key) {
|
|
22152
|
+
this._selectedRelativeKey = key;
|
|
22153
|
+
this._errorMessage = "";
|
|
22154
|
+
}
|
|
22155
|
+
// ── Positioning ─────────────────────────────────────────────────────
|
|
22156
|
+
async _updatePosition() {
|
|
22157
|
+
await this.updateComplete;
|
|
22158
|
+
if (!this._triggerEl || !this._dropdownEl) return;
|
|
22159
|
+
const { x, y } = await computePosition2(
|
|
22160
|
+
this._triggerEl,
|
|
22161
|
+
this._dropdownEl,
|
|
22162
|
+
{
|
|
22163
|
+
placement: "bottom-start",
|
|
22164
|
+
strategy: "fixed",
|
|
22165
|
+
middleware: [
|
|
22166
|
+
offset2(4),
|
|
22167
|
+
flip2({ padding: 8 }),
|
|
22168
|
+
shift2({ padding: 8 })
|
|
22169
|
+
]
|
|
22170
|
+
}
|
|
22171
|
+
);
|
|
22172
|
+
Object.assign(this._dropdownEl.style, {
|
|
22173
|
+
left: `${x}px`,
|
|
22174
|
+
top: `${y}px`
|
|
22175
|
+
});
|
|
22176
|
+
}
|
|
22177
|
+
_addOutsideClickListener() {
|
|
22178
|
+
this._removeOutsideClickListener();
|
|
22179
|
+
const handler = (e) => {
|
|
22180
|
+
const path = e.composedPath();
|
|
22181
|
+
if (!path.includes(this)) {
|
|
22182
|
+
this._open = false;
|
|
22183
|
+
}
|
|
22184
|
+
};
|
|
22185
|
+
requestAnimationFrame(() => {
|
|
22186
|
+
document.addEventListener("click", handler, true);
|
|
22187
|
+
this._cleanupOutsideClick = () => {
|
|
22188
|
+
document.removeEventListener("click", handler, true);
|
|
22189
|
+
};
|
|
22190
|
+
});
|
|
22191
|
+
}
|
|
22192
|
+
_removeOutsideClickListener() {
|
|
22193
|
+
this._cleanupOutsideClick?.();
|
|
22194
|
+
this._cleanupOutsideClick = null;
|
|
22195
|
+
}
|
|
22196
|
+
// ── Calendar grid rendering ─────────────────────────────────────────
|
|
22197
|
+
_isInRange(dateStr) {
|
|
22198
|
+
const start = this._rangeStart;
|
|
22199
|
+
const end = this._rangeEnd || this._hoverDate;
|
|
22200
|
+
if (!start || !end) return false;
|
|
22201
|
+
const lo = start < end ? start : end;
|
|
22202
|
+
const hi = start < end ? end : start;
|
|
22203
|
+
return dateStr >= lo && dateStr <= hi;
|
|
22204
|
+
}
|
|
22205
|
+
_isRangeEdge(dateStr) {
|
|
22206
|
+
return dateStr === this._rangeStart || dateStr === this._rangeEnd;
|
|
22207
|
+
}
|
|
22208
|
+
_isDayEnabled(year, month, day) {
|
|
22209
|
+
if (!this.isDateEnabled) return true;
|
|
22210
|
+
return this.isDateEnabled(new Date(year, month, day));
|
|
22211
|
+
}
|
|
22212
|
+
_renderCalendarGrid(year, month) {
|
|
22213
|
+
const startDay = getStartDayOfMonth(year, month, this.startOfWeek);
|
|
22214
|
+
const daysInMonth = getDaysInMonth(year, month);
|
|
22215
|
+
const monthLabel = getMonthName(year, month, this.locale);
|
|
22216
|
+
const reorderedDays = [
|
|
22217
|
+
...DAY_LABELS.slice(this.startOfWeek),
|
|
22218
|
+
...DAY_LABELS.slice(0, this.startOfWeek)
|
|
22219
|
+
];
|
|
22220
|
+
const weeks = [];
|
|
22221
|
+
let currentDay = 1;
|
|
22222
|
+
let weekCells = [];
|
|
22223
|
+
for (let i = 0; i < startDay; i++) {
|
|
22224
|
+
weekCells.push(html61`<td class="calendar-day calendar-day-empty"></td>`);
|
|
22225
|
+
}
|
|
22226
|
+
while (currentDay <= daysInMonth) {
|
|
22227
|
+
const dateStr = toDateString(year, month, currentDay);
|
|
22228
|
+
const inRange = this._isInRange(dateStr);
|
|
22229
|
+
const isEdge = this._isRangeEdge(dateStr);
|
|
22230
|
+
const enabled = this._isDayEnabled(year, month, currentDay);
|
|
22231
|
+
const isToday = this._isToday(year, month, currentDay);
|
|
22232
|
+
const day = currentDay;
|
|
22233
|
+
const dayClasses = {
|
|
22234
|
+
"calendar-day": true,
|
|
22235
|
+
"calendar-day-in-range": inRange,
|
|
22236
|
+
"calendar-day-range-edge": isEdge,
|
|
22237
|
+
"calendar-day-disabled": !enabled,
|
|
22238
|
+
"calendar-day-today": isToday
|
|
22239
|
+
};
|
|
22240
|
+
weekCells.push(html61`
|
|
22241
|
+
<td
|
|
22242
|
+
class=${classMap49(dayClasses)}
|
|
22243
|
+
role="gridcell"
|
|
22244
|
+
aria-selected=${isEdge ? "true" : "false"}
|
|
22245
|
+
aria-disabled=${!enabled ? "true" : "false"}
|
|
22246
|
+
@click=${enabled ? () => this._onDayClick(dateStr) : void 0}
|
|
22247
|
+
@mouseenter=${() => this._onDayHover(dateStr)}
|
|
22248
|
+
>
|
|
22249
|
+
<span class="calendar-day-number">${day}</span>
|
|
22250
|
+
</td>
|
|
22251
|
+
`);
|
|
22252
|
+
if (weekCells.length === 7) {
|
|
22253
|
+
weeks.push(html61`<tr class="calendar-week">${weekCells}</tr>`);
|
|
22254
|
+
weekCells = [];
|
|
22255
|
+
}
|
|
22256
|
+
currentDay++;
|
|
22257
|
+
}
|
|
22258
|
+
if (weekCells.length > 0) {
|
|
22259
|
+
while (weekCells.length < 7) {
|
|
22260
|
+
weekCells.push(html61`<td class="calendar-day calendar-day-empty"></td>`);
|
|
22261
|
+
}
|
|
22262
|
+
weeks.push(html61`<tr class="calendar-week">${weekCells}</tr>`);
|
|
22263
|
+
}
|
|
22264
|
+
return html61`
|
|
22265
|
+
<div class="calendar-grid-wrapper">
|
|
22266
|
+
<div class="calendar-grid-header" aria-live="polite">
|
|
22267
|
+
${monthLabel}
|
|
22268
|
+
</div>
|
|
22269
|
+
<table class="calendar-grid" role="grid" aria-label=${monthLabel}>
|
|
22270
|
+
<thead>
|
|
22271
|
+
<tr>
|
|
22272
|
+
${reorderedDays.map((d) => html61`<th class="calendar-day-header" scope="col">${d}</th>`)}
|
|
22273
|
+
</tr>
|
|
22274
|
+
</thead>
|
|
22275
|
+
<tbody>
|
|
22276
|
+
${weeks}
|
|
22277
|
+
</tbody>
|
|
22278
|
+
</table>
|
|
22279
|
+
</div>
|
|
22280
|
+
`;
|
|
22281
|
+
}
|
|
22282
|
+
_isToday(year, month, day) {
|
|
22283
|
+
const now = /* @__PURE__ */ new Date();
|
|
22284
|
+
return now.getFullYear() === year && now.getMonth() === month && now.getDate() === day;
|
|
22285
|
+
}
|
|
22286
|
+
// ── Render ──────────────────────────────────────────────────────────
|
|
22287
|
+
_renderModeSwitch() {
|
|
22288
|
+
if (!this._showModeSwitch) return nothing33;
|
|
22289
|
+
const absLabel = this.i18nStrings?.absoluteModeTitle ?? "Absolute";
|
|
22290
|
+
const relLabel = this.i18nStrings?.relativeModeTitle ?? "Relative";
|
|
22291
|
+
return html61`
|
|
22292
|
+
<div class="mode-switch" role="tablist"
|
|
22293
|
+
aria-label=${this.i18nStrings?.modeSelectionLabel ?? "Date range mode"}>
|
|
22294
|
+
<button
|
|
22295
|
+
class=${classMap49({ "mode-tab": true, "mode-tab-active": this._effectiveMode === "absolute" })}
|
|
22296
|
+
role="tab"
|
|
22297
|
+
aria-selected=${this._effectiveMode === "absolute" ? "true" : "false"}
|
|
22298
|
+
@click=${() => this._onModeSwitch("absolute")}
|
|
22299
|
+
>${absLabel}</button>
|
|
22300
|
+
<button
|
|
22301
|
+
class=${classMap49({ "mode-tab": true, "mode-tab-active": this._effectiveMode === "relative" })}
|
|
22302
|
+
role="tab"
|
|
22303
|
+
aria-selected=${this._effectiveMode === "relative" ? "true" : "false"}
|
|
22304
|
+
@click=${() => this._onModeSwitch("relative")}
|
|
22305
|
+
>${relLabel}</button>
|
|
22306
|
+
</div>
|
|
22307
|
+
`;
|
|
22308
|
+
}
|
|
22309
|
+
_renderAbsoluteMode() {
|
|
22310
|
+
return html61`
|
|
22311
|
+
<div class="absolute-mode" role="tabpanel">
|
|
22312
|
+
<div class="calendar-container">
|
|
22313
|
+
<div class="calendar-header">
|
|
22314
|
+
<cs-button variant="icon" icon-name="angle-left"
|
|
22315
|
+
aria-label=${this.i18nStrings?.previousMonthAriaLabel ?? "Previous month"}
|
|
22316
|
+
@click=${this._onPrevMonth}></cs-button>
|
|
22317
|
+
<div class="calendar-header-pages-wrapper">
|
|
22318
|
+
<div class="calendar-header-page">
|
|
22319
|
+
${getMonthName(this._leftYear, this._leftMonth, this.locale)}
|
|
22320
|
+
</div>
|
|
22321
|
+
<div class="calendar-header-page">
|
|
22322
|
+
${getMonthName(this._rightYear, this._rightMonth, this.locale)}
|
|
22323
|
+
</div>
|
|
22324
|
+
</div>
|
|
22325
|
+
<cs-button variant="icon" icon-name="angle-right"
|
|
22326
|
+
aria-label=${this.i18nStrings?.nextMonthAriaLabel ?? "Next month"}
|
|
22327
|
+
@click=${this._onNextMonth}></cs-button>
|
|
22328
|
+
</div>
|
|
22329
|
+
<div class="calendar-grids">
|
|
22330
|
+
${this._renderCalendarGrid(this._leftYear, this._leftMonth)}
|
|
22331
|
+
${this._renderCalendarGrid(this._rightYear, this._rightMonth)}
|
|
22332
|
+
</div>
|
|
22333
|
+
</div>
|
|
22334
|
+
</div>
|
|
22335
|
+
`;
|
|
22336
|
+
}
|
|
22337
|
+
_renderRelativeMode() {
|
|
22338
|
+
const heading = this.i18nStrings?.relativeRangeSelectionHeading ?? "Choose a range";
|
|
22339
|
+
return html61`
|
|
22340
|
+
<div class="relative-mode" role="tabpanel">
|
|
22341
|
+
<div class="relative-heading">${heading}</div>
|
|
22342
|
+
<div class="relative-options" role="radiogroup" aria-label=${heading}>
|
|
22343
|
+
${this.relativeOptions.map((option) => {
|
|
22344
|
+
const isSelected = this._selectedRelativeKey === option.key;
|
|
22345
|
+
const label = this.i18nStrings?.formatRelativeRange ? this.i18nStrings.formatRelativeRange(option) : `Last ${option.amount} ${option.unit}${option.amount !== 1 ? "s" : ""}`;
|
|
22346
|
+
return html61`
|
|
22347
|
+
<label class=${classMap49({
|
|
22348
|
+
"relative-option": true,
|
|
22349
|
+
"relative-option-selected": isSelected
|
|
22350
|
+
})}>
|
|
22351
|
+
<input
|
|
22352
|
+
type="radio"
|
|
22353
|
+
name="relative-range"
|
|
22354
|
+
class="relative-radio"
|
|
22355
|
+
.checked=${isSelected}
|
|
22356
|
+
@change=${() => this._onRelativeSelect(option.key)}
|
|
22357
|
+
/>
|
|
22358
|
+
<span class="relative-option-label">${label}</span>
|
|
22359
|
+
</label>
|
|
22360
|
+
`;
|
|
22361
|
+
})}
|
|
22362
|
+
</div>
|
|
22363
|
+
</div>
|
|
22364
|
+
`;
|
|
22365
|
+
}
|
|
22366
|
+
_renderFooter() {
|
|
22367
|
+
const cancelLabel = this.i18nStrings?.cancelButtonLabel ?? "Cancel";
|
|
22368
|
+
const applyLabel = this.i18nStrings?.applyButtonLabel ?? "Apply";
|
|
22369
|
+
return html61`
|
|
22370
|
+
<div class="footer">
|
|
22371
|
+
${this._errorMessage ? html61`
|
|
22372
|
+
<div class="error-message" role="alert">
|
|
22373
|
+
<cs-icon name="status-negative" size="small"></cs-icon>
|
|
22374
|
+
<span>${this._errorMessage}</span>
|
|
22375
|
+
</div>
|
|
22376
|
+
` : nothing33}
|
|
22377
|
+
<div class="footer-button-wrapper">
|
|
22378
|
+
<cs-button variant="link" @click=${this._onCancel}>${cancelLabel}</cs-button>
|
|
22379
|
+
</div>
|
|
22380
|
+
<div class="footer-button-wrapper">
|
|
22381
|
+
<cs-button variant="primary" @click=${this._onApply}>${applyLabel}</cs-button>
|
|
22382
|
+
</div>
|
|
22383
|
+
</div>
|
|
22384
|
+
`;
|
|
22385
|
+
}
|
|
22386
|
+
render() {
|
|
22387
|
+
const displayText = formatDisplayValue(
|
|
22388
|
+
this.rangeValue,
|
|
22389
|
+
this.relativeOptions,
|
|
22390
|
+
this.i18nStrings?.formatRelativeRange
|
|
22391
|
+
);
|
|
22392
|
+
const showPlaceholder = !displayText;
|
|
22393
|
+
const triggerClasses = {
|
|
22394
|
+
"trigger-button": true,
|
|
22395
|
+
"trigger-disabled": this.disabled,
|
|
22396
|
+
"trigger-invalid": this.invalid
|
|
22397
|
+
};
|
|
22398
|
+
const dropdownClasses = {
|
|
22399
|
+
"dropdown": true,
|
|
22400
|
+
"dropdown-content": true
|
|
22401
|
+
};
|
|
22402
|
+
return html61`
|
|
22403
|
+
<div class="root">
|
|
22404
|
+
<div class="label ${this.disabled ? "" : "label-enabled"}">
|
|
22405
|
+
<button
|
|
22406
|
+
class=${classMap49(triggerClasses)}
|
|
22407
|
+
type="button"
|
|
22408
|
+
aria-haspopup="dialog"
|
|
22409
|
+
aria-expanded=${this._open ? "true" : "false"}
|
|
22410
|
+
aria-label=${ifDefined32(this.ariaLabel || void 0)}
|
|
22411
|
+
aria-disabled=${ifDefined32(this.disabled ? "true" : void 0)}
|
|
22412
|
+
?disabled=${false}
|
|
22413
|
+
tabindex=${this.disabled ? -1 : 0}
|
|
22414
|
+
@click=${this._onTriggerClick}
|
|
22415
|
+
>
|
|
22416
|
+
<span class="trigger-flexbox">
|
|
22417
|
+
<span class="icon-wrapper">
|
|
22418
|
+
<cs-icon name="calendar"></cs-icon>
|
|
22419
|
+
</span>
|
|
22420
|
+
<span class="label-text ${showPlaceholder ? "" : "label-token-nowrap"}">
|
|
22421
|
+
${showPlaceholder ? this.placeholder || "\xA0" : displayText}
|
|
22422
|
+
</span>
|
|
22423
|
+
</span>
|
|
22424
|
+
</button>
|
|
22425
|
+
</div>
|
|
22426
|
+
${this._open ? html61`
|
|
22427
|
+
<div class=${classMap49(dropdownClasses)} role="dialog"
|
|
22428
|
+
aria-label=${ifDefined32(this.ariaLabel || "Date range picker")}
|
|
22429
|
+
aria-modal="true">
|
|
22430
|
+
${this._renderModeSwitch()}
|
|
22431
|
+
<div class="dropdown-body">
|
|
22432
|
+
${this._effectiveMode === "absolute" ? this._renderAbsoluteMode() : this._renderRelativeMode()}
|
|
22433
|
+
</div>
|
|
22434
|
+
${this._renderFooter()}
|
|
22435
|
+
</div>
|
|
22436
|
+
` : nothing33}
|
|
22437
|
+
</div>
|
|
22438
|
+
`;
|
|
22439
|
+
}
|
|
22440
|
+
};
|
|
22441
|
+
__decorateClass([
|
|
22442
|
+
property60({ attribute: false })
|
|
22443
|
+
], CsDateRangePickerInternal.prototype, "value", 2);
|
|
22444
|
+
__decorateClass([
|
|
22445
|
+
property60({ attribute: false })
|
|
22446
|
+
], CsDateRangePickerInternal.prototype, "rangeValue", 2);
|
|
22447
|
+
__decorateClass([
|
|
22448
|
+
property60({ attribute: false })
|
|
22449
|
+
], CsDateRangePickerInternal.prototype, "relativeOptions", 2);
|
|
22450
|
+
__decorateClass([
|
|
22451
|
+
property60({ attribute: false })
|
|
22452
|
+
], CsDateRangePickerInternal.prototype, "isDateEnabled", 2);
|
|
22453
|
+
__decorateClass([
|
|
22454
|
+
property60({ type: String })
|
|
22455
|
+
], CsDateRangePickerInternal.prototype, "locale", 2);
|
|
22456
|
+
__decorateClass([
|
|
22457
|
+
property60({ type: Number })
|
|
22458
|
+
], CsDateRangePickerInternal.prototype, "startOfWeek", 2);
|
|
22459
|
+
__decorateClass([
|
|
22460
|
+
property60({ type: String })
|
|
22461
|
+
], CsDateRangePickerInternal.prototype, "placeholder", 2);
|
|
22462
|
+
__decorateClass([
|
|
22463
|
+
property60({ type: Boolean })
|
|
22464
|
+
], CsDateRangePickerInternal.prototype, "invalid", 2);
|
|
22465
|
+
__decorateClass([
|
|
22466
|
+
property60({ type: String })
|
|
22467
|
+
], CsDateRangePickerInternal.prototype, "rangeSelectorMode", 2);
|
|
22468
|
+
__decorateClass([
|
|
22469
|
+
property60({ type: String })
|
|
22470
|
+
], CsDateRangePickerInternal.prototype, "ariaLabel", 2);
|
|
22471
|
+
__decorateClass([
|
|
22472
|
+
property60({ attribute: false })
|
|
22473
|
+
], CsDateRangePickerInternal.prototype, "isValidRange", 2);
|
|
22474
|
+
__decorateClass([
|
|
22475
|
+
property60({ attribute: false })
|
|
22476
|
+
], CsDateRangePickerInternal.prototype, "i18nStrings", 2);
|
|
22477
|
+
__decorateClass([
|
|
22478
|
+
state20()
|
|
22479
|
+
], CsDateRangePickerInternal.prototype, "_open", 2);
|
|
22480
|
+
__decorateClass([
|
|
22481
|
+
state20()
|
|
22482
|
+
], CsDateRangePickerInternal.prototype, "_mode", 2);
|
|
22483
|
+
__decorateClass([
|
|
22484
|
+
state20()
|
|
22485
|
+
], CsDateRangePickerInternal.prototype, "_errorMessage", 2);
|
|
22486
|
+
__decorateClass([
|
|
22487
|
+
state20()
|
|
22488
|
+
], CsDateRangePickerInternal.prototype, "_leftYear", 2);
|
|
22489
|
+
__decorateClass([
|
|
22490
|
+
state20()
|
|
22491
|
+
], CsDateRangePickerInternal.prototype, "_leftMonth", 2);
|
|
22492
|
+
__decorateClass([
|
|
22493
|
+
state20()
|
|
22494
|
+
], CsDateRangePickerInternal.prototype, "_rangeStart", 2);
|
|
22495
|
+
__decorateClass([
|
|
22496
|
+
state20()
|
|
22497
|
+
], CsDateRangePickerInternal.prototype, "_rangeEnd", 2);
|
|
22498
|
+
__decorateClass([
|
|
22499
|
+
state20()
|
|
22500
|
+
], CsDateRangePickerInternal.prototype, "_hoverDate", 2);
|
|
22501
|
+
__decorateClass([
|
|
22502
|
+
state20()
|
|
22503
|
+
], CsDateRangePickerInternal.prototype, "_selectedRelativeKey", 2);
|
|
22504
|
+
__decorateClass([
|
|
22505
|
+
query8(".trigger-button")
|
|
22506
|
+
], CsDateRangePickerInternal.prototype, "_triggerEl", 2);
|
|
22507
|
+
__decorateClass([
|
|
22508
|
+
query8(".dropdown")
|
|
22509
|
+
], CsDateRangePickerInternal.prototype, "_dropdownEl", 2);
|
|
22510
|
+
|
|
22511
|
+
// src/date-range-picker/index.ts
|
|
22512
|
+
var CsDateRangePicker = class extends CsDateRangePickerInternal {
|
|
22513
|
+
};
|
|
22514
|
+
customElements.define("cs-date-range-picker", CsDateRangePicker);
|
|
22515
|
+
|
|
22516
|
+
// src/attribute-editor/internal.ts
|
|
22517
|
+
import { css as css136, html as html63, nothing as nothing35 } from "lit";
|
|
22518
|
+
import { property as property62 } from "lit/decorators.js";
|
|
22519
|
+
|
|
22520
|
+
// src/attribute-editor/styles.ts
|
|
22521
|
+
import { css as css134 } from "lit";
|
|
22522
|
+
var componentStyles60 = css134`
|
|
22523
|
+
.empty-appear {
|
|
22524
|
+
animation: awsui_awsui-motion-fade-in_n4qlp_3vim8_1 var(--motion-duration-transition-show-paced-t8d1os, 180ms) var(--motion-easing-transition-show-paced-x2k7uh, ease-out);
|
|
22525
|
+
}
|
|
22526
|
+
@keyframes awsui_awsui-motion-fade-in_n4qlp_3vim8_1 {
|
|
22527
|
+
from {
|
|
22528
|
+
opacity: 0.2;
|
|
22529
|
+
}
|
|
22530
|
+
to {
|
|
22531
|
+
opacity: 1;
|
|
22532
|
+
}
|
|
22533
|
+
}
|
|
22534
|
+
@media (prefers-reduced-motion: reduce) {
|
|
22535
|
+
.empty-appear {
|
|
22536
|
+
animation: none;
|
|
22537
|
+
transition: none;
|
|
22538
|
+
}
|
|
22539
|
+
}
|
|
22540
|
+
.awsui-motion-disabled .empty-appear, .awsui-mode-entering .empty-appear {
|
|
22541
|
+
animation: none;
|
|
22542
|
+
transition: none;
|
|
22543
|
+
}
|
|
22544
|
+
|
|
22545
|
+
.root {
|
|
22546
|
+
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
22547
|
+
line-height: var(--line-height-body-m-2mh3ke, 20px);
|
|
22548
|
+
color: var(--color-text-body-default-vvtq8u, #0f141a);
|
|
22549
|
+
font-weight: 400;
|
|
22550
|
+
font-family: var(--font-family-base-gmnpzl, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
22551
|
+
-webkit-font-smoothing: auto;
|
|
22552
|
+
-moz-osx-font-smoothing: auto;
|
|
22553
|
+
display: grid;
|
|
22554
|
+
grid-template-rows: min-content;
|
|
22555
|
+
gap: var(--space-grid-gutter-whc3jp, 20px);
|
|
22556
|
+
align-items: start;
|
|
22557
|
+
}
|
|
22558
|
+
|
|
22559
|
+
.empty {
|
|
22560
|
+
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
22561
|
+
line-height: var(--line-height-body-m-2mh3ke, 20px);
|
|
22562
|
+
color: var(--color-text-empty-tlohug, #656871);
|
|
22563
|
+
grid-column: 1/-1;
|
|
22564
|
+
}
|
|
22565
|
+
|
|
22566
|
+
.row {
|
|
22567
|
+
display: contents;
|
|
22568
|
+
}
|
|
22569
|
+
|
|
22570
|
+
.divider {
|
|
22571
|
+
grid-column: 1/-1;
|
|
22572
|
+
border-block-start: var(--border-divider-section-width-uwo8my, 1px) solid var(--color-border-divider-default-nr68jt, #c6c6cd);
|
|
22573
|
+
}
|
|
22574
|
+
|
|
22575
|
+
.field {
|
|
22576
|
+
min-inline-size: 40px;
|
|
22577
|
+
}
|
|
22578
|
+
|
|
22579
|
+
.additional-info {
|
|
22580
|
+
color: var(--color-text-form-secondary-1nm780, #656871);
|
|
22581
|
+
font-size: var(--font-size-body-s-smc8cv, 12px);
|
|
22582
|
+
line-height: var(--line-height-body-s-nu5hx1, 16px);
|
|
22583
|
+
letter-spacing: var(--letter-spacing-body-s-gq78ok, 0.005em);
|
|
22584
|
+
display: block;
|
|
22585
|
+
word-wrap: break-word;
|
|
22586
|
+
margin-block-start: var(--space-xxs-hwfkai, 4px);
|
|
22587
|
+
|
|
22588
|
+
}
|
|
22589
|
+
.additional-info > a {
|
|
22590
|
+
text-underline-offset: 0.3em;
|
|
22591
|
+
text-decoration-thickness: 1px;
|
|
22592
|
+
color: var(--awsui-style-color-default-6b9ypa, var(--color-text-link-default-hude44, #006ce0));
|
|
22593
|
+
font-weight: inherit;
|
|
22594
|
+
letter-spacing: normal;
|
|
22595
|
+
text-decoration-line: underline;
|
|
22596
|
+
text-decoration-color: currentColor;
|
|
22597
|
+
transition-property: color, -webkit-text-decoration;
|
|
22598
|
+
transition-property: color, text-decoration;
|
|
22599
|
+
transition-property: color, text-decoration, -webkit-text-decoration;
|
|
22600
|
+
transition-duration: var(--motion-duration-refresh-only-medium-5rbn3k, 165ms);
|
|
22601
|
+
}
|
|
22602
|
+
@media (prefers-reduced-motion: reduce) {
|
|
22603
|
+
.additional-info > a {
|
|
22604
|
+
animation: none;
|
|
22605
|
+
transition: none;
|
|
22606
|
+
}
|
|
22607
|
+
}
|
|
22608
|
+
.awsui-motion-disabled .additional-info > a, .awsui-mode-entering .additional-info > a {
|
|
22609
|
+
animation: none;
|
|
22610
|
+
transition: none;
|
|
22611
|
+
}
|
|
22612
|
+
.additional-info > a:hover {
|
|
22613
|
+
cursor: pointer;
|
|
22614
|
+
color: var(--awsui-style-color-hover-6b9ypa, var(--color-text-link-hover-2hfec2, #002b66));
|
|
22615
|
+
}
|
|
22616
|
+
.additional-info > a:focus {
|
|
22617
|
+
outline: none;
|
|
22618
|
+
}
|
|
22619
|
+
.additional-info > a:active {
|
|
22620
|
+
color: var(--awsui-style-color-active-6b9ypa, var(--color-text-link-hover-2hfec2, #002b66));
|
|
22621
|
+
}
|
|
22622
|
+
.additional-info > a:active, .additional-info > a:focus, .additional-info > a:hover {
|
|
22623
|
+
text-decoration-line: underline;
|
|
22624
|
+
text-decoration-color: currentColor;
|
|
22625
|
+
}
|
|
22626
|
+
|
|
22627
|
+
.add-row {
|
|
22628
|
+
grid-column: 1/-1;
|
|
22629
|
+
}
|
|
22630
|
+
|
|
22631
|
+
.remove-button-container {
|
|
22632
|
+
display: inline-block;
|
|
22633
|
+
}
|
|
22634
|
+
|
|
22635
|
+
.remove-button-field-padding {
|
|
22636
|
+
padding-block-start: calc(var(--space-xxs-hwfkai, 4px) + var(--line-height-body-m-2mh3ke, 20px));
|
|
22637
|
+
}
|
|
22638
|
+
|
|
22639
|
+
.remove-button-own-row {
|
|
22640
|
+
justify-self: end;
|
|
22641
|
+
}
|
|
22642
|
+
`;
|
|
22643
|
+
|
|
22644
|
+
// src/input/internal.ts
|
|
22645
|
+
import { css as css135, html as html62, nothing as nothing34 } from "lit";
|
|
22646
|
+
import { property as property61 } from "lit/decorators.js";
|
|
22647
|
+
import { classMap as classMap50 } from "lit/directives/class-map.js";
|
|
22648
|
+
import { ifDefined as ifDefined33 } from "lit/directives/if-defined.js";
|
|
22649
|
+
import { consume as consume4 } from "@lit/context";
|
|
22650
|
+
var Base12 = FormAssociatedMixin(CsBaseElement);
|
|
22651
|
+
var hostStyles61 = css135`:host { display: block; }`;
|
|
22652
|
+
var CsInputInternal = class extends Base12 {
|
|
22653
|
+
constructor() {
|
|
22654
|
+
super(...arguments);
|
|
22655
|
+
this._formFieldCtx = defaultFormFieldContext;
|
|
22656
|
+
this.value = "";
|
|
22657
|
+
this.type = "text";
|
|
22658
|
+
this.placeholder = "";
|
|
22659
|
+
this.readOnly = false;
|
|
22660
|
+
this.invalid = false;
|
|
22661
|
+
this.warning = false;
|
|
22662
|
+
this.autoFocus = false;
|
|
22663
|
+
this.inputMode = "";
|
|
22664
|
+
this.ariaLabel = null;
|
|
22665
|
+
this.ariaDescribedby = null;
|
|
22666
|
+
this.clearAriaLabel = "";
|
|
22667
|
+
this._onInput = (e) => {
|
|
22668
|
+
const target = e.target;
|
|
22669
|
+
this.value = target.value;
|
|
22670
|
+
const detail = { value: this.value };
|
|
22671
|
+
fireNonCancelableEvent(this, "change", detail);
|
|
22672
|
+
};
|
|
22673
|
+
this._onBlur = () => {
|
|
22674
|
+
fireNonCancelableEvent(this, "blur", null);
|
|
22675
|
+
};
|
|
22676
|
+
this._onFocus = () => {
|
|
22677
|
+
fireNonCancelableEvent(this, "focus", null);
|
|
22678
|
+
};
|
|
22679
|
+
this._onKeyDown = (e) => {
|
|
22680
|
+
const detail = {
|
|
22681
|
+
keyCode: e.keyCode,
|
|
22682
|
+
key: e.key,
|
|
22683
|
+
ctrlKey: e.ctrlKey,
|
|
22684
|
+
shiftKey: e.shiftKey,
|
|
22685
|
+
altKey: e.altKey,
|
|
22686
|
+
metaKey: e.metaKey,
|
|
22687
|
+
isComposing: e.isComposing
|
|
22688
|
+
};
|
|
22689
|
+
fireNonCancelableEvent(this, "keydown", detail);
|
|
22690
|
+
};
|
|
22691
|
+
this._onKeyUp = (e) => {
|
|
22692
|
+
const detail = {
|
|
22693
|
+
keyCode: e.keyCode,
|
|
22694
|
+
key: e.key,
|
|
22695
|
+
ctrlKey: e.ctrlKey,
|
|
22696
|
+
shiftKey: e.shiftKey,
|
|
22697
|
+
altKey: e.altKey,
|
|
22698
|
+
metaKey: e.metaKey,
|
|
22699
|
+
isComposing: e.isComposing
|
|
22700
|
+
};
|
|
22701
|
+
fireNonCancelableEvent(this, "keyup", detail);
|
|
22702
|
+
};
|
|
22703
|
+
this._onClear = () => {
|
|
22704
|
+
this.value = "";
|
|
22705
|
+
const detail = { value: "" };
|
|
22706
|
+
fireNonCancelableEvent(this, "change", detail);
|
|
22707
|
+
this.focus();
|
|
22708
|
+
};
|
|
22709
|
+
}
|
|
22710
|
+
static {
|
|
22711
|
+
this.styles = [sharedStyles, componentStyles44, hostStyles61];
|
|
22712
|
+
}
|
|
22713
|
+
focus(options) {
|
|
22714
|
+
this._getInput()?.focus(options);
|
|
22715
|
+
}
|
|
22716
|
+
select() {
|
|
22717
|
+
this._getInput()?.select();
|
|
22718
|
+
}
|
|
22719
|
+
_getInput() {
|
|
22720
|
+
return this.shadowRoot?.querySelector("input");
|
|
22721
|
+
}
|
|
22722
|
+
get _isInvalid() {
|
|
22723
|
+
return this.invalid || this._formFieldCtx.invalid;
|
|
22724
|
+
}
|
|
22725
|
+
get _isWarning() {
|
|
22726
|
+
return (this.warning || this._formFieldCtx.warning) && !this._isInvalid;
|
|
22727
|
+
}
|
|
22728
|
+
get _resolvedAriaDescribedby() {
|
|
22729
|
+
const parts = [];
|
|
22730
|
+
if (this.ariaDescribedby) parts.push(this.ariaDescribedby);
|
|
22731
|
+
if (this._formFieldCtx.ariaDescribedby) parts.push(this._formFieldCtx.ariaDescribedby);
|
|
22732
|
+
return parts.length ? parts.join(" ") : void 0;
|
|
22733
|
+
}
|
|
22734
|
+
get _showClearButton() {
|
|
22735
|
+
return !!this.clearAriaLabel && this.value.length > 0 && !this.disabled && !this.readOnly;
|
|
22736
|
+
}
|
|
22737
|
+
render() {
|
|
22738
|
+
const inputClasses = {
|
|
22739
|
+
"input": true,
|
|
22740
|
+
"input-readonly": this.readOnly,
|
|
22741
|
+
"input-invalid": this._isInvalid,
|
|
22742
|
+
"input-warning": this._isWarning,
|
|
22743
|
+
"input-disabled": this.disabled,
|
|
22744
|
+
"input-has-clear-button": this._showClearButton,
|
|
22745
|
+
[`input-type-${this.type}`]: true
|
|
22746
|
+
};
|
|
22747
|
+
const controlId = this._formFieldCtx.controlId || void 0;
|
|
22748
|
+
const ariaLabelledby = this._formFieldCtx.ariaLabelledby || void 0;
|
|
22749
|
+
return html62`
|
|
22750
|
+
<div class="root">
|
|
22751
|
+
<div class="input-container">
|
|
22752
|
+
<input
|
|
22753
|
+
class=${classMap50(inputClasses)}
|
|
22754
|
+
type=${this.type}
|
|
22755
|
+
.value=${this.value}
|
|
22756
|
+
placeholder=${ifDefined33(this.placeholder || void 0)}
|
|
22757
|
+
?disabled=${this.disabled}
|
|
22758
|
+
?readonly=${this.readOnly}
|
|
22759
|
+
?autofocus=${this.autoFocus}
|
|
22760
|
+
inputmode=${ifDefined33(this.inputMode || void 0)}
|
|
22761
|
+
step=${ifDefined33(this.step)}
|
|
22762
|
+
id=${ifDefined33(controlId)}
|
|
22763
|
+
aria-label=${ifDefined33(this.ariaLabel || void 0)}
|
|
22764
|
+
aria-labelledby=${ifDefined33(!this.ariaLabel ? ariaLabelledby : void 0)}
|
|
22765
|
+
aria-describedby=${ifDefined33(this._resolvedAriaDescribedby)}
|
|
22766
|
+
aria-invalid=${ifDefined33(this._isInvalid ? "true" : void 0)}
|
|
22767
|
+
@input=${this._onInput}
|
|
22768
|
+
@blur=${this._onBlur}
|
|
22769
|
+
@focus=${this._onFocus}
|
|
22770
|
+
@keydown=${this._onKeyDown}
|
|
22771
|
+
@keyup=${this._onKeyUp}
|
|
22772
|
+
/>
|
|
22773
|
+
${this._showClearButton ? html62`
|
|
22774
|
+
<span class="input-icon-right">
|
|
22775
|
+
<button
|
|
22776
|
+
type="button"
|
|
22777
|
+
aria-label=${this.clearAriaLabel}
|
|
22778
|
+
@click=${this._onClear}
|
|
22779
|
+
>
|
|
22780
|
+
<cs-icon name="close" size="small"></cs-icon>
|
|
22781
|
+
</button>
|
|
22782
|
+
</span>
|
|
22783
|
+
` : nothing34}
|
|
22784
|
+
</div>
|
|
22785
|
+
</div>
|
|
22786
|
+
`;
|
|
22787
|
+
}
|
|
22788
|
+
};
|
|
22789
|
+
__decorateClass([
|
|
22790
|
+
consume4({ context: formFieldContext, subscribe: true })
|
|
22791
|
+
], CsInputInternal.prototype, "_formFieldCtx", 2);
|
|
22792
|
+
__decorateClass([
|
|
22793
|
+
property61({ type: String })
|
|
22794
|
+
], CsInputInternal.prototype, "value", 2);
|
|
22795
|
+
__decorateClass([
|
|
22796
|
+
property61({ type: String, reflect: true })
|
|
22797
|
+
], CsInputInternal.prototype, "type", 2);
|
|
22798
|
+
__decorateClass([
|
|
22799
|
+
property61({ type: String })
|
|
22800
|
+
], CsInputInternal.prototype, "placeholder", 2);
|
|
22801
|
+
__decorateClass([
|
|
22802
|
+
property61({ type: Boolean, reflect: true })
|
|
22803
|
+
], CsInputInternal.prototype, "readOnly", 2);
|
|
22804
|
+
__decorateClass([
|
|
22805
|
+
property61({ type: Boolean, reflect: true })
|
|
22806
|
+
], CsInputInternal.prototype, "invalid", 2);
|
|
22807
|
+
__decorateClass([
|
|
22808
|
+
property61({ type: Boolean, reflect: true })
|
|
22809
|
+
], CsInputInternal.prototype, "warning", 2);
|
|
22810
|
+
__decorateClass([
|
|
22811
|
+
property61({ type: Boolean })
|
|
22812
|
+
], CsInputInternal.prototype, "autoFocus", 2);
|
|
22813
|
+
__decorateClass([
|
|
22814
|
+
property61({ type: String })
|
|
22815
|
+
], CsInputInternal.prototype, "inputMode", 2);
|
|
22816
|
+
__decorateClass([
|
|
22817
|
+
property61({ type: Number })
|
|
22818
|
+
], CsInputInternal.prototype, "step", 2);
|
|
22819
|
+
__decorateClass([
|
|
22820
|
+
property61({ type: String })
|
|
22821
|
+
], CsInputInternal.prototype, "ariaLabel", 2);
|
|
22822
|
+
__decorateClass([
|
|
22823
|
+
property61({ type: String })
|
|
22824
|
+
], CsInputInternal.prototype, "ariaDescribedby", 2);
|
|
22825
|
+
__decorateClass([
|
|
22826
|
+
property61({ type: String })
|
|
22827
|
+
], CsInputInternal.prototype, "clearAriaLabel", 2);
|
|
22828
|
+
|
|
22829
|
+
// src/input/index.ts
|
|
22830
|
+
var CsInput = class extends CsInputInternal {
|
|
22831
|
+
};
|
|
22832
|
+
customElements.define("cs-input", CsInput);
|
|
22833
|
+
|
|
22834
|
+
// src/attribute-editor/internal.ts
|
|
22835
|
+
var hostStyles62 = css136`:host { display: block; }`;
|
|
22836
|
+
function resolveText(value, item, itemIndex) {
|
|
22837
|
+
if (typeof value === "function") {
|
|
22838
|
+
const result = value(item, itemIndex);
|
|
22839
|
+
return result != null ? String(result) : "";
|
|
22840
|
+
}
|
|
22841
|
+
return value != null ? String(value) : "";
|
|
22842
|
+
}
|
|
22843
|
+
var CsAttributeEditorInternal = class extends CsBaseElement {
|
|
22844
|
+
constructor() {
|
|
22845
|
+
super(...arguments);
|
|
22846
|
+
this.items = [];
|
|
22847
|
+
this.definition = [];
|
|
22848
|
+
this.addButtonText = "Add attribute";
|
|
22849
|
+
this.removeButtonText = "Remove";
|
|
22850
|
+
this.empty = "";
|
|
22851
|
+
this.disableAddButton = false;
|
|
22852
|
+
this._handleAddClick = (e) => {
|
|
22853
|
+
if (!(e instanceof CustomEvent)) return;
|
|
22854
|
+
fireNonCancelableEvent(this, "addButtonClick", {});
|
|
22855
|
+
};
|
|
22856
|
+
}
|
|
22857
|
+
static {
|
|
22858
|
+
this.styles = [sharedStyles, componentStyles60, hostStyles62];
|
|
22859
|
+
}
|
|
22860
|
+
_handleRemoveClick(itemIndex) {
|
|
22861
|
+
return (e) => {
|
|
22862
|
+
if (!(e instanceof CustomEvent)) return;
|
|
22863
|
+
const detail = { itemIndex };
|
|
22864
|
+
fireNonCancelableEvent(this, "removeButtonClick", detail);
|
|
22865
|
+
};
|
|
22866
|
+
}
|
|
22867
|
+
_renderRow(item, itemIndex) {
|
|
22868
|
+
const removable = this.isItemRemovable ? this.isItemRemovable(item) : true;
|
|
22869
|
+
return html63`
|
|
22870
|
+
<div class="row" data-row-index="${itemIndex}">
|
|
22871
|
+
${this.definition.map((def) => {
|
|
22872
|
+
const label = resolveText(def.label, item, itemIndex);
|
|
22873
|
+
const errorText = resolveText(def.errorText, item, itemIndex);
|
|
22874
|
+
const constraintText = resolveText(def.constraintText, item, itemIndex);
|
|
22875
|
+
return html63`
|
|
22876
|
+
<div class="field">
|
|
22877
|
+
<cs-form-field
|
|
22878
|
+
.label=${label}
|
|
22879
|
+
.errorText=${errorText}
|
|
22880
|
+
.constraintText=${constraintText}
|
|
22881
|
+
>
|
|
22882
|
+
<cs-input .ariaLabel=${label}></cs-input>
|
|
22883
|
+
</cs-form-field>
|
|
22884
|
+
</div>
|
|
22885
|
+
`;
|
|
22886
|
+
})}
|
|
22887
|
+
${removable ? html63`
|
|
22888
|
+
<div class="remove-button-container remove-button-field-padding">
|
|
22889
|
+
<cs-button
|
|
22890
|
+
variant="normal"
|
|
22891
|
+
.ariaLabel=${this.removeButtonText}
|
|
22892
|
+
@click=${this._handleRemoveClick(itemIndex)}
|
|
22893
|
+
>${this.removeButtonText}</cs-button>
|
|
22894
|
+
</div>
|
|
22895
|
+
` : nothing35}
|
|
22896
|
+
</div>
|
|
22897
|
+
`;
|
|
22898
|
+
}
|
|
22899
|
+
render() {
|
|
22900
|
+
const hasItems = this.items.length > 0;
|
|
22901
|
+
const cols = this.definition.length;
|
|
22902
|
+
const gridCols = cols > 0 ? `repeat(${cols}, 1fr) auto` : "1fr";
|
|
22903
|
+
return html63`
|
|
22904
|
+
<div class="root" style="grid-template-columns: ${gridCols}">
|
|
22905
|
+
${!hasItems && this.empty ? html63`<div class="empty empty-appear">${this.empty}</div>` : nothing35}
|
|
22906
|
+
${this.items.map((item, idx) => html63`
|
|
22907
|
+
${idx > 0 ? html63`<div class="divider"></div>` : nothing35}
|
|
22908
|
+
${this._renderRow(item, idx)}
|
|
22909
|
+
`)}
|
|
22910
|
+
<div class="add-row">
|
|
22911
|
+
<cs-button
|
|
22912
|
+
variant="normal"
|
|
22913
|
+
icon-name="add-plus"
|
|
22914
|
+
?disabled=${this.disableAddButton}
|
|
22915
|
+
@click=${this._handleAddClick}
|
|
22916
|
+
>${this.addButtonText}</cs-button>
|
|
22917
|
+
</div>
|
|
22918
|
+
</div>
|
|
22919
|
+
`;
|
|
22920
|
+
}
|
|
22921
|
+
};
|
|
22922
|
+
__decorateClass([
|
|
22923
|
+
property62({ attribute: false })
|
|
22924
|
+
], CsAttributeEditorInternal.prototype, "items", 2);
|
|
22925
|
+
__decorateClass([
|
|
22926
|
+
property62({ attribute: false })
|
|
22927
|
+
], CsAttributeEditorInternal.prototype, "definition", 2);
|
|
22928
|
+
__decorateClass([
|
|
22929
|
+
property62({ type: String })
|
|
22930
|
+
], CsAttributeEditorInternal.prototype, "addButtonText", 2);
|
|
22931
|
+
__decorateClass([
|
|
22932
|
+
property62({ type: String })
|
|
22933
|
+
], CsAttributeEditorInternal.prototype, "removeButtonText", 2);
|
|
22934
|
+
__decorateClass([
|
|
22935
|
+
property62({ type: String })
|
|
22936
|
+
], CsAttributeEditorInternal.prototype, "empty", 2);
|
|
22937
|
+
__decorateClass([
|
|
22938
|
+
property62({ attribute: false })
|
|
22939
|
+
], CsAttributeEditorInternal.prototype, "isItemRemovable", 2);
|
|
22940
|
+
__decorateClass([
|
|
22941
|
+
property62({ type: Boolean })
|
|
22942
|
+
], CsAttributeEditorInternal.prototype, "disableAddButton", 2);
|
|
22943
|
+
|
|
22944
|
+
// src/attribute-editor/index.ts
|
|
22945
|
+
var CsAttributeEditor = class extends CsAttributeEditorInternal {
|
|
22946
|
+
};
|
|
22947
|
+
customElements.define("cs-attribute-editor", CsAttributeEditor);
|
|
22948
|
+
|
|
22949
|
+
// src/tag-editor/internal.ts
|
|
22950
|
+
import { css as css138, html as html64, nothing as nothing36 } from "lit";
|
|
22951
|
+
import { property as property63 } from "lit/decorators.js";
|
|
22952
|
+
import { classMap as classMap51 } from "lit/directives/class-map.js";
|
|
22953
|
+
|
|
22954
|
+
// src/tag-editor/styles.ts
|
|
22955
|
+
import { css as css137 } from "lit";
|
|
22956
|
+
var componentStyles61 = css137`
|
|
22957
|
+
.root {
|
|
22958
|
+
/* used in test utils */
|
|
22959
|
+
}
|
|
22960
|
+
|
|
22961
|
+
.loading {
|
|
22962
|
+
/* used in test utils */
|
|
22963
|
+
}
|
|
22964
|
+
|
|
22965
|
+
.undo-button {
|
|
22966
|
+
-webkit-font-smoothing: var(--font-smoothing-webkit-oemolo, antialiased);
|
|
22967
|
+
-moz-osx-font-smoothing: var(--font-smoothing-moz-osx-hbm0aq, grayscale);
|
|
22968
|
+
text-underline-offset: 0.25em;
|
|
22969
|
+
text-decoration-thickness: 1px;
|
|
22970
|
+
color: var(--awsui-style-color-default-6b9ypa, var(--color-text-link-default-hude44, #006ce0));
|
|
22971
|
+
font-weight: var(--font-link-button-weight-vslyg9, 700);
|
|
22972
|
+
letter-spacing: var(--font-link-button-letter-spacing-imtxwq, 0.005em);
|
|
22973
|
+
text-decoration-line: underline;
|
|
22974
|
+
text-decoration-color: var(--color-text-link-button-underline-z4wjnv, transparent);
|
|
22975
|
+
transition-property: color, -webkit-text-decoration;
|
|
22976
|
+
transition-property: color, text-decoration;
|
|
22977
|
+
transition-property: color, text-decoration, -webkit-text-decoration;
|
|
22978
|
+
transition-duration: var(--motion-duration-refresh-only-medium-5rbn3k, 165ms);
|
|
22979
|
+
}
|
|
22980
|
+
@media (prefers-reduced-motion: reduce) {
|
|
22981
|
+
.undo-button {
|
|
22982
|
+
animation: none;
|
|
22983
|
+
transition: none;
|
|
22984
|
+
}
|
|
22985
|
+
}
|
|
22986
|
+
.awsui-motion-disabled .undo-button, .awsui-mode-entering .undo-button {
|
|
22987
|
+
animation: none;
|
|
22988
|
+
transition: none;
|
|
22989
|
+
}
|
|
22990
|
+
.undo-button:hover {
|
|
22991
|
+
cursor: pointer;
|
|
22992
|
+
color: var(--awsui-style-color-hover-6b9ypa, var(--color-text-link-hover-2hfec2, #002b66));
|
|
22993
|
+
}
|
|
22994
|
+
.undo-button:focus {
|
|
22995
|
+
outline: none;
|
|
22996
|
+
}
|
|
22997
|
+
.undo-button:active {
|
|
22998
|
+
color: var(--awsui-style-color-active-6b9ypa, var(--color-text-link-hover-2hfec2, #002b66));
|
|
22999
|
+
}
|
|
23000
|
+
.undo-button:active, .undo-button:focus, .undo-button:hover {
|
|
23001
|
+
text-decoration-line: underline;
|
|
23002
|
+
text-decoration-color: var(--color-text-link-button-underline-hover-cn3mqh, transparent);
|
|
23003
|
+
}
|
|
23004
|
+
:host-context([data-awsui-focus-visible=true]) .undo-button:focus {
|
|
23005
|
+
outline: thin dotted;
|
|
23006
|
+
outline: var(--border-link-focus-ring-outline-1p0hnu, 0);
|
|
23007
|
+
outline-offset: 2px;
|
|
23008
|
+
outline-color: var(--color-border-item-focused-uk47pl, #006ce0);
|
|
23009
|
+
border-start-start-radius: var(--border-radius-control-default-focus-ring-1uabki, 4px);
|
|
23010
|
+
border-start-end-radius: var(--border-radius-control-default-focus-ring-1uabki, 4px);
|
|
23011
|
+
border-end-start-radius: var(--border-radius-control-default-focus-ring-1uabki, 4px);
|
|
23012
|
+
border-end-end-radius: var(--border-radius-control-default-focus-ring-1uabki, 4px);
|
|
23013
|
+
box-shadow: 0 0 0 var(--border-link-focus-ring-shadow-spread-39uvxr, 2px) var(--color-border-item-focused-uk47pl, #006ce0);
|
|
23014
|
+
}
|
|
23015
|
+
`;
|
|
23016
|
+
|
|
23017
|
+
// src/tag-editor/internal.ts
|
|
23018
|
+
var hostStyles63 = css138`
|
|
23019
|
+
:host { display: block; }
|
|
23020
|
+
.tag-row {
|
|
23021
|
+
display: grid;
|
|
23022
|
+
grid-template-columns: 1fr 1fr auto;
|
|
23023
|
+
gap: var(--space-grid-gutter-whc3jp, 20px);
|
|
23024
|
+
align-items: start;
|
|
23025
|
+
padding-block: var(--space-xs-ctmojp, 8px);
|
|
23026
|
+
}
|
|
23027
|
+
.tag-row-removed {
|
|
23028
|
+
opacity: 0.5;
|
|
23029
|
+
}
|
|
23030
|
+
.tag-list {
|
|
23031
|
+
display: flex;
|
|
23032
|
+
flex-direction: column;
|
|
23033
|
+
}
|
|
23034
|
+
.add-section {
|
|
23035
|
+
margin-block-start: var(--space-s-k3fkj0, 12px);
|
|
23036
|
+
}
|
|
23037
|
+
.action-cell {
|
|
23038
|
+
padding-block-start: calc(var(--space-xxs-hwfkai, 4px) + var(--line-height-body-m-2mh3ke, 20px));
|
|
23039
|
+
}
|
|
23040
|
+
`;
|
|
23041
|
+
var CsTagEditorInternal = class extends CsBaseElement {
|
|
23042
|
+
constructor() {
|
|
23043
|
+
super(...arguments);
|
|
23044
|
+
this.tags = [];
|
|
23045
|
+
this.allowedCharacterPattern = "";
|
|
23046
|
+
this.keyPlaceholder = "";
|
|
23047
|
+
this.valuePlaceholder = "";
|
|
23048
|
+
this.addButtonText = "Add tag";
|
|
23049
|
+
this.removeButtonText = "Remove";
|
|
23050
|
+
this.undoButtonText = "Undo";
|
|
23051
|
+
this.loading = false;
|
|
23052
|
+
this._handleAdd = (e) => {
|
|
23053
|
+
if (!(e instanceof CustomEvent)) return;
|
|
23054
|
+
this._onAdd();
|
|
23055
|
+
};
|
|
23056
|
+
}
|
|
23057
|
+
static {
|
|
23058
|
+
this.styles = [sharedStyles, componentStyles61, hostStyles63];
|
|
23059
|
+
}
|
|
23060
|
+
_emitChange(updatedTags) {
|
|
23061
|
+
const detail = { tags: updatedTags, valid: true };
|
|
23062
|
+
fireNonCancelableEvent(this, "change", detail);
|
|
23063
|
+
}
|
|
23064
|
+
_onAdd() {
|
|
23065
|
+
const updatedTags = [
|
|
23066
|
+
...this.tags,
|
|
23067
|
+
{ key: "", value: "", existing: false }
|
|
23068
|
+
];
|
|
23069
|
+
this._emitChange(updatedTags);
|
|
23070
|
+
}
|
|
23071
|
+
_onRemove(index) {
|
|
23072
|
+
const tag = this.tags[index];
|
|
23073
|
+
if (tag.existing) {
|
|
23074
|
+
const updatedTags = this.tags.map(
|
|
23075
|
+
(t, i) => i === index ? { ...t, markedForRemoval: true } : t
|
|
23076
|
+
);
|
|
23077
|
+
this._emitChange(updatedTags);
|
|
23078
|
+
} else {
|
|
23079
|
+
const updatedTags = this.tags.filter((_, i) => i !== index);
|
|
23080
|
+
this._emitChange(updatedTags);
|
|
23081
|
+
}
|
|
23082
|
+
}
|
|
23083
|
+
_onUndo(index) {
|
|
23084
|
+
const updatedTags = this.tags.map(
|
|
23085
|
+
(t, i) => i === index ? { ...t, markedForRemoval: false } : t
|
|
23086
|
+
);
|
|
23087
|
+
this._emitChange(updatedTags);
|
|
23088
|
+
}
|
|
23089
|
+
_onKeyChange(index, newKey) {
|
|
23090
|
+
const updatedTags = this.tags.map(
|
|
23091
|
+
(t, i) => i === index ? { ...t, key: newKey } : t
|
|
23092
|
+
);
|
|
23093
|
+
this._emitChange(updatedTags);
|
|
23094
|
+
}
|
|
23095
|
+
_onValueChange(index, newValue) {
|
|
23096
|
+
const updatedTags = this.tags.map(
|
|
23097
|
+
(t, i) => i === index ? { ...t, value: newValue } : t
|
|
23098
|
+
);
|
|
23099
|
+
this._emitChange(updatedTags);
|
|
23100
|
+
}
|
|
23101
|
+
_handleAction(index, action) {
|
|
23102
|
+
return (e) => {
|
|
23103
|
+
if (!(e instanceof CustomEvent)) return;
|
|
23104
|
+
if (action === "undo") this._onUndo(index);
|
|
23105
|
+
else this._onRemove(index);
|
|
23106
|
+
};
|
|
23107
|
+
}
|
|
23108
|
+
_renderTagRow(tag, index) {
|
|
23109
|
+
const isMarked = !!tag.markedForRemoval;
|
|
23110
|
+
const rowClasses = { "tag-row": true, "tag-row-removed": isMarked };
|
|
23111
|
+
const keyLabel = this.i18nStrings?.keyHeader ?? "Key";
|
|
23112
|
+
const valueLabel = this.i18nStrings?.valueHeader ?? "Value";
|
|
23113
|
+
return html64`
|
|
23114
|
+
<div class=${classMap51(rowClasses)} data-row-index="${index}">
|
|
23115
|
+
<cs-form-field .label=${keyLabel}>
|
|
23116
|
+
<cs-input
|
|
23117
|
+
.value=${tag.key}
|
|
23118
|
+
.placeholder=${this.keyPlaceholder}
|
|
23119
|
+
.ariaLabel=${keyLabel}
|
|
23120
|
+
?disabled=${isMarked}
|
|
23121
|
+
@change=${(e) => this._onKeyChange(index, e.detail.value)}
|
|
23122
|
+
></cs-input>
|
|
23123
|
+
</cs-form-field>
|
|
23124
|
+
<cs-form-field .label=${valueLabel}>
|
|
23125
|
+
<cs-input
|
|
23126
|
+
.value=${tag.value}
|
|
23127
|
+
.placeholder=${this.valuePlaceholder}
|
|
23128
|
+
.ariaLabel=${valueLabel}
|
|
23129
|
+
?disabled=${isMarked}
|
|
23130
|
+
@change=${(e) => this._onValueChange(index, e.detail.value)}
|
|
23131
|
+
></cs-input>
|
|
23132
|
+
</cs-form-field>
|
|
23133
|
+
<div class="action-cell">
|
|
23134
|
+
${isMarked ? html64`
|
|
23135
|
+
<cs-button
|
|
23136
|
+
variant="normal"
|
|
23137
|
+
@click=${this._handleAction(index, "undo")}
|
|
23138
|
+
>${this.undoButtonText}</cs-button>
|
|
23139
|
+
` : html64`
|
|
23140
|
+
<cs-button
|
|
23141
|
+
variant="normal"
|
|
23142
|
+
@click=${this._handleAction(index, "remove")}
|
|
23143
|
+
>${this.removeButtonText}</cs-button>
|
|
23144
|
+
`}
|
|
23145
|
+
</div>
|
|
23146
|
+
</div>
|
|
23147
|
+
`;
|
|
23148
|
+
}
|
|
23149
|
+
render() {
|
|
23150
|
+
const limitReached = this.tagLimit != null && this.tags.length >= this.tagLimit;
|
|
23151
|
+
return html64`
|
|
23152
|
+
<div class="root">
|
|
23153
|
+
${this.loading ? html64`<div class="loading">Loading...</div>` : nothing36}
|
|
23154
|
+
<div class="tag-list">
|
|
23155
|
+
${this.tags.length === 0 && !this.loading ? html64`<div>${this.i18nStrings?.emptyTags ?? "No tags"}</div>` : nothing36}
|
|
23156
|
+
${this.tags.map((tag, idx) => this._renderTagRow(tag, idx))}
|
|
23157
|
+
</div>
|
|
23158
|
+
<div class="add-section">
|
|
23159
|
+
<cs-button
|
|
23160
|
+
variant="normal"
|
|
23161
|
+
icon-name="add-plus"
|
|
23162
|
+
?disabled=${limitReached}
|
|
23163
|
+
@click=${this._handleAdd}
|
|
23164
|
+
>${this.addButtonText}</cs-button>
|
|
23165
|
+
</div>
|
|
23166
|
+
</div>
|
|
23167
|
+
`;
|
|
23168
|
+
}
|
|
23169
|
+
};
|
|
23170
|
+
__decorateClass([
|
|
23171
|
+
property63({ attribute: false })
|
|
23172
|
+
], CsTagEditorInternal.prototype, "tags", 2);
|
|
23173
|
+
__decorateClass([
|
|
23174
|
+
property63({ attribute: false })
|
|
23175
|
+
], CsTagEditorInternal.prototype, "keysRequest", 2);
|
|
23176
|
+
__decorateClass([
|
|
23177
|
+
property63({ attribute: false })
|
|
23178
|
+
], CsTagEditorInternal.prototype, "valuesRequest", 2);
|
|
23179
|
+
__decorateClass([
|
|
23180
|
+
property63({ type: String })
|
|
23181
|
+
], CsTagEditorInternal.prototype, "allowedCharacterPattern", 2);
|
|
23182
|
+
__decorateClass([
|
|
23183
|
+
property63({ type: String })
|
|
23184
|
+
], CsTagEditorInternal.prototype, "keyPlaceholder", 2);
|
|
23185
|
+
__decorateClass([
|
|
23186
|
+
property63({ type: String })
|
|
23187
|
+
], CsTagEditorInternal.prototype, "valuePlaceholder", 2);
|
|
23188
|
+
__decorateClass([
|
|
23189
|
+
property63({ type: String })
|
|
23190
|
+
], CsTagEditorInternal.prototype, "addButtonText", 2);
|
|
23191
|
+
__decorateClass([
|
|
23192
|
+
property63({ type: String })
|
|
23193
|
+
], CsTagEditorInternal.prototype, "removeButtonText", 2);
|
|
23194
|
+
__decorateClass([
|
|
23195
|
+
property63({ type: String })
|
|
23196
|
+
], CsTagEditorInternal.prototype, "undoButtonText", 2);
|
|
23197
|
+
__decorateClass([
|
|
23198
|
+
property63({ type: Boolean })
|
|
23199
|
+
], CsTagEditorInternal.prototype, "loading", 2);
|
|
23200
|
+
__decorateClass([
|
|
23201
|
+
property63({ type: Number })
|
|
23202
|
+
], CsTagEditorInternal.prototype, "tagLimit", 2);
|
|
23203
|
+
__decorateClass([
|
|
23204
|
+
property63({ attribute: false })
|
|
23205
|
+
], CsTagEditorInternal.prototype, "i18nStrings", 2);
|
|
23206
|
+
|
|
23207
|
+
// src/tag-editor/index.ts
|
|
23208
|
+
var CsTagEditor = class extends CsTagEditorInternal {
|
|
23209
|
+
};
|
|
23210
|
+
customElements.define("cs-tag-editor", CsTagEditor);
|
|
19839
23211
|
export {
|
|
19840
23212
|
CsAlert,
|
|
19841
23213
|
CsAnchorNavigation,
|
|
23214
|
+
CsAttributeEditor,
|
|
19842
23215
|
CsAutosuggest,
|
|
19843
23216
|
CsBadge,
|
|
19844
23217
|
CsBox,
|
|
@@ -19846,6 +23219,7 @@ export {
|
|
|
19846
23219
|
CsButton,
|
|
19847
23220
|
CsButtonDropdown,
|
|
19848
23221
|
CsButtonGroup,
|
|
23222
|
+
CsCalendar,
|
|
19849
23223
|
CsCards,
|
|
19850
23224
|
CsCheckbox,
|
|
19851
23225
|
CsCollectionPreferences,
|
|
@@ -19853,11 +23227,16 @@ export {
|
|
|
19853
23227
|
CsContainer,
|
|
19854
23228
|
CsContentLayout,
|
|
19855
23229
|
CsCopyToClipboard,
|
|
23230
|
+
CsDateInput,
|
|
23231
|
+
CsDatePicker,
|
|
23232
|
+
CsDateRangePicker,
|
|
19856
23233
|
CsErrorBoundary,
|
|
19857
23234
|
CsExpandableSection,
|
|
19858
23235
|
CsFileDropzone,
|
|
19859
23236
|
CsFileInput,
|
|
23237
|
+
CsFileUpload,
|
|
19860
23238
|
CsFlashbar,
|
|
23239
|
+
CsForm,
|
|
19861
23240
|
CsFormField,
|
|
19862
23241
|
CsGrid,
|
|
19863
23242
|
CsHeader,
|
|
@@ -19867,6 +23246,7 @@ export {
|
|
|
19867
23246
|
CsLink,
|
|
19868
23247
|
CsList,
|
|
19869
23248
|
CsLiveRegion,
|
|
23249
|
+
CsModal,
|
|
19870
23250
|
CsMultiselect,
|
|
19871
23251
|
CsPagination,
|
|
19872
23252
|
CsPopover,
|
|
@@ -19883,6 +23263,7 @@ export {
|
|
|
19883
23263
|
CsSteps,
|
|
19884
23264
|
CsTable,
|
|
19885
23265
|
CsTabs,
|
|
23266
|
+
CsTagEditor,
|
|
19886
23267
|
CsTextContent,
|
|
19887
23268
|
CsTiles,
|
|
19888
23269
|
CsToggle,
|