-
Notifications
You must be signed in to change notification settings - Fork 452
Support "control after generate" in vue #6985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
23fdbe4
f853cb9
57025df
cfaeed1
04bd165
6acc7b0
29af785
c18df9c
abe600b
fcf9a32
895a458
613fe12
94ade0a
0fb7466
95b95ed
69715b2
7dd2f52
307771b
bbcb3b4
ec07416
b5419f7
6d2f976
9348995
9723e2b
bb5c884
ff08660
52daf4e
ad70768
4b4b90d
a84fd7a
0b5ded8
a2391e6
5b6d835
939090f
26e6aec
1fa618c
1ddf364
cfb579b
d25cd39
679a1da
70f6d5b
ed25f72
488922a
9553233
437880c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,6 @@ | ||||||||||
| import { computed, onMounted, onUnmounted, ref } from 'vue' | ||||||||||
| import type { Ref } from 'vue' | ||||||||||
|
|
||||||||||
| import { useGlobalSeedStore } from '@/stores/globalSeedStore' | ||||||||||
| import type { ControlOptions } from '@/types/simplifiedWidget' | ||||||||||
|
|
||||||||||
| import { numberControlRegistry } from '../services/NumberControlRegistry' | ||||||||||
|
|
@@ -60,12 +59,11 @@ export function useStepperControl( | |||||||||
| ) { | ||||||||||
| const controlMode = ref<NumberControlMode>(convertToEnum(defaultValue)) | ||||||||||
| const controlId = Symbol('numberControl') | ||||||||||
| const globalSeedStore = useGlobalSeedStore() | ||||||||||
|
|
||||||||||
| const applyControl = () => { | ||||||||||
| const { min = 0, max = 1000000, step2, step = 1, onChange } = options | ||||||||||
| const safeMax = Math.min(1125899906842624, max) | ||||||||||
| const safeMin = Math.max(-1125899906842624, min) | ||||||||||
| const safeMax = Math.min(2 ** 50, max) | ||||||||||
| const safeMin = Math.max(-(2 ** 50), min) | ||||||||||
|
Comment on lines
+65
to
+66
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider using Number.MAX_SAFE_INTEGER for clarity. The safe bounds use Apply this diff: - const safeMax = Math.min(2 ** 50, max)
- const safeMin = Math.max(-(2 ** 50), min)
+ const safeMax = Math.min(Number.MAX_SAFE_INTEGER, max)
+ const safeMin = Math.max(-Number.MAX_SAFE_INTEGER, min)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| // Use step2 if available (widget context), otherwise use step as-is (direct API usage) | ||||||||||
| const actualStep = step2 !== undefined ? step2 : step | ||||||||||
|
|
||||||||||
|
|
@@ -83,10 +81,6 @@ export function useStepperControl( | |||||||||
| case NumberControlMode.RANDOMIZE: | ||||||||||
| newValue = Math.floor(Math.random() * (safeMax - safeMin + 1)) + safeMin | ||||||||||
| break | ||||||||||
| case NumberControlMode.LINK_TO_GLOBAL: | ||||||||||
| // Use global seed value, constrained by min/max | ||||||||||
| newValue = Math.max(min, Math.min(safeMax, globalSeedStore.globalSeed)) | ||||||||||
| break | ||||||||||
| default: | ||||||||||
| return | ||||||||||
| } | ||||||||||
|
|
||||||||||
AustinMroz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be a utility function instead of a composable for now.