Skip to content
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

Release version v1.0.0-125 #2156

Merged
merged 5 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## v1.0.0-125


### 🩹 Fixes

- Fix date control ([f0eed23](https://github.com/undb-io/undb/commit/f0eed23))

### ❤️ Contributors

- Nichenqin ([@nichenqin](http://github.com/nichenqin))

## v1.0.0-124

## v1.0.0-123
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

let open = false

function onChange() {
function onChange(value: string | Date | undefined | null) {
if (!includeTime) {
open = false
}
Expand Down Expand Up @@ -63,21 +63,23 @@
<Popover.Content class="p-0" side="bottom" align="start">
<div class="p-1">
<DateMacroPicker
onValueChange={() => {
onChange()
onValueChange={(v) => {
onChange(v)
}}
bind:value
/>
</div>
<Calendar
value={isString(internalDate) && isDateFieldMacro(internalDate) ? undefined : internalDate}
onValueChange={(v) => {
let vv
if (v) {
value = v.toString()
vv = v.toString()
} else {
value = undefined
vv = undefined
}
onChange()
value = vv
onChange(vv)
}}
initialFocus
/>
Expand All @@ -90,8 +92,9 @@
}}
onValueChange={(v) => {
if (!value) return
value = new Date(new Date(value).setHours(v.hour, v.minute, 0, 0)).toISOString()
onValueChange?.(value)
const vv = new Date(new Date(value).setHours(v.hour, v.minute, 0, 0)).toISOString()
value = vv
onValueChange?.(vv)
}}
/>
</div>
Expand All @@ -101,8 +104,9 @@
class="flex-1"
variant="outline"
on:click={() => {
value = today(getLocalTimeZone()).toString()
onChange()
const v = today(getLocalTimeZone()).toString()
value = v
onChange(v)
}}>Today</Button
>
<Button
Expand All @@ -111,7 +115,7 @@
on:click={() => {
if (value) {
value = null
onValueChange?.(value)
onValueChange?.(null)
}
open = false
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
export let value: number
export let onValueChange: (value: number) => void
const onInput = (event: Event) => {
value = +(event.target as HTMLInputElement).value
onValueChange?.(value)
const v = Number((event.target as HTMLInputElement).value)
value = v
onValueChange?.(v)
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
<div class="col-span-9 grid grid-cols-12 items-center">
<FilterField
disabled
value={child.field}
bind:value={child.field}
class={cn(!!child.field && "col-span-4 rounded-r-none border-r-0")}
/>
<OpPicker
disabled
{field}
value={child.op}
bind:value={child.op}
class={cn("col-span-3 rounded-l-none", !!child.value && "rounded-r-none")}
/>
<FilterInput
disabled
{field}
value={child.value}
bind:value={child.value}
op={child.op}
class="col-span-5 bg-white text-xs font-medium"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
export let value: any | undefined = undefined
export let disabled = false

export let onOptionChange: ((option: any) => void) | undefined = undefined
export let onValueChange: ((value: any) => void) | undefined = undefined
export let onOpChange: ((op: IOpType) => void) | undefined = undefined

$: conditionOps = field?.conditionOps ?? []
$: ops = conditionOps.map((op) => ({ value: op, label: $LL.table.ops[op]() })) ?? []

Expand All @@ -24,8 +28,14 @@

<div class={cn("col-span-8 flex flex-1 items-center gap-0", $$restProps.class)}>
<FieldFilterOption {field} bind:option class="h-8 w-20 font-semibold" />
<OpPicker {disabled} {field} bind:value={op} class={cn("rounded-l-none", hasValue && "rounded-r-none")} />
<OpPicker
{disabled}
{field}
bind:value={op}
class={cn("rounded-l-none", hasValue && "rounded-r-none")}
onValueChange={onOpChange}
/>
{#if hasValue}
<FilterInput {disabled} class="flex-1" {field} bind:value {op} />
<FilterInput {disabled} class="flex-1" {field} bind:value {op} {onValueChange} />
{/if}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

export let value: string | undefined
export let filter: ((field: any) => boolean) | undefined = undefined
export let onValueChange: ((value: FieldType | undefined, prev: FieldType) => void) | undefined = undefined
export let onValueChange: ((value: string | undefined, prev: string) => void) | undefined = undefined
export let sameWidth = true
export let table: Writable<TableDo> | undefined = undefined
export let disabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import OptionFilterInput from "./variants/option-filter-input.svelte"
import OptionsFilterInput from "./variants/options-filter-input.svelte"
import DurationInput from "$lib/components/blocks/duration/duration-input.svelte"
import StringControl from "$lib/components/blocks/field-control/string-control.svelte"

export let field: Field | undefined
export let recordId: string | undefined = undefined
Expand All @@ -43,15 +44,17 @@
export let op: IOpType | undefined = undefined
export let disabled = false

export let onValueChange: ((value: any) => void) | undefined = undefined

const className = cn("h-8 rounded-l-none border-l-0 py-0 text-xs bg-background", $$restProps.class)

const string: Record<IStringFieldConditionOp, ComponentType | null> = {
eq: Input,
neq: Input,
contains: Input,
does_not_contain: Input,
starts_with: Input,
ends_with: Input,
eq: StringControl,
neq: StringControl,
contains: StringControl,
does_not_contain: StringControl,
starts_with: StringControl,
ends_with: StringControl,
is_empty: null,
is_not_empty: null,
min: NumberInput,
Expand Down Expand Up @@ -334,6 +337,6 @@

{#if field && op}
{#if component}
<svelte:component this={component} {disabled} bind:value class={className} {field} />
<svelte:component this={component} {disabled} bind:value class={className} {field} {onValueChange} />
{/if}
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
export let disabled = false
export let readonly = false

export let onValueChange: ((value: MaybeConditionGroup<any> | undefined) => void) | undefined = undefined

$: filteredFields = table?.getOrderedVisibleFields().filter((f) => filter({ id: f.id.value, type: f.type })) ?? []
export let disableGroup = false

Expand Down Expand Up @@ -126,11 +128,16 @@
{readonly}
table={table ? writable(table) : undefined}
{sameWidth}
onValueChange={(type, prev) => {
if (type !== prev) {
if (isMaybeFieldCondition(child)) {
onValueChange={async (field, prev) => {
if (isMaybeFieldCondition(child)) {
if (field !== prev) {
child.value = undefined
} else {
child.value = field
}

child = child
value = value
}
}}
{filter}
Expand All @@ -144,6 +151,30 @@
bind:option={child.option}
bind:op={child.op}
bind:value={child.value}
onOpChange={(o) => {
if (isMaybeFieldCondition(child)) {
child.op = o
child = child
value = value
onValueChange?.(value)
}
}}
onOptionChange={(o) => {
if (isMaybeFieldCondition(child)) {
child.option = o
child = child
value = value
onValueChange?.(value)
}
}}
onValueChange={(v) => {
if (isMaybeFieldCondition(child)) {
child.value = v
child = child
value = value
onValueChange?.(value)
}
}}
/>
</div>
<div class="col-span-1 flex items-center gap-2">
Expand Down Expand Up @@ -184,7 +215,7 @@
{/if}
</div>
</div>
<svelte:self bind:value={child} {table} level={level + 1} {readonly} {disabled} />
<svelte:self {onValueChange} bind:value={child} {table} level={level + 1} {readonly} {disabled} {filter} />
</div>
{/if}
{/each}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
$: ops = conditionOps.map((op) => ({ value: op, label: $LL.table.ops[op]() })) ?? []
export let disabled = false

export let onValueChange: ((value: IOpType) => void) | undefined = undefined

let open = false
export let value: IOpType | undefined = undefined

Expand Down Expand Up @@ -57,6 +59,7 @@
onSelect={(currentValue) => {
value = currentValue
closeAndFocusTrigger(ids.trigger)
onValueChange?.(currentValue)
}}
>
<Check class={cn("mr-2 h-4 w-4", value !== framework.value && "text-transparent")} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
export let field: SelectField
export let value: any
export let disabled = false

export let onValueChange: (value: any) => void = () => {}
</script>

<OptionPicker {disabled} {...$$restProps} bind:value options={field.options} />
<OptionPicker {disabled} {...$$restProps} bind:value options={field.options} {onValueChange} />
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
export let field: SelectField
export let value: any
export let disabled = false

export let onValueChange: (value: string[] | null) => void = () => {}
</script>

<OptionsPicker {disabled} {...$$restProps} bind:value options={field.options} />
<OptionsPicker {disabled} {...$$restProps} bind:value options={field.options} {onValueChange} />
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,24 @@
<span class="flex w-full items-center truncate">
{#if internalValue && internalValue.start}
{#if internalValue.end}
{formatter(internalValue.start.toDate())} - {formatter(internalValue.end.toDate())}
<span class="flex items-center gap-1">
<span class="rounded-sm border bg-gray-50 px-1 py-0.5">
{formatter(internalValue.start.toDate())}
</span>
<span class="mx-1 text-xs text-gray-500"> - </span>
<span class="rounded-sm border bg-gray-50 px-1 py-0.5">
{formatter(internalValue.end.toDate())}
</span>
</span>
{:else}
{formatter(internalValue.start.toDate())}
<span class="rounded-sm border bg-gray-50 px-1 py-0.5">
{formatter(internalValue.start.toDate())}
</span>
{/if}
{:else if value?.[0]}
{formatter(new Date(value[0]))}
<span class="rounded-sm border bg-gray-50 px-1 py-0.5">
{formatter(new Date(value[0]))}
</span>
{/if}
</span>
</Popover.Trigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@
<Command.Item
value={option.id}
onSelect={(currentValue) => {
value = value?.includes(currentValue)
const v = value?.includes(currentValue)
? value?.filter((v) => v !== currentValue)
: [...(value ?? []), currentValue]
onValueChange(value ?? [])
value = v
onValueChange(v ?? [])
}}
>
<Check class={cn("text-primary mr-2 h-4 w-4", !value?.includes(option.id) && "text-transparent")} />
Expand Down
7 changes: 5 additions & 2 deletions apps/frontend/src/lib/components/ui/input/number-input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
import Input from "./input.svelte"

export let value: number | undefined
export let onValueChange: ((value: number) => void) | undefined = undefined

function onInput(e: Event) {
value = +(e.target as HTMLInputElement).value
const v = Number((e.target as HTMLInputElement).value)
value = v
onValueChange?.(v)
}
</script>

<Input {...$$restProps} type="number" {value} on:input={onInput} />
<Input {...$$restProps} type="number" {value} on:change on:input={onInput} />
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "undb",
"version": "1.0.0-124",
"version": "1.0.0-125",
"private": true,
"scripts": {
"build": "NODE_ENV=production bun --bun turbo build",
Expand Down
Loading
Loading