From 5f76b115953663abdf2080ececa5b567e2654728 Mon Sep 17 00:00:00 2001 From: kwongz Date: Thu, 28 Nov 2024 11:27:30 -0500 Subject: [PATCH 01/21] updating date input --- .../date-input/DateInput.stories.svelte | 46 ++ .../atoms/inputs/date-input/DateInput.svelte | 142 +++++++ .../atoms/inputs/date-input/_DateInput.svelte | 401 ++++++++++++++++++ .../src/lib/atoms/inputs/date-input/index.js | 1 + .../date-range/DateRange.stories.svelte | 5 +- .../atoms/inputs/date-range/DateRange.svelte | 18 +- .../src/lib/atoms/inputs/index.js | 1 + .../shadcn/calendar/calendar-cell.svelte | 19 + .../atoms/shadcn/calendar/calendar-day.svelte | 40 ++ .../shadcn/calendar/calendar-grid-body.svelte | 11 + .../shadcn/calendar/calendar-grid-head.svelte | 11 + .../shadcn/calendar/calendar-grid-row.svelte | 11 + .../shadcn/calendar/calendar-grid.svelte | 11 + .../shadcn/calendar/calendar-head-cell.svelte | 14 + .../shadcn/calendar/calendar-header.svelte | 14 + .../shadcn/calendar/calendar-heading.svelte | 17 + .../shadcn/calendar/calendar-months.svelte | 13 + .../calendar/calendar-next-button.svelte | 25 ++ .../calendar/calendar-prev-button.svelte | 27 ++ .../lib/atoms/shadcn/calendar/calendar.svelte | 177 ++++++++ .../src/lib/atoms/shadcn/calendar/index.js | 30 ++ .../range-calendar/range-calendar.svelte | 6 +- .../atoms/shadcn/select/select-trigger.svelte | 8 +- sites/docs/components/DocTab.svelte | 15 +- sites/docs/components/DocWrapper.svelte | 3 + .../docs/pages/components/date-input/index.md | 318 ++++++++++++++ 26 files changed, 1365 insertions(+), 19 deletions(-) create mode 100644 packages/ui/core-components/src/lib/atoms/inputs/date-input/DateInput.stories.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/inputs/date-input/DateInput.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/inputs/date-input/index.js create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-cell.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-day.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid-body.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid-head.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid-row.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-head-cell.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-header.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-heading.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-months.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-next-button.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-prev-button.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar.svelte create mode 100644 packages/ui/core-components/src/lib/atoms/shadcn/calendar/index.js create mode 100644 sites/docs/components/DocWrapper.svelte create mode 100644 sites/docs/pages/components/date-input/index.md diff --git a/packages/ui/core-components/src/lib/atoms/inputs/date-input/DateInput.stories.svelte b/packages/ui/core-components/src/lib/atoms/inputs/date-input/DateInput.stories.svelte new file mode 100644 index 0000000000..369651f511 --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/inputs/date-input/DateInput.stories.svelte @@ -0,0 +1,46 @@ + + + + + + + +

+ Input Store: +

value: {$inputStore.dateInput.value}

+

start: {$inputStore.dateInput.start}

+

end: {$inputStore.dateInput.end}

+ + +
+ +

+ Input Store: +

value: {$inputStore.dateInput_range.value}

+

start: {$inputStore.dateInput_range.start}

+

end: {$inputStore.dateInput_range.end}

+ + +
diff --git a/packages/ui/core-components/src/lib/atoms/inputs/date-input/DateInput.svelte b/packages/ui/core-components/src/lib/atoms/inputs/date-input/DateInput.svelte new file mode 100644 index 0000000000..ea7310db1c --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/inputs/date-input/DateInput.svelte @@ -0,0 +1,142 @@ + + + + + +
+ {#if title} + {title} + {/if} + + {#if $query?.error} + + error + + + {:else} + + + + + + + + {/if} +
+
diff --git a/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte b/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte new file mode 100644 index 0000000000..3890d8d0d4 --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte @@ -0,0 +1,401 @@ + + +
+ + + + + + {#if range} + { + selectedPreset = undefined; + selectedDateInput = value; + }} + minValue={calendarStart} + maxValue={calendarEnd} + /> + {:else} + { + selectedPreset = undefined; + selectedDateInput = value; + }} + minValue={calendarStart} + maxValue={calendarEnd} + /> + {/if} + + + { + v.range = v.value; + applyPreset(v); + }} + bind:selected={selectedPreset} + disabled={!loaded} + > + + {#if selectedPreset} + {selectedPreset.label} + {:else} + + Range + {/if} + + {#if presets && presets.length === 0} + +

No Valid Presets

+
+ {:else if range} + + {#each presets.filter((d) => d.group === 'Days') as preset} + {preset.label} + {/each} + {#if groupExists('Months')} + + {/if} + {#each presets.filter((d) => d.group === 'Months') as preset} + {preset.label} + {/each} + {#if groupExists('Last')} + + {/if} + {#each presets.filter((d) => d.group === 'Last') as preset} + {preset.label} + {/each} + {#if groupExists('To Date')} + + {/if} + {#each presets.filter((d) => d.group === 'To Date') as preset} + {preset.label} + {/each} + {#each presets.filter((d) => d.group === 'Single Input') as preset} + {preset.label} + {/each} + + {/if} +
+
diff --git a/packages/ui/core-components/src/lib/atoms/inputs/date-input/index.js b/packages/ui/core-components/src/lib/atoms/inputs/date-input/index.js new file mode 100644 index 0000000000..966031e43a --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/inputs/date-input/index.js @@ -0,0 +1 @@ +export { default as DateInput } from './DateInput.svelte'; diff --git a/packages/ui/core-components/src/lib/atoms/inputs/date-range/DateRange.stories.svelte b/packages/ui/core-components/src/lib/atoms/inputs/date-range/DateRange.stories.svelte index d591d58f60..68df33b211 100644 --- a/packages/ui/core-components/src/lib/atoms/inputs/date-range/DateRange.stories.svelte +++ b/packages/ui/core-components/src/lib/atoms/inputs/date-range/DateRange.stories.svelte @@ -14,6 +14,8 @@ @@ -111,13 +114,14 @@ - {/if} diff --git a/packages/ui/core-components/src/lib/atoms/inputs/index.js b/packages/ui/core-components/src/lib/atoms/inputs/index.js index b3e72e168b..bcf2ea55b6 100644 --- a/packages/ui/core-components/src/lib/atoms/inputs/index.js +++ b/packages/ui/core-components/src/lib/atoms/inputs/index.js @@ -2,5 +2,6 @@ export * from './text'; export * from './dropdown'; export * from './button-group'; export * from './date-range'; +export * from './date-input'; export * from './checkbox'; export * from './slider'; diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-cell.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-cell.svelte new file mode 100644 index 0000000000..4403358207 --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-cell.svelte @@ -0,0 +1,19 @@ + + + + + diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-day.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-day.svelte new file mode 100644 index 0000000000..abeb09d3f1 --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-day.svelte @@ -0,0 +1,40 @@ + + + + + {date.day} + + diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid-body.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid-body.svelte new file mode 100644 index 0000000000..1c8f671e1d --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid-body.svelte @@ -0,0 +1,11 @@ + + + + + diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid-head.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid-head.svelte new file mode 100644 index 0000000000..13714ca75d --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid-head.svelte @@ -0,0 +1,11 @@ + + + + + diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid-row.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid-row.svelte new file mode 100644 index 0000000000..defc4def5b --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid-row.svelte @@ -0,0 +1,11 @@ + + + + + diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid.svelte new file mode 100644 index 0000000000..d2061c88e3 --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-grid.svelte @@ -0,0 +1,11 @@ + + + + + diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-head-cell.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-head-cell.svelte new file mode 100644 index 0000000000..6cec056385 --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-head-cell.svelte @@ -0,0 +1,14 @@ + + + + + diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-header.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-header.svelte new file mode 100644 index 0000000000..81084dc5e2 --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-header.svelte @@ -0,0 +1,14 @@ + + + + + diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-heading.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-heading.svelte new file mode 100644 index 0000000000..5f2dfc1a8c --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-heading.svelte @@ -0,0 +1,17 @@ + + + + + {headingValue} + + diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-months.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-months.svelte new file mode 100644 index 0000000000..840829065f --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-months.svelte @@ -0,0 +1,13 @@ + + +
+ +
diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-next-button.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-next-button.svelte new file mode 100644 index 0000000000..1c8f7c610f --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-next-button.svelte @@ -0,0 +1,25 @@ + + + + + + + diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-prev-button.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-prev-button.svelte new file mode 100644 index 0000000000..455cc094cc --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar-prev-button.svelte @@ -0,0 +1,27 @@ + + + + + + + diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar.svelte new file mode 100644 index 0000000000..8f15743787 --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/calendar.svelte @@ -0,0 +1,177 @@ + + + +
+ + + { + if (!v || !placeholder) return; + if (v.value === placeholder?.month) return; + placeholder = placeholder.set({ month: v.value }); + }} + > + + + + + {#each monthOptions as { value, label }} + + {label} + + {/each} + + + { + if (!v || !placeholder) return; + if (v.value === placeholder?.year) return; + placeholder = placeholder.set({ year: v.value }); + }} + > + + + + + {#each yearOptions as { value, label }} + + {label} + + {/each} + + + + +
+ + {#each months as month} + + + + {#each weekdays as weekday} + + {weekday.slice(0, 2)} + + {/each} + + + + {#each month.weeks as weekDates} + + {#each weekDates as date} + + + + {/each} + + {/each} + + + {/each} + +
diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/calendar/index.js b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/index.js new file mode 100644 index 0000000000..5d60fa56eb --- /dev/null +++ b/packages/ui/core-components/src/lib/atoms/shadcn/calendar/index.js @@ -0,0 +1,30 @@ +import Root from './calendar.svelte'; +import Cell from './calendar-cell.svelte'; +import Day from './calendar-day.svelte'; +import Grid from './calendar-grid.svelte'; +import Header from './calendar-header.svelte'; +import Months from './calendar-months.svelte'; +import GridRow from './calendar-grid-row.svelte'; +import Heading from './calendar-heading.svelte'; +import GridBody from './calendar-grid-body.svelte'; +import GridHead from './calendar-grid-head.svelte'; +import HeadCell from './calendar-head-cell.svelte'; +import NextButton from './calendar-next-button.svelte'; +import PrevButton from './calendar-prev-button.svelte'; + +export { + Day, + Cell, + Grid, + Header, + Months, + GridRow, + Heading, + GridBody, + GridHead, + HeadCell, + NextButton, + PrevButton, + // + Root as Calendar +}; diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/range-calendar/range-calendar.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/range-calendar/range-calendar.svelte index 79a3e07bcf..3e96699df3 100644 --- a/packages/ui/core-components/src/lib/atoms/shadcn/range-calendar/range-calendar.svelte +++ b/packages/ui/core-components/src/lib/atoms/shadcn/range-calendar/range-calendar.svelte @@ -15,7 +15,7 @@ /** @type {DateValue | undefined} */ let placeholder = undefined; /** @type {{ start: DateValue; end: DateValue; } | undefined} */ - let selectedDateRange = undefined; + let selectedDateInput = undefined; /** @type {'short' | 'long' | undefined} */ let weekdayFormat = 'short'; /** @type {DateValue | undefined} */ @@ -66,7 +66,7 @@ placeholder, weekdayFormat, startValue, - selectedDateRange, + selectedDateInput, minValue, maxValue }; @@ -76,7 +76,7 @@ bind:value bind:placeholder bind:startValue - bind:selectedDateRange + bind:selectedDateInput {minValue} {maxValue} {weekdayFormat} diff --git a/packages/ui/core-components/src/lib/atoms/shadcn/select/select-trigger.svelte b/packages/ui/core-components/src/lib/atoms/shadcn/select/select-trigger.svelte index 134a69fa7c..5e10dc4039 100644 --- a/packages/ui/core-components/src/lib/atoms/shadcn/select/select-trigger.svelte +++ b/packages/ui/core-components/src/lib/atoms/shadcn/select/select-trigger.svelte @@ -6,11 +6,17 @@ /** @type {string | undefined | null} */ let className = undefined; - + export let range = undefined; + export let openVar = undefined; export { className as class }; { + if (range === false && openVar) { + $openVar = !$openVar; + } + }} class={cn( 'border-input flex h-9 w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-white placeholder:text-gray-500 focus:outline-none focus:ring-1 focus:ring-gray-400 disabled:cursor-not-allowed disabled:opacity-50', className diff --git a/sites/docs/components/DocTab.svelte b/sites/docs/components/DocTab.svelte index 9dce689588..9ee18d1800 100644 --- a/sites/docs/components/DocTab.svelte +++ b/sites/docs/components/DocTab.svelte @@ -5,11 +5,9 @@ let activeTab = 'preview'; const tabs = ['preview', 'code']; - let tabButtons = []; - function setTab(tab, index) { + function setTab(tab) { activeTab = tab; - updateActiveBorder(index); } const [send, receive] = crossfade({ @@ -21,15 +19,14 @@
- {#each tabs as tab, index} + {#each tabs as tab}
@@ -51,7 +48,9 @@ class={activeTab !== 'preview' ? 'h-[0px]' : 'mb-3 mt-2'} class:invisible={activeTab !== 'preview'} > - +
+ +
div:first-of-type) { margin: 0; + box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), + var(--tw-shadow); } diff --git a/sites/docs/components/DocWrapper.svelte b/sites/docs/components/DocWrapper.svelte new file mode 100644 index 0000000000..95785e5b12 --- /dev/null +++ b/sites/docs/components/DocWrapper.svelte @@ -0,0 +1,3 @@ +
+ +
diff --git a/sites/docs/pages/components/date-input/index.md b/sites/docs/pages/components/date-input/index.md new file mode 100644 index 0000000000..0151bb7525 --- /dev/null +++ b/sites/docs/pages/components/date-input/index.md @@ -0,0 +1,318 @@ +--- +title: Date Input +sidebar_position: 1 +queries: +- orders_by_day.sql +--- + +Creates a date picker that can be used to filter a query. + +To see how to filter a query using an input component, see [Filters](/core-concepts/filters). + +```sql filtered_query +select +* +from ${orders_by_day} +where day = '${inputs.date_filtering_a_query.value}' +``` + + +
+
+ + + +
+
+ +````markdown + +```sql filtered_query +select + * +from ${orders_by_day} +where day = '${inputs.range_filtering_a_query.value}' +``` + + + + +```` +
+ +## Examples + +### Using Date Input from a Query + +The Date selected can be accessed through the `inputs.[name].value` + + +
+
+ + + Date Selected: {inputs.date_input_from_query.value} +
+
+ +````markdown + + +Date Selected: {inputs.date_input_from_query.value} +```` +
+ +### With a Title + + +
+
+ +
+
+ +```markdown + +``` +
+ +## Date Range + +Creates a date picker for selecting a date range to filter queries, with selectable preset date options. + +### Filtering a Query with Range Calendar + +The Date selected can be accessed through the `inputs.[name].start` & `inputs.[name].end` + +```sql filtered_query_ranged +select + * +from ${orders_by_day} +where day between '${inputs.range_filtering_a_query.start}' and '${inputs.range_filtering_a_query.end}' +``` + + +
+
+ +
+ + +
+ +````markdown + +```sql filtered_query_ranged +select + * +from ${orders_by_day} +where day between '${inputs.range_filtering_a_query.start}' - '${inputs.range_filtering_a_query.end}' +``` + + + + +```` +
+ +### Default Value for Preset Ranges + + +
+
+ +
+
+ +````svelte + +```` +
+ +### Customizing Single Preset Ranges + + +
+
+ +
+
+ +```svelte + +``` +
+ +### Customizing Multiple Preset Ranges + + +
+
+ +
+
+ +````svelte + +```` +
+ +### Manually Specifying a Range + + +
+
+ +
+
+ +```markdown + +``` +
+ +## Options + + + + + + + + + +Title to display in the Date Input component + + + + +Customize "Select a Range" drop down, by including present range options. **Range options**: `'Last 7 Days'` `'Last 30 Days'` `'Last 90 Days'` `'Last 3 Months'` `'Last 6 Months'` `'Last 12 Months'` `'Last Month'` `'Last Year'` `'Month to Date'` `'Year to Date'` `'All Time'` + + + + + +Accepts preset in string format to apply default value in Date Input picker. **Range options**: `'Last 7 Days'` `'Last 30 Days'` `'Last 90 Days'` `'Last 3 Months'` `'Last 6 Months'` `'Last 12 Months'` `'Last Month'` `'Last Year'` `'Month to Date'` `'Year to Date'` `'All Time'` + + + From e31bbd4d759be483b48f81f5b0726cd62a45aea7 Mon Sep 17 00:00:00 2001 From: kwongz Date: Thu, 28 Nov 2024 16:28:22 -0500 Subject: [PATCH 02/21] removed dateInput dropdown --- .../atoms/inputs/date-input/_DateInput.svelte | 125 +++++++++--------- .../docs/pages/components/date-input/index.md | 16 --- 2 files changed, 63 insertions(+), 78 deletions(-) diff --git a/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte b/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte index 3890d8d0d4..4230fc547e 100644 --- a/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte +++ b/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte @@ -334,68 +334,69 @@ {/if} - { - v.range = v.value; - applyPreset(v); - }} - bind:selected={selectedPreset} - disabled={!loaded} - > - { + v.range = v.value; + applyPreset(v); + }} + bind:selected={selectedPreset} + disabled={!loaded} > - {#if selectedPreset} - {selectedPreset.label} - {:else} - - Range - {/if} - - {#if presets && presets.length === 0} - -

No Valid Presets

-
- {:else if range} - - {#each presets.filter((d) => d.group === 'Days') as preset} - {preset.label} - {/each} - {#if groupExists('Months')} - - {/if} - {#each presets.filter((d) => d.group === 'Months') as preset} - {preset.label} - {/each} - {#if groupExists('Last')} - - {/if} - {#each presets.filter((d) => d.group === 'Last') as preset} - {preset.label} - {/each} - {#if groupExists('To Date')} - + + {#if selectedPreset} + {selectedPreset.label} + {:else} + + Range {/if} - {#each presets.filter((d) => d.group === 'To Date') as preset} - {preset.label} - {/each} - {#each presets.filter((d) => d.group === 'Single Input') as preset} - {preset.label} - {/each} - - {/if} -
+ + {#if presets && presets.length === 0} + +

No Valid Presets

+
+ + {#each presets.filter((d) => d.group === 'Days') as preset} + {preset.label} + {/each} + {#if groupExists('Months')} + + {/if} + {#each presets.filter((d) => d.group === 'Months') as preset} + {preset.label} + {/each} + {#if groupExists('Last')} + + {/if} + {#each presets.filter((d) => d.group === 'Last') as preset} + {preset.label} + {/each} + {#if groupExists('To Date')} + + {/if} + {#each presets.filter((d) => d.group === 'To Date') as preset} + {preset.label} + {/each} + {#each presets.filter((d) => d.group === 'Single Input') as preset} + {preset.label} + {/each} + + {/if} + + {/if}
diff --git a/sites/docs/pages/components/date-input/index.md b/sites/docs/pages/components/date-input/index.md index 0151bb7525..c33d1b8b7a 100644 --- a/sites/docs/pages/components/date-input/index.md +++ b/sites/docs/pages/components/date-input/index.md @@ -18,7 +18,6 @@ where day = '${inputs.date_filtering_a_query.value}'
-
-
````markdown @@ -66,7 +64,6 @@ The Date selected can be accessed through the `inputs.[name].value`
-
Date Selected: {inputs.date_input_from_query.value} -
````markdown @@ -92,7 +88,6 @@ Date Selected: {inputs.date_input_from_query.value}
-
-
```markdown @@ -131,14 +125,12 @@ where day between '${inputs.range_filtering_a_query.start}' and '${inputs.range_
-
-
-
-
````svelte @@ -193,9 +183,7 @@ where day between '${inputs.range_filtering_a_query.start}' - '${inputs.range_fi
-
-
```svelte @@ -211,9 +199,7 @@ where day between '${inputs.range_filtering_a_query.start}' - '${inputs.range_fi
-
-
````svelte @@ -229,14 +215,12 @@ where day between '${inputs.range_filtering_a_query.start}' - '${inputs.range_fi
-
-
```markdown From 46dd2524f7955e272d4eda56c1f0a2f99bdc725d Mon Sep 17 00:00:00 2001 From: kwongz Date: Thu, 28 Nov 2024 16:29:13 -0500 Subject: [PATCH 03/21] removed docwrapper --- sites/docs/components/DocWrapper.svelte | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 sites/docs/components/DocWrapper.svelte diff --git a/sites/docs/components/DocWrapper.svelte b/sites/docs/components/DocWrapper.svelte deleted file mode 100644 index 95785e5b12..0000000000 --- a/sites/docs/components/DocWrapper.svelte +++ /dev/null @@ -1,3 +0,0 @@ -
- -
From 959a44994a7f7f3e0e901457e82a15e618c62bc3 Mon Sep 17 00:00:00 2001 From: kwongz Date: Thu, 28 Nov 2024 16:43:08 -0500 Subject: [PATCH 04/21] fixed preset select --- .../atoms/inputs/date-input/_DateInput.svelte | 45 +++---------------- .../atoms/shadcn/select/select-trigger.svelte | 7 --- 2 files changed, 5 insertions(+), 47 deletions(-) diff --git a/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte b/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte index 4230fc547e..4da4efff15 100644 --- a/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte +++ b/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte @@ -46,10 +46,8 @@ /** @type {string} */ export let currentDate; - $: presets = range ? presetsRangeCalendar : presetsCalendar; - /** @type { { label: string, group: string, range: import('bits-ui').DateRange }[] } */ - $: presetsRangeCalendar = [ + $: presets = [ { label: 'Last 7 Days', group: 'Days', @@ -140,24 +138,6 @@ } ]; - $: presetsCalendar = [ - { - label: 'Last Day', - group: 'Single Input', - range: calendarEnd - }, - { - label: 'Today', - group: 'Single Input', - range: calendarCurrent - }, - { - label: 'First Day', - group: 'Single Input', - range: calendarStart - } - ]; - function lowerCaseNoSpaceString(unformattedStr) { return unformattedStr.toString().toLowerCase().replace(/\s+/g, ''); } @@ -246,7 +226,7 @@
- +
@@ -43,7 +42,7 @@ where day > '${inputs.range_filtering_a_query.value}' ``` @@ -52,7 +51,6 @@ where day > '${inputs.range_filtering_a_query.value}' data={filtered_query} x=day y=sales - y2=num_orders /> ````
From 0527feb0da06e42c59a051ce332b172abb6c47ce Mon Sep 17 00:00:00 2001 From: kwongz Date: Fri, 29 Nov 2024 14:02:09 -0500 Subject: [PATCH 10/21] updated date input ui --- .../lib/atoms/inputs/date-input/DateInput.svelte | 6 +++--- .../lib/atoms/inputs/date-input/_DateInput.svelte | 14 +++++++++++++- sites/docs/pages/components/date-input/index.md | 3 +++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/ui/core-components/src/lib/atoms/inputs/date-input/DateInput.svelte b/packages/ui/core-components/src/lib/atoms/inputs/date-input/DateInput.svelte index 8f1a8b6fb0..323305a0fc 100644 --- a/packages/ui/core-components/src/lib/atoms/inputs/date-input/DateInput.svelte +++ b/packages/ui/core-components/src/lib/atoms/inputs/date-input/DateInput.svelte @@ -22,7 +22,7 @@ /** @type {string} */ export let name; /** @type {string | undefined} */ - export let title = 'Date Input'; + export let title; /** @type {boolean} */ export let hideDuringPrint = true; @@ -105,7 +105,7 @@
- {#if title} + {#if title && range} {title} {/if} @@ -125,7 +125,6 @@ - {/if} diff --git a/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte b/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte index 9cdc0794ee..fd64490764 100644 --- a/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte +++ b/packages/ui/core-components/src/lib/atoms/inputs/date-input/_DateInput.svelte @@ -15,6 +15,8 @@ import * as Popover from '$lib/atoms/shadcn/popover/index.js'; import { Separator } from '$lib/atoms/shadcn/separator/index.js'; import { Calendar } from '$lib/atoms/shadcn/calendar/index.js'; + import { Icon } from '@steeze-ui/svelte-icon'; + import { Calendar as CalendarIcon } from '@steeze-ui/radix-icons'; function YYYYMMDDToCalendar(yyyymmdd) { const pieces = yyyymmdd.split('-'); @@ -42,6 +44,8 @@ export let defaultValue; /** @type {boolean} */ export let range = false; + /** @type {string} */ + export let title; /** @type { { label: string, group: string, range: import('bits-ui').DateRange }[] } */ $: presets = [ @@ -223,11 +227,18 @@ builders={[builder]} disabled={!loaded} > + {#if !range && title} + {title} + | + {/if}