@stacksjs/components 0.2.988 → 0.2.991

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.
@@ -0,0 +1,20 @@
1
+ import type { DefineComponent } from '@stacksjs/stx';
2
+ declare const __dtsx_component__: __DtsxStxComponentType;
3
+ /*
4
+ * Platform-styled social authentication button (`apple` or `google`).
5
+ *
6
+ * Renders as a native Craft Pressable with SF Symbol / native styling when
7
+ * compiled with `$native`, and as an accessible anchor/button on the web.
8
+ */
9
+ export declare const provider: boolean;
10
+ export declare const label: unknown;
11
+ export declare const href: unknown;
12
+ export declare const disabled: ReturnType<typeof $bool>;
13
+ export declare const testID: unknown;
14
+ export declare const className: unknown;
15
+ export declare const isApple: boolean;
16
+ export declare const nativeClasses: unknown;
17
+ export declare const nativeTextClasses: unknown;
18
+ export declare const webClasses: unknown;
19
+ declare type __DtsxStxComponentType = DefineComponent<{ provider?: unknown, label?: unknown, href?: string, disabled?: unknown, testID?: string, className?: string }> & { readonly __stxEmits?: ["press"] }
20
+ export default __dtsx_component__;
@@ -37,5 +37,6 @@ export declare interface TwoFactorChallengeProps {
37
37
  export { default as BiometricSignIn } from './BiometricSignIn';
38
38
  export { default as Login } from './Login';
39
39
  export { default as Signup } from './Signup';
40
+ export { default as SocialSignInButton } from './SocialSignInButton';
40
41
  export { default as TwoFactorChallenge } from './TwoFactorChallenge';
41
42
  export * from './biometric';
@@ -18,6 +18,7 @@ export declare const description: unknown;
18
18
  * out of that decision.
19
19
  */
20
20
  export declare const icon: unknown;
21
+ export declare const symbol: unknown;
21
22
  export declare const as: unknown;
22
23
  /** `panel` draws the bordered card; `bare` is for something already in one. */
23
24
  export declare const variant: boolean;
@@ -30,5 +31,6 @@ export declare const titleClasses: 'text-base font-semibold text-fg';
30
31
  export declare const descriptionClasses: 'max-w-sm text-sm text-fg-muted';
31
32
  export declare const actionClasses: 'mt-2 flex flex-wrap items-center gap-2';
32
33
  export declare const hasIcon: boolean;
33
- declare type __DtsxStxComponentType = DefineComponent<{ title?: string, description?: string, icon?: string, as?: string, variant?: unknown, align?: unknown, className?: string, testID?: string }>;
34
+ export declare const hasSymbol: boolean;
35
+ declare type __DtsxStxComponentType = DefineComponent<{ title?: string, description?: string, icon?: string, symbol?: string, as?: string, variant?: unknown, align?: unknown, className?: string, testID?: string }>;
34
36
  export default __dtsx_component__;
@@ -22,6 +22,7 @@ export declare const title: unknown;
22
22
  export declare const subtitle: unknown;
23
23
  export declare const value: unknown;
24
24
  export declare const icon: unknown;
25
+ export declare const symbol: unknown;
25
26
  export declare const tint: unknown;
26
27
  export declare const chevron: ReturnType<typeof $bool>;
27
28
  export declare const pressable: unknown;
@@ -30,6 +31,7 @@ export declare const separator: ReturnType<typeof $bool>;
30
31
  export declare const testID: unknown;
31
32
  export declare const className: unknown;
32
33
  export declare const hasIcon: boolean;
34
+ export declare const hasSymbol: boolean;
33
35
  export declare const tag: unknown;
34
36
  export declare const tileClasses: string;
35
37
  /*
@@ -45,5 +47,5 @@ export declare const ruleClasses: unknown;
45
47
  export declare const titleClasses: unknown;
46
48
  export declare const subtitleClasses: string;
47
49
  export declare const valueClasses: string;
48
- declare type __DtsxStxComponentType = DefineComponent<{ title?: string, subtitle?: string, value?: string, icon?: string, tint?: unknown, chevron?: unknown, pressable?: unknown, destructive?: unknown, separator?: unknown, testID?: string, className?: string }> & { readonly __stxEmits?: ["select"] }
50
+ declare type __DtsxStxComponentType = DefineComponent<{ title?: string, subtitle?: string, value?: string, icon?: string, symbol?: string, tint?: unknown, chevron?: unknown, pressable?: unknown, destructive?: unknown, separator?: unknown, testID?: string, className?: string }> & { readonly __stxEmits?: ["select"] }
49
51
  export default __dtsx_component__;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/components",
3
3
  "type": "module",
4
- "version": "0.2.988",
4
+ "version": "0.2.991",
5
5
  "description": "A modern component library built with STX, featuring headwind utility classes and TypeScript syntax highlighting.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -144,8 +144,8 @@
144
144
  "dependencies": {
145
145
  "@iconify-json/f7": "^1.2.2",
146
146
  "@stacksjs/ts-css": "^0.3.11",
147
- "@stacksjs/stx": "0.2.988",
148
- "bun-plugin-stx": "0.2.988",
147
+ "@stacksjs/stx": "0.2.991",
148
+ "bun-plugin-stx": "0.2.991",
149
149
  "ts-syntax-highlighter": "^0.2.20",
150
150
  "ts-video-player": "^0.1.11"
151
151
  },
@@ -0,0 +1,74 @@
1
+ <script server>
2
+ /*
3
+ * Platform-styled social authentication button (`apple` or `google`).
4
+ *
5
+ * Renders as a native Craft Pressable with SF Symbol / native styling when
6
+ * compiled with `$native`, and as an accessible anchor/button on the web.
7
+ */
8
+ export const provider = $props.provider === 'apple' ? 'apple' : 'google'
9
+ export const label = $props.label || (provider === 'apple' ? 'Continue with Apple' : 'Continue with Google')
10
+ export const href = $props.href || ''
11
+ export const disabled = $bool($props.disabled)
12
+ export const testID = $props.testID || ''
13
+ export const className = $props.className || ''
14
+
15
+ export const isApple = provider === 'apple'
16
+ export const nativeClasses = isApple
17
+ ? `flex-row items-center justify-center gap-2.5 min-h-[50px] px-4 rounded-control bg-fg ${disabled ? 'opacity-50' : ''} ${className}`.replace(/\s+/g, ' ').trim()
18
+ : `flex-row items-center justify-center gap-2.5 min-h-[50px] px-4 rounded-control bg-panel border border-line ${disabled ? 'opacity-50' : ''} ${className}`.replace(/\s+/g, ' ').trim()
19
+ export const nativeTextClasses = isApple
20
+ ? 'text-[16px] font-semibold text-page'
21
+ : 'text-[16px] font-semibold text-fg'
22
+ export const webClasses = isApple
23
+ ? `inline-flex w-full min-h-[48px] items-center justify-center gap-2.5 rounded-xl px-4 py-2.5 text-[15px] font-semibold bg-fg text-page transition-opacity hover:opacity-90 active:scale-[0.99] ${disabled ? 'opacity-50 pointer-events-none' : ''} ${className}`.replace(/\s+/g, ' ').trim()
24
+ : `inline-flex w-full min-h-[48px] items-center justify-center gap-2.5 rounded-xl px-4 py-2.5 text-[15px] font-semibold bg-panel text-fg border border-line transition-colors hover:bg-surface-hover active:scale-[0.99] ${disabled ? 'opacity-50 pointer-events-none' : ''} ${className}`.replace(/\s+/g, ' ').trim()
25
+ </script>
26
+
27
+ <script client>
28
+ const emit = defineEmits(['press'])
29
+ const buttonLabel = useReactiveProp('label', {{ label }})
30
+ const isDisabled = useReactiveProp('disabled', {{ disabled }})
31
+
32
+ function press() {
33
+ if (isDisabled()) return
34
+ if (typeof craft !== 'undefined' && craft && craft.haptics && craft.haptics.selection)
35
+ void craft.haptics.selection()
36
+ emit('press')
37
+ }
38
+ </script>
39
+
40
+ @if($native)
41
+ <button
42
+ type="button"
43
+ data-native="Pressable"
44
+ :disabled="isDisabled()"
45
+ class="{{ nativeClasses }}"
46
+ @if(testID)testID="{{ testID }}"@endif
47
+ @click="press()"
48
+ data-stx-social-sign-in="{{ provider }}"
49
+ >
50
+ @if(isApple)
51
+ <span data-native="Icon" symbol="apple.logo" class="h-[18px] w-[18px] text-page"></span>
52
+ @else
53
+ <span data-native="Icon" symbol="globe" class="h-[18px] w-[18px] text-fg"></span>
54
+ @endif
55
+ <span :text="buttonLabel()" class="{{ nativeTextClasses }}">{{ label }}</span>
56
+ </button>
57
+ @elseif(href && !disabled)
58
+ <a href="{{ href }}" class="{{ webClasses }}" @if(testID)data-testid="{{ testID }}"@endif data-stx-social-sign-in="{{ provider }}">
59
+ <i class="{{ isApple ? 'i-hugeicons-apple' : 'i-hugeicons-google' }} h-5 w-5" aria-hidden="true"></i>
60
+ <span :text="buttonLabel()">{{ label }}</span>
61
+ </a>
62
+ @else
63
+ <button
64
+ type="button"
65
+ :disabled="isDisabled()"
66
+ class="{{ webClasses }}"
67
+ @if(testID)data-testid="{{ testID }}"@endif
68
+ @click="press()"
69
+ data-stx-social-sign-in="{{ provider }}"
70
+ >
71
+ <i class="{{ isApple ? 'i-hugeicons-apple' : 'i-hugeicons-google' }} h-5 w-5" aria-hidden="true"></i>
72
+ <span :text="buttonLabel()">{{ label }}</span>
73
+ </button>
74
+ @endif
@@ -1,6 +1,7 @@
1
1
  export { default as BiometricSignIn } from './BiometricSignIn.stx'
2
2
  export { default as Login } from './Login.stx'
3
3
  export { default as Signup } from './Signup.stx'
4
+ export { default as SocialSignInButton } from './SocialSignInButton.stx'
4
5
  export { default as TwoFactorChallenge } from './TwoFactorChallenge.stx'
5
6
 
6
7
  export * from './biometric'
@@ -38,10 +38,16 @@ function normalise(choice) {
38
38
  if (choice !== null && typeof choice === 'object') {
39
39
  const value = choice.value == null ? '' : String(choice.value)
40
40
  const count = Number(choice.count)
41
- return { value, label: choice.label == null ? value : String(choice.label), count: Number.isFinite(count) && count > 0 ? count : 0, disabled: choice.disabled === true }
41
+ return {
42
+ value,
43
+ label: choice.label == null ? value : String(choice.label),
44
+ symbol: choice.symbol == null ? '' : String(choice.symbol),
45
+ count: Number.isFinite(count) && count > 0 ? count : 0,
46
+ disabled: choice.disabled === true,
47
+ }
42
48
  }
43
49
  const value = choice == null ? '' : String(choice)
44
- return { value, label: value, count: 0, disabled: false }
50
+ return { value, label: value, symbol: '', count: 0, disabled: false }
45
51
  }
46
52
 
47
53
  function chips() {
@@ -55,6 +61,8 @@ function isOn(chip) {
55
61
 
56
62
  function choose(chip) {
57
63
  if (chip.disabled || isOn(chip)) return
64
+ if (typeof craft !== 'undefined' && craft && craft.haptics && craft.haptics.selection)
65
+ void craft.haptics.selection()
58
66
  selected.set(chip.value)
59
67
  emit('change', chip.value)
60
68
  }
@@ -196,8 +196,8 @@ defineExpose({
196
196
  bottom edge whichever edge it is given, under a title bar with the close
197
197
  button where iOS puts it. --}}
198
198
  <div x-ref="rootRef" data-native="Modal" animationType="slide" presentationStyle="pageSheet" :sheetDetents="{{ JSON.stringify(nativeDetents) }}" @if(nativeSelectedDetent)selectedDetent="{{ nativeSelectedDetent }}"@endif data-stx-drawer="{{ drawerInstanceId }}" :show="isOpen()">
199
- <div class="absolute inset-0 bg-[#000000]/40" aria-hidden="true" @click="onBackdropClick()"></div>
200
- <div class="absolute inset-0 justify-end pt-12">
199
+ <div :show="!systemSheet" class="absolute inset-0 bg-[#000000]/40" aria-hidden="true" @click="onBackdropClick()"></div>
200
+ <div :class="systemSheet ? 'w-full' : 'absolute inset-0 justify-end pt-12'">
201
201
  <div
202
202
  class="w-full max-h-full rounded-t-[10px] bg-[#f2f2f7] dark:bg-[#1c1c1e] {{ className }}"
203
203
  data-stx-drawer-panel="{{ drawerInstanceId }}"
@@ -17,6 +17,7 @@ export const description = $props.description || ''
17
17
  * out of that decision.
18
18
  */
19
19
  export const icon = $props.icon || ''
20
+ export const symbol = $props.symbol || ''
20
21
  export const as = $props.as || 'div'
21
22
  /** `panel` draws the bordered card; `bare` is for something already in one. */
22
23
  export const variant = $props.variant === 'bare' ? 'bare' : 'panel'
@@ -32,6 +33,7 @@ export const titleClasses = 'text-base font-semibold text-fg'
32
33
  export const descriptionClasses = 'max-w-sm text-sm text-fg-muted'
33
34
  export const actionClasses = 'mt-2 flex flex-wrap items-center gap-2'
34
35
  export const hasIcon = icon !== ''
36
+ export const hasSymbol = symbol !== ''
35
37
  </script>
36
38
 
37
39
  <script client>
@@ -51,7 +53,9 @@ const explanation = useReactiveProp('description', {{ description }})
51
53
  cannot tell an empty slot from an absent one at render time, so the
52
54
  circle would render either way - the prop is the honest shape, and a
53
55
  caller wanting a whole <Icon /> composes it with variant="bare". --}}
54
- @if(hasIcon)
56
+ @if(hasSymbol && $native)
57
+ <div class="{{ iconWrapClasses }}"><span data-native="Icon" symbol="{{ symbol }}" class="h-6 w-6 text-fg-soft"></span></div>
58
+ @elseif(hasIcon)
55
59
  <div class="{{ iconWrapClasses }}">{!! icon !!}</div>
56
60
  @endif
57
61
 
@@ -21,6 +21,7 @@ export const title = $props.title || ''
21
21
  export const subtitle = $props.subtitle || ''
22
22
  export const value = $props.value || ''
23
23
  export const icon = $props.icon || ''
24
+ export const symbol = $props.symbol || ''
24
25
  export const tint = ['accent', 'success', 'danger', 'warning', 'info', 'secondary'].includes($props.tint) ? $props.tint : 'accent'
25
26
  export const chevron = $bool($props.chevron)
26
27
  export const pressable = $bool($props.pressable) || chevron
@@ -47,7 +48,8 @@ const tintFills = $native
47
48
  info: 'bg-info-solid',
48
49
  secondary: 'bg-secondary-solid',
49
50
  }
50
- export const hasIcon = icon !== ''
51
+ export const hasIcon = icon !== '' || symbol !== ''
52
+ export const hasSymbol = symbol !== ''
51
53
  export const tag = pressable ? 'button' : 'div'
52
54
  export const tileClasses = `flex shrink-0 items-center justify-center h-[29px] w-[29px] rounded-[7px] text-white ${tintFills[tint]}`
53
55
  /*
@@ -87,7 +89,9 @@ function select() {
87
89
  <div class="flex flex-col" data-stx-grouped-list-row>
88
90
  <div :show="ruled()" class="{{ ruleClasses }}" aria-hidden="true"></div>
89
91
  <{{ tag }} @if(pressable)type="button" @click="select()"@endif @if(pressable && $native)data-native="TouchableHighlight" underlayColor="#7676803d"@endif class="{{ rowClasses }}" @if(testID)testID="{{ testID }}"@endif>
90
- @if(hasIcon)
92
+ @if(hasSymbol && $native)
93
+ <span class="{{ tileClasses }}" aria-hidden="true"><span data-native="Icon" symbol="{{ symbol }}" class="h-[17px] w-[17px] text-white"></span></span>
94
+ @elseif(hasIcon)
91
95
  <span class="{{ tileClasses }}" aria-hidden="true">{!! icon !!}</span>
92
96
  @endif
93
97
  <span class="flex flex-1 min-w-0 flex-col">
@@ -76,7 +76,7 @@ onMount(() => {
76
76
  return () => { stop(); changes.disconnect(); observer.disconnect() }
77
77
  })
78
78
  </script>
79
- <div data-native="FlatList" ref="listRef" role="list" class="{{ viewportClasses }} {{ className }}" :horizontal="horizontal()" :contentContainerStyle="contentStyle()" :style="nativeHost ? {} : webPadding()" :data-stx-list-direction="horizontal ? 'horizontal' : 'vertical'" data-stx-list data-stx-layout-root @end-reached="reachedEnd()" @refresh="emit('refresh')">
79
+ <div data-native="FlatList" ref="listRef" role="list" class="{{ viewportClasses }} {{ className }}" :horizontal="horizontal()" :contentContainerStyle="contentStyle()" :style="nativeHost ? {} : webPadding()" :data-stx-list-direction="horizontal() ? 'horizontal' : 'vertical'" data-stx-list data-stx-layout-root @end-reached="reachedEnd()" @refresh="emit('refresh')">
80
80
  <slot />
81
81
  @if(!nativeHost)
82
82
  <div ref="endRef" aria-hidden="true" style="height:1px;width:1px;flex-shrink:0"></div>
@@ -38,7 +38,7 @@ const positions = {
38
38
  }
39
39
 
40
40
  const baseClasses = 'fixed z-50 m-4 max-w-md w-full pointer-events-auto rounded-panel p-4 shadow-lg ring-1 ring-line transition-all'
41
- const extraClassName = {{ JSON.stringify(className) }}
41
+ const extraClassName = {{ className }}
42
42
 
43
43
  const notificationClasses = derived(() => {
44
44
  const color = typeColors[type()] || typeColors.info
@@ -83,6 +83,10 @@ onMount(() => {
83
83
  if (isVisible()) scheduleAutoHide()
84
84
  })
85
85
 
86
+ onDestroy(() => {
87
+ clearAutoHide()
88
+ })
89
+
86
90
  defineExpose({
87
91
  open,
88
92
  close,
@@ -19,7 +19,7 @@ const variantClasses = {
19
19
  }
20
20
 
21
21
  // Animation classes
22
- const animationClasses = animate ? 'motion-safe:animate-pulse' : ''
22
+ const animationClasses = !$native && animate ? 'motion-safe:animate-pulse' : ''
23
23
 
24
24
  // Build base classes
25
25
  const baseClasses = circle ? 'rounded-full' : variantClasses[variant] || variantClasses.text
@@ -37,7 +37,17 @@ export const skeletonClasses = `bg-surface-sunken ${baseClasses} ${animationClas
37
37
  export const containerClasses = count > 1 ? 'space-y-3' : ''
38
38
  </script>
39
39
 
40
- @if(count > 1)
40
+ @if($native)
41
+ @if(count > 1)
42
+ <div data-native="View" class="gap-3">
43
+ @for(i = 0; i < count; i++)
44
+ <div data-native="View" @if(animate)pulse="true"@endif class="{{ skeletonClasses }}" aria-hidden="true"></div>
45
+ @endfor
46
+ </div>
47
+ @else
48
+ <div data-native="View" @if(animate)pulse="true"@endif class="{{ skeletonClasses }}" aria-hidden="true"></div>
49
+ @endif
50
+ @elseif(count > 1)
41
51
  <div class="{{ containerClasses }}">
42
52
  @for(i = 0; i < count; i++)
43
53
  <div class="{{ skeletonClasses }}" style="{{ styleString }}" aria-busy="true" aria-live="polite"></div>