-
Notifications
You must be signed in to change notification settings - Fork 1
Feat: search table tip #1449
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
Feat: search table tip #1449
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@milaboratories/milaboratories.ui-examples.ui": patch | ||
| "@milaboratories/uikit": patch | ||
| "@platforma-sdk/ui-vue": patch | ||
| --- | ||
|
|
||
| add helper with tooltip for table fast search |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,47 +2,52 @@ | |
| import { PlIcon16 } from "../PlIcon16"; | ||
| import { PlIcon24 } from "../PlIcon24"; | ||
| import { computed } from "vue"; | ||
| import PlTooltip from "../PlTooltip/PlTooltip.vue"; | ||
|
|
||
| const emit = defineEmits(["update:modelValue"]); | ||
| const model = defineModel<string>({ required: true }); | ||
|
|
||
| const props = defineProps<{ | ||
| modelValue?: string; | ||
| clearable?: boolean; | ||
| placeholder?: string; | ||
| disabled?: boolean; | ||
| helper?: string; | ||
| }>(); | ||
| const slots = defineSlots<{ | ||
| helper: () => unknown; | ||
| }>(); | ||
|
|
||
| const value = computed({ | ||
| get() { | ||
| return props.modelValue ?? ""; | ||
| }, | ||
| set(v) { | ||
| emit("update:modelValue", v); | ||
| }, | ||
| }); | ||
|
|
||
| const nonEmpty = computed(() => !!props.modelValue); | ||
| const nonEmpty = computed(() => model.value != null && model.value.length > 0); | ||
| const hasHelper = computed(() => props.helper != null || slots.helper != null); | ||
|
|
||
| const clear = () => emit("update:modelValue", ""); | ||
| const clear = () => (model.value = ""); | ||
| </script> | ||
|
|
||
| <template> | ||
| <div ref="root" class="pl-search-field" :class="[$style.component]"> | ||
| <div ref="root" :class="$style.component"> | ||
| <PlIcon24 name="search" /> | ||
| <input | ||
| ref="input" | ||
| v-model="value" | ||
| :disabled="disabled" | ||
| :placeholder="placeholder || 'Find...'" | ||
| v-model="model" | ||
| :disabled="props.disabled" | ||
|
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. |
||
| :placeholder="props.placeholder || 'Find...'" | ||
|
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. |
||
| type="text" | ||
|
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. |
||
| spellcheck="false" | ||
| /> | ||
| <PlIcon16 | ||
| v-if="clearable && nonEmpty" | ||
| v-if="props.clearable && nonEmpty" | ||
| :class="$style.clear" | ||
| name="delete-clear" | ||
| @click.stop="clear" | ||
| /> | ||
|
|
||
| <PlTooltip v-if="hasHelper" class="info" position="bottom"> | ||
| <template #tooltip> | ||
| <slot name="helper"> | ||
| {{ props.helper }} | ||
| </slot> | ||
| </template> | ||
| </PlTooltip> | ||
| </div> | ||
| </template> | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,38 @@ | ||
| <script lang="ts" setup> | ||
| import { PlSearchField } from "@milaboratories/uikit"; | ||
| import { ref, watch } from "vue"; | ||
| import { useDebounceFn } from "@vueuse/core"; | ||
|
|
||
| const model = defineModel<string>({ required: true }); | ||
|
Comment on lines
3
to
4
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. |
||
|
|
||
| const localValue = ref(model.value ?? ""); | ||
|
|
||
| const emitDebounced = useDebounceFn((value: string) => { | ||
| model.value = value; | ||
| }, 300); | ||
|
|
||
| watch(localValue, (value) => { | ||
| emitDebounced(value); | ||
| }); | ||
|
|
||
| watch(model, (value) => { | ||
| if (value !== localValue.value) { | ||
| localValue.value = value ?? ""; | ||
| } | ||
| }); | ||
| </script> | ||
|
|
||
| <template> | ||
| <PlSearchField v-model="localValue" clearable placeholder="Search..." /> | ||
| <PlSearchField v-model="model" clearable placeholder="Search..."> | ||
| <template #helper> | ||
| <b>How table search works:</b> | ||
| <br /> | ||
| <ul> | ||
| <li> | ||
| <b>Exact match only.</b><br /> | ||
| No partials, wildcards, ranges, or regex. | ||
| </li> | ||
| <li> | ||
| <b>Scope:</b> Searches all visible columns. To include a column, make it visible in | ||
| Columns. | ||
| </li> | ||
| <li> | ||
| <b>Text columns:</b> Exact string equality. Characters must match exactly (including case, | ||
|
Comment on lines
6
to
+22
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. |
||
| spaces, and punctuation). | ||
| </li> | ||
| <li> | ||
| <b>Number columns:</b> Exact numeric equality. 71 matches 71 and 71.0; it does not match | ||
| 715 or 0.71/0.85. | ||
| </li> | ||
| </ul> | ||
| <b>Examples:</b> | ||
| <br /> | ||
| <ul> | ||
| <li>CASSLDRGTEAFF → shows rows where any visible column equals that full string.</li> | ||
| <li>85 → matches 85 / 85.0, not 0.85 or 850.</li> | ||
| </ul> | ||
| </template> | ||
| </PlSearchField> | ||
| </template> | ||
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.
The
modelValueprop is redundant sincedefineModelis being used. It should be removed to avoid confusion and potential conflicts.