@descope/web-components-ui 3.4.0 → 3.5.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.
@@ -6990,26 +6990,85 @@ class RawTimerButton extends BaseClass$6 {
6990
6990
  .wrapper {
6991
6991
  display: flex;
6992
6992
  flex-direction: column;
6993
- gap: 0.5em;
6994
6993
  align-items: center;
6995
6994
  width: 100%;
6996
6995
  }
6997
- .timer {
6996
+ /* allow timer to grow along the main axis in the wrapper flex container */
6997
+ :host(:not([timer-inside="true"])) .timer {
6998
6998
  flex: 1;
6999
6999
  }
7000
+ :host([timer-inside="true"]) .timer {
7001
+ flex: 0 0 auto;
7002
+ }
7000
7003
  `,
7001
7004
  this,
7002
7005
  );
7003
7006
 
7007
+ this.wrapper = this.shadowRoot.querySelector('.wrapper');
7004
7008
  this.timer = this.shadowRoot.querySelector('.timer');
7005
7009
  this.button = this.shadowRoot.querySelector('.button');
7010
+ this.forwardingSlot = this.shadowRoot.querySelector('.button slot');
7006
7011
 
7007
7012
  this.timer.addEventListener('timer-started', () => this.onTimerStarted());
7008
7013
  this.timer.addEventListener('timer-ended', () => this.onTimerEnded());
7009
7014
 
7015
+ this.syncTimerPlacement();
7016
+
7010
7017
  this.button.addEventListener('click', this.onClick.bind(this));
7011
7018
  }
7012
7019
 
7020
+ static get observedAttributes() {
7021
+ return [
7022
+ ...(super.observedAttributes || []),
7023
+ 'timer-inside',
7024
+ 'timer-position',
7025
+ ];
7026
+ }
7027
+
7028
+ attributeChangedCallback(name, oldValue, newValue) {
7029
+ super.attributeChangedCallback?.(name, oldValue, newValue);
7030
+ if (name === 'timer-inside' || name === 'timer-position') {
7031
+ this.syncTimerPlacement();
7032
+ }
7033
+ }
7034
+
7035
+ get #isTimerInside() {
7036
+ return this.getAttribute('timer-inside') === 'true';
7037
+ }
7038
+
7039
+ get #isReversed() {
7040
+ return this.getAttribute('timer-position') === 'end';
7041
+ }
7042
+
7043
+ syncTimerPlacement() {
7044
+ if (this.#isTimerInside) {
7045
+ this.#placeTimerInsideButton(this.#isReversed);
7046
+ } else {
7047
+ this.#placeTimerOutsideButton();
7048
+ }
7049
+ }
7050
+
7051
+ #placeTimerInsideButton(reversed) {
7052
+ if (reversed) {
7053
+ // timer after label text (right)
7054
+ if (this.timer.previousSibling !== this.forwardingSlot) {
7055
+ this.button.appendChild(this.timer);
7056
+ }
7057
+ } else {
7058
+ // timer before label text (left) — matches default outside position (above/before button)
7059
+ if (this.timer.nextSibling !== this.forwardingSlot) {
7060
+ this.button.insertBefore(this.timer, this.forwardingSlot);
7061
+ }
7062
+ }
7063
+ }
7064
+
7065
+ #placeTimerOutsideButton() {
7066
+ // move timer back as a wrapper sibling, before the button so flex-column puts it above
7067
+ if (this.timer.parentElement !== this.wrapper) {
7068
+ this.wrapper.insertBefore(this.timer, this.button);
7069
+ }
7070
+ }
7071
+
7013
7072
  set onclick(val) {
7014
7073
  this.button.onclick = val;
7015
7074
  }
@@ -7057,8 +7116,26 @@ class RawTimerButton extends BaseClass$6 {
7057
7116
  }
7058
7117
  }
7059
7118
 
7060
- const { host: host$p } = {
7061
- host: { selector: () => ':host' }};
7119
+ const {
7120
+ host: host$p,
7121
+ nestedTimer,
7122
+ nestedButton,
7123
+ timerInsideNotReversed,
7124
+ timerInsideReversed,
7125
+ } = {
7126
+ host: { selector: () => ':host' },
7127
+ nestedTimer: { selector: () => ':host([timer-inside="true"]) .timer' },
7128
+ nestedButton: {
7129
+ selector: () => ':host([timer-inside="true"]) .button',
7130
+ },
7131
+ timerInsideNotReversed: {
7132
+ selector: () =>
7133
+ ':host([timer-inside="true"]:not([timer-position="end"])) .timer',
7134
+ },
7135
+ timerInsideReversed: {
7136
+ selector: () => ':host([timer-inside="true"][timer-position="end"]) .timer',
7137
+ },
7138
+ };
7062
7139
 
7063
7140
  const TimerButtonClass = compose(
7064
7141
  createStyleMixin$1({
@@ -7067,6 +7144,30 @@ const TimerButtonClass = compose(
7067
7144
  flexDirection: {},
7068
7145
  hostWidth: { ...host$p, property: 'width' },
7069
7146
  hostDirection: { ...host$p, property: 'direction' },
7147
+ timerTextColor: {
7148
+ ...nestedTimer,
7149
+ property: TimerClass.cssVarList.textColor,
7150
+ },
7151
+ timerIconColor: {
7152
+ ...nestedTimer,
7153
+ property: TimerClass.cssVarList.iconColor,
7154
+ },
7155
+ timerHostWidth: {
7156
+ ...nestedTimer,
7157
+ property: TimerClass.cssVarList.hostWidth,
7158
+ },
7159
+ buttonLabelSpacing: {
7160
+ ...nestedButton,
7161
+ property: ButtonClass.cssVarList.labelSpacing,
7162
+ },
7163
+ timerInsideGapEnd: {
7164
+ ...timerInsideNotReversed,
7165
+ property: 'margin-inline-end',
7166
+ },
7167
+ timerInsideGapStart: {
7168
+ ...timerInsideReversed,
7169
+ property: 'margin-inline-start',
7170
+ },
7070
7171
  },
7071
7172
  }),
7072
7173
  draggableMixin$1,
@@ -7082,11 +7183,35 @@ const timerButton = {
7082
7183
 
7083
7184
  _horizontal: {
7084
7185
  [vars$S.flexDirection]: 'row',
7186
+ timerPosition: {
7187
+ end: {
7188
+ [vars$S.flexDirection]: 'row-reverse',
7189
+ },
7190
+ },
7191
+ },
7192
+
7193
+ timerPosition: {
7194
+ end: {
7195
+ [vars$S.flexDirection]: 'column-reverse',
7196
+ },
7085
7197
  },
7086
7198
 
7087
7199
  _fullWidth: {
7088
7200
  [vars$S.hostWidth]: '100%',
7089
7201
  },
7202
+
7203
+ _timerInside: {
7204
+ [vars$S.timerTextColor]: 'currentColor',
7205
+ [vars$S.timerIconColor]: 'currentColor',
7206
+ [vars$S.timerHostWidth]: 'auto',
7207
+ [vars$S.buttonLabelSpacing]: '0',
7208
+ [vars$S.timerInsideGapEnd]: `var(${vars$S.gap})`,
7209
+ timerPosition: {
7210
+ end: {
7211
+ [vars$S.timerInsideGapStart]: `var(${vars$S.gap})`,
7212
+ },
7213
+ },
7214
+ },
7090
7215
  };
7091
7216
 
7092
7217
  var timerButton$1 = /*#__PURE__*/Object.freeze({