File tree Expand file tree Collapse file tree 3 files changed +18
-11
lines changed
apps/frontend/src/lib/components/blocks/forms
packages/table/src/modules/forms/form Expand file tree Collapse file tree 3 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 66 type MaybeConditionGroup ,
77 toMaybeConditionGroup ,
88 parseValidViewFilter ,
9- formOption ,
109 } from " @undb/table"
1110 import { Switch } from " $lib/components/ui/switch"
1211 import { Label } from " $lib/components/ui/label"
2221 import type { ZodUndefined } from " @undb/zod"
2322 import { writable } from " svelte/store"
2423 import { Button } from " $lib/components/ui/button"
24+ import { Checkbox } from " $lib/components/ui/checkbox"
2525
2626 const table = getTable ()
2727
5757 }
5858
5959 $ : previousFields = form .getPreviousFields (field .id .value ) ?? []
60+ $ : disabled = formField .getRequired (field ) && ! formField .defaultValue
6061 </script >
6162
6263<div
108109 <span >required</span >
109110 </Label >
110111
111- <label class ={cn (formField .required ? " cursor-not-allowed" : " cursor-pointer" )}>
112- <input
113- type =" checkbox"
112+ <Label class ={cn (disabled ? " cursor-not-allowed" : " cursor-pointer" )}>
113+ <Checkbox
114114 class =" hidden"
115115 bind:checked ={formField .hidden }
116- disabled ={formField .getRequired (field ) && ! formField .defaultValue }
117- on:click ={setForm }
116+ {disabled }
117+ onCheckedChange ={async () => {
118+ await tick ()
119+ setForm ()
120+ }}
118121 />
119122 {#if formField .hidden }
120123 <EyeClosed class =" h-4 w-4" />
121124 {:else }
122125 <EyeOpen class =" h-4 w-4" />
123126 {/if }
124- </label >
127+ </Label >
125128 </div >
126129 </div >
127130 <Collapsible .Content class =" mt-4" >
Original file line number Diff line number Diff line change 172172 class =" hidden"
173173 bind:checked ={formField .hidden }
174174 disabled ={hiddenDisabled }
175- on:change ={setForm }
175+ on:change ={async () => {
176+ if (hiddenDisabled ) {
177+ return
178+ }
179+
180+ await tick ()
181+ setForm ()
182+ }}
176183 />
177184 {#if formField .hidden }
178185 <EyeClosed class =" h-4 w-4" />
Original file line number Diff line number Diff line change @@ -26,9 +26,6 @@ export class FormFieldVO extends ValueObject<IFormField> {
2626 }
2727
2828 public get hidden ( ) {
29- if ( this . required ) {
30- return false
31- }
3229 return this . props . hidden ?? false
3330 }
3431
You can’t perform that action at this time.
0 commit comments