@descope/flow-components 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.
@@ -5,7 +5,7 @@
5
5
  "name": "flowComponents",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "3.4.0",
8
+ "buildVersion": "3.5.0",
9
9
  "buildName": "@descope/flow-components"
10
10
  },
11
11
  "remoteEntry": {
@@ -5,7 +5,7 @@
5
5
  "name": "flowComponents",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "3.4.0",
8
+ "buildVersion": "3.5.0",
9
9
  "buildName": "@descope/flow-components"
10
10
  },
11
11
  "remoteEntry": {
package/dist/index.cjs.js CHANGED
@@ -86565,26 +86565,85 @@ function requireIndex_cjs () {
86565
86565
  .wrapper {
86566
86566
  display: flex;
86567
86567
  flex-direction: column;
86568
- gap: 0.5em;
86569
86568
  align-items: center;
86570
86569
  width: 100%;
86571
86570
  }
86572
- .timer {
86571
+ /* allow timer to grow along the main axis in the wrapper flex container */
86572
+ :host(:not([timer-inside="true"])) .timer {
86573
86573
  flex: 1;
86574
86574
  }
86575
+ :host([timer-inside="true"]) .timer {
86576
+ flex: 0 0 auto;
86577
+ }
86575
86578
  `,
86576
86579
  this,
86577
86580
  );
86578
86581
 
86582
+ this.wrapper = this.shadowRoot.querySelector('.wrapper');
86579
86583
  this.timer = this.shadowRoot.querySelector('.timer');
86580
86584
  this.button = this.shadowRoot.querySelector('.button');
86585
+ this.forwardingSlot = this.shadowRoot.querySelector('.button slot');
86581
86586
 
86582
86587
  this.timer.addEventListener('timer-started', () => this.onTimerStarted());
86583
86588
  this.timer.addEventListener('timer-ended', () => this.onTimerEnded());
86584
86589
 
86590
+ this.syncTimerPlacement();
86591
+
86585
86592
  this.button.addEventListener('click', this.onClick.bind(this));
86586
86593
  }
86587
86594
 
86595
+ static get observedAttributes() {
86596
+ return [
86597
+ ...(super.observedAttributes || []),
86598
+ 'timer-inside',
86599
+ 'timer-position',
86600
+ ];
86601
+ }
86602
+
86603
+ attributeChangedCallback(name, oldValue, newValue) {
86604
+ super.attributeChangedCallback?.(name, oldValue, newValue);
86605
+ if (name === 'timer-inside' || name === 'timer-position') {
86606
+ this.syncTimerPlacement();
86607
+ }
86608
+ }
86609
+
86610
+ get #isTimerInside() {
86611
+ return this.getAttribute('timer-inside') === 'true';
86612
+ }
86613
+
86614
+ get #isReversed() {
86615
+ return this.getAttribute('timer-position') === 'end';
86616
+ }
86617
+
86618
+ syncTimerPlacement() {
86619
+ if (this.#isTimerInside) {
86620
+ this.#placeTimerInsideButton(this.#isReversed);
86621
+ } else {
86622
+ this.#placeTimerOutsideButton();
86623
+ }
86624
+ }
86625
+
86626
+ #placeTimerInsideButton(reversed) {
86627
+ if (reversed) {
86628
+ // timer after label text (right)
86629
+ if (this.timer.previousSibling !== this.forwardingSlot) {
86630
+ this.button.appendChild(this.timer);
86631
+ }
86632
+ } else {
86633
+ // timer before label text (left) — matches default outside position (above/before button)
86634
+ if (this.timer.nextSibling !== this.forwardingSlot) {
86635
+ this.button.insertBefore(this.timer, this.forwardingSlot);
86636
+ }
86637
+ }
86638
+ }
86639
+
86640
+ #placeTimerOutsideButton() {
86641
+ // move timer back as a wrapper sibling, before the button so flex-column puts it above
86642
+ if (this.timer.parentElement !== this.wrapper) {
86643
+ this.wrapper.insertBefore(this.timer, this.button);
86644
+ }
86645
+ }
86646
+
86588
86647
  set onclick(val) {
86589
86648
  this.button.onclick = val;
86590
86649
  }
@@ -86632,8 +86691,26 @@ function requireIndex_cjs () {
86632
86691
  }
86633
86692
  }
86634
86693
 
86635
- const { host: host$p } = {
86636
- host: { selector: () => ':host' }};
86694
+ const {
86695
+ host: host$p,
86696
+ nestedTimer,
86697
+ nestedButton,
86698
+ timerInsideNotReversed,
86699
+ timerInsideReversed,
86700
+ } = {
86701
+ host: { selector: () => ':host' },
86702
+ nestedTimer: { selector: () => ':host([timer-inside="true"]) .timer' },
86703
+ nestedButton: {
86704
+ selector: () => ':host([timer-inside="true"]) .button',
86705
+ },
86706
+ timerInsideNotReversed: {
86707
+ selector: () =>
86708
+ ':host([timer-inside="true"]:not([timer-position="end"])) .timer',
86709
+ },
86710
+ timerInsideReversed: {
86711
+ selector: () => ':host([timer-inside="true"][timer-position="end"]) .timer',
86712
+ },
86713
+ };
86637
86714
 
86638
86715
  const TimerButtonClass = compose(
86639
86716
  createStyleMixin$1({
@@ -86642,6 +86719,30 @@ function requireIndex_cjs () {
86642
86719
  flexDirection: {},
86643
86720
  hostWidth: { ...host$p, property: 'width' },
86644
86721
  hostDirection: { ...host$p, property: 'direction' },
86722
+ timerTextColor: {
86723
+ ...nestedTimer,
86724
+ property: TimerClass.cssVarList.textColor,
86725
+ },
86726
+ timerIconColor: {
86727
+ ...nestedTimer,
86728
+ property: TimerClass.cssVarList.iconColor,
86729
+ },
86730
+ timerHostWidth: {
86731
+ ...nestedTimer,
86732
+ property: TimerClass.cssVarList.hostWidth,
86733
+ },
86734
+ buttonLabelSpacing: {
86735
+ ...nestedButton,
86736
+ property: ButtonClass.cssVarList.labelSpacing,
86737
+ },
86738
+ timerInsideGapEnd: {
86739
+ ...timerInsideNotReversed,
86740
+ property: 'margin-inline-end',
86741
+ },
86742
+ timerInsideGapStart: {
86743
+ ...timerInsideReversed,
86744
+ property: 'margin-inline-start',
86745
+ },
86645
86746
  },
86646
86747
  }),
86647
86748
  draggableMixin$1,
@@ -86657,11 +86758,35 @@ function requireIndex_cjs () {
86657
86758
 
86658
86759
  _horizontal: {
86659
86760
  [vars$S.flexDirection]: 'row',
86761
+ timerPosition: {
86762
+ end: {
86763
+ [vars$S.flexDirection]: 'row-reverse',
86764
+ },
86765
+ },
86766
+ },
86767
+
86768
+ timerPosition: {
86769
+ end: {
86770
+ [vars$S.flexDirection]: 'column-reverse',
86771
+ },
86660
86772
  },
86661
86773
 
86662
86774
  _fullWidth: {
86663
86775
  [vars$S.hostWidth]: '100%',
86664
86776
  },
86777
+
86778
+ _timerInside: {
86779
+ [vars$S.timerTextColor]: 'currentColor',
86780
+ [vars$S.timerIconColor]: 'currentColor',
86781
+ [vars$S.timerHostWidth]: 'auto',
86782
+ [vars$S.buttonLabelSpacing]: '0',
86783
+ [vars$S.timerInsideGapEnd]: `var(${vars$S.gap})`,
86784
+ timerPosition: {
86785
+ end: {
86786
+ [vars$S.timerInsideGapStart]: `var(${vars$S.gap})`,
86787
+ },
86788
+ },
86789
+ },
86665
86790
  };
86666
86791
 
86667
86792
  var timerButton$1 = /*#__PURE__*/Object.freeze({
@@ -106121,7 +106246,7 @@ const AddressField = React__default.default.forwardRef(({ size = 'md', ...props
106121
106246
 
106122
106247
  const CountrySubdivisionCityField = React__default.default.forwardRef(({ size = 'md', ...props }, ref) => (React__default.default.createElement("descope-country-subdivision-city-field", { size: size, ...props, ref: ref })));
106123
106248
 
106124
- const TimerButton = React__default.default.forwardRef(({ children, color = 'primary', size = 'md', variant = 'contained', horizontal = false, 'text-align': textAlign = 'center', 'timer-seconds': timerSeconds = 0, 'timer-hide-icon': timerHideIcon = false, 'timer-paused': timerPause = false, ...props }, ref) => (React__default.default.createElement("descope-timer-button", { ...props, size: size, "text-align": textAlign, horizontal: horizontal, "button-variant": variant, "button-mode": color, "timer-hide-icon": timerHideIcon, "timer-seconds": timerSeconds, "timer-paused": timerPause, ref: ref }, children)));
106249
+ const TimerButton = React__default.default.forwardRef(({ children, color = 'primary', size = 'md', variant = 'contained', horizontal = false, 'text-align': textAlign = 'center', 'timer-seconds': timerSeconds = 0, 'timer-hide-icon': timerHideIcon = false, 'timer-paused': timerPause = false, 'timer-position': timerPosition = 'start', 'timer-inside': timerInside = false, ...props }, ref) => (React__default.default.createElement("descope-timer-button", { ...props, size: size, "text-align": textAlign, horizontal: horizontal, "button-variant": variant, "button-mode": color, "timer-hide-icon": timerHideIcon, "timer-seconds": timerSeconds, "timer-paused": timerPause, "timer-position": timerPosition, "timer-inside": timerInside, ref: ref }, children)));
106125
106250
 
106126
106251
  const applyDefaults = ({ paddingX, paddingY, background, spaceBetween }) => ({
106127
106252
  'st-horizontal-padding': !paddingX || isNumeric(paddingX)
package/dist/index.d.ts CHANGED
@@ -1116,6 +1116,8 @@ type Props$7 = React.JSX.IntrinsicElements['button'] & {
1116
1116
  'timer-seconds'?: number;
1117
1117
  'timer-hide-icon'?: boolean;
1118
1118
  'timer-paused'?: boolean;
1119
+ 'timer-position'?: 'start' | 'end';
1120
+ 'timer-inside'?: boolean;
1119
1121
  };
1120
1122
  declare global {
1121
1123
  namespace React.JSX {
@@ -1134,6 +1136,8 @@ declare const TimerButton: React.ForwardRefExoticComponent<Omit<React.ClassAttri
1134
1136
  'timer-seconds'?: number;
1135
1137
  'timer-hide-icon'?: boolean;
1136
1138
  'timer-paused'?: boolean;
1139
+ 'timer-position'?: "start" | "end";
1140
+ 'timer-inside'?: boolean;
1137
1141
  }, "ref"> & React.RefAttributes<HTMLButtonElement>>;
1138
1142
 
1139
1143
  type Never<T extends Record<string, any>> = {
package/dist/index.esm.js CHANGED
@@ -560,7 +560,7 @@ const AddressField = React.forwardRef(({ size = 'md', ...props }, ref) => (React
560
560
 
561
561
  const CountrySubdivisionCityField = React.forwardRef(({ size = 'md', ...props }, ref) => (React.createElement("descope-country-subdivision-city-field", { size: size, ...props, ref: ref })));
562
562
 
563
- const TimerButton = React.forwardRef(({ children, color = 'primary', size = 'md', variant = 'contained', horizontal = false, 'text-align': textAlign = 'center', 'timer-seconds': timerSeconds = 0, 'timer-hide-icon': timerHideIcon = false, 'timer-paused': timerPause = false, ...props }, ref) => (React.createElement("descope-timer-button", { ...props, size: size, "text-align": textAlign, horizontal: horizontal, "button-variant": variant, "button-mode": color, "timer-hide-icon": timerHideIcon, "timer-seconds": timerSeconds, "timer-paused": timerPause, ref: ref }, children)));
563
+ const TimerButton = React.forwardRef(({ children, color = 'primary', size = 'md', variant = 'contained', horizontal = false, 'text-align': textAlign = 'center', 'timer-seconds': timerSeconds = 0, 'timer-hide-icon': timerHideIcon = false, 'timer-paused': timerPause = false, 'timer-position': timerPosition = 'start', 'timer-inside': timerInside = false, ...props }, ref) => (React.createElement("descope-timer-button", { ...props, size: size, "text-align": textAlign, horizontal: horizontal, "button-variant": variant, "button-mode": color, "timer-hide-icon": timerHideIcon, "timer-seconds": timerSeconds, "timer-paused": timerPause, "timer-position": timerPosition, "timer-inside": timerInside, ref: ref }, children)));
564
564
 
565
565
  const applyDefaults = ({ paddingX, paddingY, background, spaceBetween }) => ({
566
566
  'st-horizontal-padding': !paddingX || isNumeric(paddingX)
@@ -10,6 +10,8 @@ type Props = React.JSX.IntrinsicElements['button'] & {
10
10
  'timer-seconds'?: number;
11
11
  'timer-hide-icon'?: boolean;
12
12
  'timer-paused'?: boolean;
13
+ 'timer-position'?: 'start' | 'end';
14
+ 'timer-inside'?: boolean;
13
15
  };
14
16
  declare global {
15
17
  namespace React.JSX {
@@ -28,5 +30,7 @@ declare const TimerButton: React.ForwardRefExoticComponent<Omit<React.ClassAttri
28
30
  'timer-seconds'?: number;
29
31
  'timer-hide-icon'?: boolean;
30
32
  'timer-paused'?: boolean;
33
+ 'timer-position'?: "start" | "end";
34
+ 'timer-inside'?: boolean;
31
35
  }, "ref"> & React.RefAttributes<HTMLButtonElement>>;
32
36
  export default TimerButton;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/flow-components",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -97,7 +97,7 @@
97
97
  "webpack-subresource-integrity": "5.2.0-rc.1"
98
98
  },
99
99
  "dependencies": {
100
- "@descope/web-components-ui": "3.4.0"
100
+ "@descope/web-components-ui": "3.5.0"
101
101
  },
102
102
  "peerDependencies": {
103
103
  "react": ">= 18"