@optona/otofill 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +110 -3
- package/dist/otofill.js +2260 -0
- package/dist/otofill.min.js +61 -0
- package/dist/types/drivers.d.ts +9 -0
- package/dist/types/engine.d.ts +30 -0
- package/dist/types/fill-utils.d.ts +22 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/io.d.ts +33 -0
- package/dist/types/matcher.d.ts +36 -0
- package/dist/types/panel/dom.d.ts +16 -0
- package/dist/types/panel/panel.d.ts +64 -0
- package/dist/types/panel/styles.d.ts +1 -0
- package/dist/types/scanner.d.ts +30 -0
- package/dist/types/store.d.ts +42 -0
- package/dist/types/types.d.ts +69 -0
- package/dist/types/ui/element-plus.d.ts +7 -0
- package/dist/types/util.d.ts +21 -0
- package/package.json +49 -4
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var Otofill=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,n)=>{let r=Object.setPrototypeOf({},null);for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n&1||t(r,Symbol.toStringTag,{value:`Module`}),n&2?r:Object.preventExtensions(r)},r={ı:`i`,ğ:`g`,ü:`u`,ş:`s`,ö:`o`,ç:`c`,â:`a`,î:`i`,û:`u`};function i(e){return e?e.toLocaleLowerCase(`tr`).replace(/[ığüşöçâîû]/g,e=>r[e]??e).normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,` `).trim():``}function a(e,t){if(e=i(e).replace(/ /g,``),t=i(t).replace(/ /g,``),!e||!t)return 0;if(e===t)return 1;if(e.length<2||t.length<2)return 0;let n=new Map;for(let t=0;t<e.length-1;t++){let r=e.slice(t,t+2);n.set(r,(n.get(r)??0)+1)}let r=0;for(let e=0;e<t.length-1;e++){let i=t.slice(e,e+2),a=n.get(i)??0;a>0&&(n.set(i,a-1),r++)}return 2*r/(e.length+t.length-2)}function o(e){return i(e).replace(/ /g,`_`).slice(0,40)}function s(){let e=globalThis.crypto;return e&&typeof e.randomUUID==`function`?e.randomUUID():Date.now().toString(36)+Math.random().toString(36).slice(2,10)+Math.random().toString(36).slice(2,6)}function c(){return new Date().toISOString()}function l(e){let t=e.trim().replace(/[.+^${}()|[\]\\?]/g,`\\$&`).replace(/\*/g,`.*`);return RegExp(`^`+t+`$`,`i`)}function u(e,t){let n=(e??[]).map(e=>e.trim()).filter(Boolean);return n.length===0||n.some(e=>{try{return l(e).test(t)}catch{return!1}})}function d(e=location){let t=e.pathname.replace(/\/\d+(?=\/|$)/g,`/*`);if(e.hash.startsWith(`#/`)){let n=e.hash.split(`?`)[0].replace(/\/\d+(?=\/|$)/g,`/*`);return`${e.origin}${t}*${n}*`}return`${e.origin}${t}*`}function ee(e=location){return`${e.origin}/*`}function f(e){return/\d{3,}/.test(e)||/[0-9a-f]{8,}/i.test(e)||/^(el-id-|v-\d|:r|mui-|pv_id|react-|ember|ext-|ui-id-|__|input-\d|headlessui-|radix-|n-\d)/i.test(e)}function p(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/["\\#.:[\]()>+~*^$|=\s]/g,`\\$&`)}function m(e){if(e.id&&!f(e.id))return`#${p(e.id)}`;let t=[],n=e;for(;n&&t.length<6;){if(n!==e&&n.id&&!f(n.id)){t.unshift(`#${p(n.id)}`);break}let r=n.tagName.toLowerCase(),i=n.getAttribute(`name`);n===e&&i&&(r+=`[name="${p(i)}"]`);let a=n.parentElement;if(a){let e=n.tagName,t=Array.from(a.children).filter(t=>t.tagName===e);t.length>1&&(r+=`:nth-of-type(${t.indexOf(n)+1})`)}if(t.unshift(r),n.tagName===`FORM`||n.tagName===`BODY`)break;n=a}return t.join(` > `)}var h=e=>new Promise(t=>setTimeout(t,e)),g=`optona-otofill`,_=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,te=new Set([`hidden`,`submit`,`button`,`reset`,`image`,`file`]),ne=`.el-form-item, .ant-form-item, .n-form-item, .v-input, .q-field, .p-field, .p-float-label, .field, .form-group, .form-item, .form-field, .mb-3`,re=`label, .el-form-item__label, .ant-form-item-label, .n-form-item-label, .v-label, .q-field__label, legend`,ie=e=>e.tagName.toLowerCase();function v(e){let t=ie(e);if(t===`textarea`)return`textarea`;if(t===`select`)return`select`;if(t===`input`){if(e.closest(`.el-select, .el-cascader`))return`select`;if(e.closest(`.el-date-editor`))return`date`;let t=(e.getAttribute(`type`)??`text`).toLowerCase();return t===`checkbox`?`checkbox`:t===`radio`?`radio`:[`date`,`datetime-local`,`month`,`time`,`week`].includes(t)?`date`:`text`}return e.isContentEditable?`contenteditable`:`other`}function y(e){return!(!e||!e.matches?.(_)||ie(e)===`input`&&te.has((e.getAttribute(`type`)??`text`).toLowerCase()))}function ae(e){if(!e)return null;if(y(e))return e;let t=e.closest(`label`);if(t?.control&&y(t.control))return t.control;let n=e.closest(_);if(n&&y(n))return n;let r=e.closest(`.el-select, .el-input, .el-date-editor, .p-dropdown, .v-field, .ant-select, .n-input, .q-field`)?.querySelector(_);return r&&y(r)?r:null}function b(e){if(!e.getClientRects().length)return!1;let t=getComputedStyle(e);return t.visibility!==`hidden`&&t.display!==`none`}function oe(e){let t=v(e);if(t===`checkbox`||t===`radio`){if(b(e))return!0;let t=e.closest(`label`)??(e.id?e.getRootNode():null)?.querySelector?.(`label[for="${p(e.id)}"]`);return!!(t&&b(t))||!!(e.parentElement&&b(e.parentElement))}return b(e)}function x(e){return(e??``).replace(/\s+/g,` `).replace(/^[*\s]+|[*:\s]+$/g,``).trim().slice(0,80)}function S(e,t){let n=``,r=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),i;for(;i=r.nextNode();){let e=i.parentElement;!e||t.contains(i)||e.closest(`select, option, textarea, script, style, button`)||(n+=` `+i.textContent)}return x(n)}function se(e,t){return e.getRootNode().getElementById?.(t)??e.ownerDocument.getElementById(t)}function ce(e){let t=e;for(let e=0;t&&e<4;e++){let e=t.previousSibling;for(;e;){if(e.nodeType===Node.TEXT_NODE){let t=x(e.textContent);if(t)return t}else if(e.nodeType===Node.ELEMENT_NODE){let t=e;if(t.matches(_)||t.querySelector(_))return``;let n=x(t.textContent);if(n)return n}e=e.previousSibling}if(t=t.parentElement,!t||t.tagName===`FORM`||t.tagName===`BODY`)break}return``}function le(e){let t=e.getAttribute(`aria-labelledby`);if(t){let n=x(t.split(/\s+/).map(t=>se(e,t)?.textContent??``).join(` `));if(n)return n}if(e.id){let t=e.getRootNode().querySelector?.(`label[for="${p(e.id)}"]`);if(t){let n=S(t,e);if(n)return n}}let n=e.closest(`label`);if(n){let t=S(n,e);if(t)return t}let r=x(e.getAttribute(`aria-label`));if(r)return r;let i=e.closest(ne);if(i){let t=i.querySelector(re);if(t&&!t.contains(e)){let n=S(t,e);if(n)return n}}return ce(e)}function C(e){let t=e.getAttribute(`name`);if(!t)return[e];let n=e.closest(`form`)??e.getRootNode();return Array.from(n.querySelectorAll(`input[type="radio"][name="${p(t)}"]`))}function ue(e){if(e.id){let t=e.getRootNode().querySelector?.(`label[for="${p(e.id)}"]`);if(t)return S(t,e)}let t=e.closest(`label`);if(t)return S(t,e);let n=e.nextSibling;for(;n&&n.nodeType===Node.TEXT_NODE&&!x(n.textContent);)n=n.nextSibling;return x(n?.textContent)}function de(e){let t=C(e),n=e.closest(`fieldset`)?.querySelector(`legend`);if(n)return x(n.textContent);let r=e.closest(`[role="radiogroup"]`);if(r){let t=x(r.getAttribute(`aria-label`))||(r.getAttribute(`aria-labelledby`)?x(se(e,r.getAttribute(`aria-labelledby`))?.textContent):``);if(t)return t}let i=e.closest(ne);if(i){let e=Array.from(i.querySelectorAll(re)).find(e=>!t.some(t=>e.contains(t)||t.id&&e.getAttribute(`for`)===t.id));if(e)return x(e.textContent)}let a=e.parentElement;for(;a&&!t.every(e=>a.contains(e));)a=a.parentElement;return a?ce(a):``}function fe(e){let t=C(e),n=e.parentElement;for(;n&&!t.every(e=>n.contains(e));)n=n.parentElement;return n?`${m(n)} input[type="radio"]`:m(e)}function pe(e){let t=e.closest(`form`);if(t)return(t.id&&!f(t.id)?t.id:``)||t.getAttribute(`name`)||void 0}function w(e,t=0){let n=v(e),r=e.getAttribute(`name`)||void 0,i=r&&!f(r)?r:void 0;return{el:e,kind:n,tag:ie(e),type:e.getAttribute(`type`)?.toLowerCase()||void 0,otofill:e.getAttribute(`data-otofill`)||void 0,id:e.id&&!f(e.id)?e.id:void 0,name:i,label:(n===`radio`?de(e):le(e))||void 0,placeholder:e.getAttribute(`placeholder`)||void 0,ariaLabel:e.getAttribute(`aria-label`)||void 0,css:n===`radio`?i?`input[type="radio"][name="${p(i)}"]`:fe(e):m(e),formKey:pe(e),index:t}}function T(e,t){e.querySelectorAll(_).forEach(e=>{y(e)&&!e.disabled&&oe(e)&&t.push(e)}),e.querySelectorAll(`*`).forEach(e=>{if(e.tagName.toLowerCase()===`optona-otofill`)return;let n=e.shadowRoot;if(n&&T(n,t),e.tagName===`IFRAME`)try{let n=e.contentDocument;n&&T(n,t)}catch{}})}function E(e=document){let t=[];T(e,t);let n=new Set,r=[];for(let e of t)if(v(e)===`radio`){let t=C(e);if(n.has(t[0]))continue;n.add(t[0]),r.push(w(t[0],r.length))}else r.push(w(e,r.length));return r}function me(e){let{el:t,kind:n,...r}=e;return r}function D(e,t){e.dispatchEvent(new Event(t,{bubbles:!0}))}function O(e,t){let n={key:t,code:t,bubbles:!0,cancelable:!0};e.dispatchEvent(new KeyboardEvent(`keydown`,n)),e.dispatchEvent(new KeyboardEvent(`keyup`,n))}function k(e,t){let n=Object.getPrototypeOf(e),r;for(;n&&!(r=Object.getOwnPropertyDescriptor(n,`value`));)n=Object.getPrototypeOf(n);r?.set?r.set.call(e,t):e.value=t}function he(e){if(!e||!e.isConnected||!e.getClientRects().length)return!1;let t=getComputedStyle(e);return t.visibility!==`hidden`&&t.display!==`none`}async function A(e,t=800,n=25){let r=Date.now()+t;for(;;){let t=e();if(t)return t;if(Date.now()>r)return null;await h(n)}}function j(e,t,n=e=>e.textContent??``){let r=i(t);if(r)return e.find(e=>i(n(e))===r)??e.find(e=>i(n(e)).startsWith(r))??e.find(e=>a(n(e),t)>=.85)}var ge=e=>e.split(`|`).map(e=>e.trim()).filter(Boolean);function _e(e){let t=e.trim(),n=``,r=``,i=``,a=``,o=t.match(/^(\d{1,2})[./-](\d{1,2})[./-](\d{4})(.*)$/);return o?[,i,r,n,a]=o:(o=t.match(/^(\d{4})[./-](\d{1,2})[./-](\d{1,2})(.*)$/))&&([,n,r,i,a]=o),n?(r=r.padStart(2,`0`),i=i.padStart(2,`0`),a=a.replace(/^T/,` `),[...new Set([`${n}-${r}-${i}${a}`,t,`${i}.${r}.${n}${a}`,`${i}/${r}/${n}${a}`,`${r}/${i}/${n}${a}`,`${n}/${r}/${i}${a}`])]):[t]}function ve(e,t){let n=e=>(e.match(/\d+/g)??[]).map(Number),r=n(e),i=n(t);return i.length>0&&i.every((e,t)=>r[t]===e)}var M=e=>e.tagName===`INPUT`;function ye(e){let t=e.closest(`.el-select`),n=e,r=t.querySelector(`.el-select__wrapper`)??t,i=()=>{let t=n.getAttribute(`aria-controls`);return t?e.ownerDocument.getElementById(t):null};return{root:t,input:n,wrapper:r,listbox:i,isOpen:()=>n.getAttribute(`aria-expanded`)===`true`&&he(i()),items:()=>Array.from(i()?.querySelectorAll(`.el-select-dropdown__item`)??[]).filter(e=>he(e)&&!e.classList.contains(`is-disabled`))}}async function be(e){e.isOpen()&&(O(e.input,`Escape`),await A(()=>!e.isOpen(),300)||(e.wrapper.click(),await A(()=>!e.isOpen(),300)))}var xe={name:`element-plus-select`,detect:e=>M(e)&&!!e.closest(`.el-select`),async fill(e,t){let n=ye(e),r=ge(t);if(!r.length)return!0;if(n.isOpen()||n.wrapper.click(),!await A(()=>n.isOpen(),800))return!1;let i=n.listbox()?.getAttribute(`aria-multiselectable`)===`true`||n.root.querySelector(`.el-select__selection .el-tag`)!=null||r.length>1,a=!n.input.readOnly;if(i)for(let e of n.items().filter(e=>e.classList.contains(`is-selected`)))r.some(t=>j([e],t))||(e.click(),await h(30));let o=!0;for(let e of r){a&&(k(n.input,e),D(n.input,`input`),await h(120));let t=await A(()=>j(n.items(),e),500);if(!t)o=!1;else if(!(i&&t.classList.contains(`is-selected`))){if(t.click(),await h(40),!i)break;n.isOpen()||n.wrapper.click()}}return await be(n),o},read(e){let t=e.closest(`.el-select`),n=Array.from(t.querySelectorAll(`.el-tag .el-select__tags-text`)).map(e=>e.textContent?.trim()??``);return n.length?n.join(` | `):t.querySelector(`.el-select__placeholder:not(.is-transparent)`)?.textContent?.trim()??``}};function N(){let e=Array.from(document.querySelectorAll(`.el-popper .el-cascader-panel`)).filter(he);return e[e.length-1]??null}var Se=[xe,{name:`element-plus-cascader`,detect:e=>M(e)&&!!e.closest(`.el-cascader`),async fill(e,t){let n=e.closest(`.el-cascader`),r=t.split(/\s*[/>]\s*/).map(e=>e.trim()).filter(Boolean);if(!r.length)return!0;let i=N();if(!i&&(n.click(),i=await A(N,800),!i))return!1;for(let t=0;t<r.length;t++){let n=await A(()=>{let e=i.querySelectorAll(`.el-cascader-menu`)[t];return j(Array.from(e?.querySelectorAll(`.el-cascader-node:not(.is-disabled)`)??[]),r[t],e=>e.querySelector(`.el-cascader-node__label`)?.textContent??e.textContent??``)},600);if(!n)return O(e,`Escape`),document.body.click(),!1;n.click(),await h(60)}return N()&&(O(e,`Escape`),await h(50),N()&&document.body.click()),!0},read:e=>e.value},{name:`element-plus-date`,detect:e=>M(e)&&!!e.closest(`.el-date-editor`),async fill(e,t){let n=e;for(let e of _e(t))if(n.focus({preventScroll:!0}),k(n,e),D(n,`input`),D(n,`change`),await h(40),O(n,`Escape`),n.blur(),await h(40),n.value&&ve(n.value,e))return!0;return!1},read:e=>e.value}],Ce=new Set([`1`,`true`,`evet`,`e`,`yes`,`y`,`on`,`x`,`secili`,`checked`]),we=e=>Ce.has(i(e))||e.trim()===`✓`;function Te(e,t){let n=e.trim().match(/^(\d{1,2})[./-](\d{1,2})[./-](\d{4})(?:[ T](\d{1,2}):(\d{2}))?$/);if(!n)return e;let r=`${n[3]}-${n[2].padStart(2,`0`)}-${n[1].padStart(2,`0`)}`;return t===`datetime-local`?`${r}T${(n[4]??`00`).padStart(2,`0`)}:${n[5]??`00`}`:t===`month`?r.slice(0,7):r}var Ee={name:`native-text`,detect:e=>[`text`,`textarea`,`date`].includes(v(e)),fill(e,t){let n=e,r=(n.getAttribute(`type`)??`text`).toLowerCase(),i=v(e)===`date`?Te(t,r):t;return n.focus({preventScroll:!0}),k(n,i),D(n,`input`),D(n,`change`),n.blur(),v(e)!==`date`||n.value!==``||i===``},read:e=>e.value};function De(e,t){let n=Array.from(e.options),r=i(t);return n.find(e=>e.value===t)??n.find(e=>i(e.text)===r)??n.find(e=>r&&i(e.text).startsWith(r))??n.find(e=>a(e.text,t)>=.85)}var Oe={name:`native-select`,detect:e=>e.tagName===`SELECT`,fill(e,t){let n=e,r=De(n,t);return r?(k(n,r.value),D(n,`input`),D(n,`change`),!0):!1},read:e=>e.selectedOptions[0]?.text.trim()},ke={name:`native-checkbox`,detect:e=>v(e)===`checkbox`,fill(e,t){let n=e;return n.checked!==we(t)&&n.click(),!0},read:e=>e.checked?`true`:`false`},Ae={name:`native-radio`,detect:e=>v(e)===`radio`,fill(e,t){let n=C(e),r=i(t),o=n.find(e=>e.value===t)??n.find(e=>i(ue(e))===r)??n.find(e=>i(e.value)===r)??n.find(e=>a(ue(e),t)>=.8);return o?(o.checked||o.click(),!0):!1},read(e){let t=C(e).find(e=>e.checked);return t?ue(t)||t.value:``}},je={name:`contenteditable`,detect:e=>v(e)===`contenteditable`,fill(e,t){let n=e;return n.focus({preventScroll:!0}),n.textContent=t,n.dispatchEvent(new InputEvent(`input`,{bubbles:!0,inputType:`insertText`,data:t})),n.blur(),!0},read:e=>e.textContent??``},Me=[...Se,ke,Ae,Oe,je,Ee],P=[];function Ne(e){let t=P.findIndex(t=>t.name===e.name);t>=0?P[t]=e:P.unshift(e)}function Pe(e){return P.find(t=>t.detect(e))??Me.find(t=>t.detect(e))}async function Fe(e,t){let n=Pe(e);return n?await n.fill(e,t):!1}function Ie(e){return Pe(e)?.read?.(e)}var Le={otofill:100,id:50,name:40,labelExact:35,css:30,labelFuzzy:25,placeholder:15,ariaLabel:15,type:5,index:5,mismatch:-10,wrongTag:-25,wrongKind:-40},Re=30;function ze(e,t){let n=e.match,r=Le;if(n.otofill&&t.otofill)return n.otofill===t.otofill?r.otofill:0;let o=0;if(n.id&&t.id&&(o+=n.id===t.id?r.id:r.mismatch),n.name&&t.name&&(o+=n.name===t.name?r.name:r.mismatch),n.css)try{t.el.matches(n.css)&&(o+=r.css)}catch{}if(n.label&&t.label){let e=i(n.label),s=i(t.label);if(e===s)o+=r.labelExact;else{let t=a(e,s);t>=.6&&(o+=Math.round(r.labelFuzzy*t))}}return n.placeholder&&t.placeholder&&i(n.placeholder)===i(t.placeholder)&&(o+=r.placeholder),n.ariaLabel&&t.ariaLabel&&i(n.ariaLabel)===i(t.ariaLabel)&&(o+=r.ariaLabel),n.type&&t.type&&n.type===t.type&&(o+=r.type),n.index!=null&&n.index===t.index&&n.formKey===t.formKey&&(o+=r.index),n.tag&&t.tag&&n.tag!==t.tag&&(o+=r.wrongTag),e.kind&&e.kind!==t.kind&&(o+=r.wrongKind),o}function Be(e,t,n=location.href){let r=e.filter(e=>u(e.pages,n)),i=[];for(let e of r)for(let n of t){let t=ze(e,n);t>=30&&i.push({def:e,fp:n,score:t})}i.sort((e,t)=>t.score-e.score);let a=new Set,o=new Set,s=[];for(let e of i)a.has(e.def.id)||o.has(e.fp)||(a.add(e.def.id),o.add(e.fp),s.push(e));return s.sort((e,t)=>(e.fp.index??0)-(t.fp.index??0)),{defs:r,matches:s,missing:r.filter(e=>!a.has(e.id)),free:t.filter(e=>!o.has(e))}}var Ve=n({STATE_VERSION:()=>1,STORAGE_KEY:()=>He,addRow:()=>$e,clearAll:()=>Je,createDataset:()=>Xe,datasetKeys:()=>V,load:()=>L,migrate:()=>Ke,removeDataset:()=>Qe,removeField:()=>B,removeRow:()=>et,save:()=>R,subscribe:()=>qe,update:()=>z,upsertDataset:()=>Ze,upsertField:()=>Ye}),He=`optona-otofill`,F=new Set,Ue=null;function I(){return{v:1,fields:[],datasets:[],prefs:{cursor:{},closeAfterFill:!0}}}function We(){try{return localStorage.getItem(He)}catch{return Ue}}function Ge(e){try{localStorage.setItem(He,e)}catch{Ue=e}}function Ke(e){let t=I();if(!e||typeof e!=`object`)return t;let n=e;return{v:1,fields:Array.isArray(n.fields)?n.fields:[],datasets:Array.isArray(n.datasets)?n.datasets:[],prefs:{...t.prefs,...n.prefs??{},cursor:{...n.prefs?.cursor??{}}}}}function L(){let e=We();if(!e)return I();try{return Ke(JSON.parse(e))}catch{return I()}}function R(e){Ge(JSON.stringify(e)),F.forEach(t=>t(e))}function z(e){let t=L();return e(t),R(t),t}function qe(e){return F.add(e),()=>F.delete(e)}typeof window<`u`&&window.addEventListener(`storage`,e=>{if(e.key===`optona-otofill`){let e=L();F.forEach(t=>t(e))}});function Je(){R(I())}function Ye(e){let t={...e,id:e.id??s(),updatedAt:c()};return z(e=>{let n=e.fields.findIndex(e=>e.id===t.id);n>=0?e.fields[n]=t:e.fields.push(t)}),t}function B(e){z(t=>{t.fields=t.fields.filter(t=>t.id!==e)})}function Xe(e,t=[]){let n={id:s(),name:e,rows:t,updatedAt:c()};return z(e=>{e.datasets.push(n)}),n}function Ze(e){z(t=>{let n={...e,updatedAt:c()},r=t.datasets.findIndex(t=>t.id===e.id);r>=0?t.datasets[r]=n:t.datasets.push(n)})}function Qe(e){z(t=>{t.datasets=t.datasets.filter(t=>t.id!==e),delete t.prefs.cursor[e]})}function $e(e,t){let n={...t,_id:t._id??s()};return z(t=>{let r=t.datasets.find(t=>t.id===e);r&&(r.rows.push(n),r.updatedAt=c())}),n}function et(e,t){z(n=>{let r=n.datasets.find(t=>t.id===e);r&&(r.rows=r.rows.filter(e=>e._id!==t))})}function V(e){let t=new Set;return e.rows.forEach(e=>Object.keys(e).forEach(e=>!e.startsWith(`_`)&&t.add(e))),[...t]}function H(e=L().fields,t=location.href){return Be(e,E(document),t)}async function U(e,t={}){let n=t.retries??3,r=t.delay??300,i=new Set,a=new Set,o=H(),s=new Set;for(let c=0;c<=n;c++){a.clear();for(let n of o.matches){let r=n.def.key;if(i.has(n.def.id))continue;let o=e[r];if(o===void 0){s.add(r);continue}let c=!1;try{c=await Fe(n.fp.el,o)}catch(e){console.warn(`[otofill]`,r,e)}c?(i.add(n.def.id),t.onFilled?.(n.fp.el)):a.add(r)}let l=o.missing.filter(t=>e[t.key]!==void 0&&!i.has(t.id));if(a.size===0&&l.length===0||c===n)break;await h(r),o=H()}let c=o,l=c.defs.filter(e=>i.has(e.id));return{filled:l.map(e=>e.key),notFound:c.missing.filter(t=>!i.has(t.id)&&e[t.key]!==void 0).map(e=>e.key),failed:[...a],noValue:[...s].filter(e=>!l.some(t=>t.key===e))}}function tt(e=H()){let t={};for(let n of e.matches){let e=Ie(n.fp.el);e!==void 0&&(t[n.def.key]=e)}return t}function nt(e,t){let n=new Set(t);return e.map(e=>{let t=new Set;return e.rows.forEach(e=>Object.keys(e).forEach(e=>t.add(e))),{ds:e,overlap:[...n].filter(e=>t.has(e)).length}}).sort((e,t)=>t.overlap-e.overlap||e.ds.name.localeCompare(t.ds.name,`tr`))}function W(e,t=[]){return e._label?e._label:(t.length?t:Object.keys(e).filter(e=>!e.startsWith(`_`))).map(t=>e[t]).filter(e=>e&&e!==`true`&&e!==`false`).slice(0,2).join(` · `)||`(adsız satır)`}var G=`optona-otofill`,rt=1,it=n({ImportError:()=>K,applyBundle:()=>st,csvToDataset:()=>ut,datasetToCsv:()=>ct,download:()=>dt,exportCsv:()=>ft,exportJson:()=>J,importFile:()=>mt,importText:()=>pt,makeBundle:()=>at,parseCsv:()=>lt,summaryText:()=>Y,validateBundle:()=>ot});function at(e=L(),t={fields:!0,datasets:!0}){let n={format:G,version:1,exportedAt:c()};return t.fields&&(n.fields=e.fields),t.datasets&&(n.datasets=Array.isArray(t.datasets)?e.datasets.filter(e=>t.datasets.includes(e.id)):e.datasets),n}var K=class extends Error{};function q(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function ot(e){if(!q(e))throw new K(`Dosya bir JSON nesnesi değil.`);if(e.format!==`optona-otofill`)throw new K(`Bu bir Otofill dosyası değil (format: "${String(e.format)}").`);let t=Number(e.version);if(!t||t>1)throw new K(`Dosya sürümü (${String(e.version)}) bu kütüphaneden yeni. Kütüphaneyi güncelleyin.`);let n={format:G,version:1,exportedAt:String(e.exportedAt??c())};if(e.fields!==void 0){if(!Array.isArray(e.fields))throw new K(`"fields" bir dizi olmalı.`);n.fields=e.fields.map((e,t)=>{if(!q(e)||typeof e.key!=`string`||!e.key.trim())throw new K(`fields[${t}]: "key" eksik.`);return{id:typeof e.id==`string`&&e.id?e.id:s(),key:e.key.trim(),title:typeof e.title==`string`?e.title:void 0,pages:Array.isArray(e.pages)?e.pages.map(String):[],kind:typeof e.kind==`string`?e.kind:void 0,match:q(e.match)?e.match:{},updatedAt:typeof e.updatedAt==`string`?e.updatedAt:void 0}})}if(e.datasets!==void 0){if(!Array.isArray(e.datasets))throw new K(`"datasets" bir dizi olmalı.`);n.datasets=e.datasets.map((e,t)=>{if(!q(e)||typeof e.name!=`string`)throw new K(`datasets[${t}]: "name" eksik.`);if(!Array.isArray(e.rows))throw new K(`datasets[${t}]: "rows" bir dizi olmalı.`);return{id:typeof e.id==`string`&&e.id?e.id:s(),name:e.name,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:void 0,rows:e.rows.map((e,n)=>{if(!q(e))throw new K(`datasets[${t}].rows[${n}] bir nesne değil.`);let r={_id:typeof e._id==`string`&&e._id?e._id:s()};for(let[t,n]of Object.entries(e))t!==`_id`&&n!=null&&(r[t]=String(n));return r})}})}if(!n.fields&&!n.datasets)throw new K(`Dosyada ne alan tanımı ne de veri seti var.`);return n}function st(e,t,n){let r={fieldsAdded:0,fieldsUpdated:0,datasetsAdded:0,datasetsUpdated:0,rows:0},i=t.fields??[],a=t.datasets??[];if(r.rows=a.reduce((e,t)=>e+t.rows.length,0),n===`copy`)return i.forEach(t=>e.fields.push({...t,id:s()})),a.forEach(t=>e.datasets.push({...t,id:s(),rows:t.rows.map(e=>({...e,_id:s()}))})),r.fieldsAdded=i.length,r.datasetsAdded=a.length,r;if(n===`replace`)return t.fields&&(e.fields=[...i],r.fieldsAdded=i.length),t.datasets&&(e.datasets=[...a],r.datasetsAdded=a.length),r;for(let t of i){let n=e.fields.findIndex(e=>e.id===t.id||e.key===t.key&&e.pages.join(`|`)===t.pages.join(`|`));n>=0?(e.fields[n]={...t,id:e.fields[n].id},r.fieldsUpdated++):(e.fields.push(t),r.fieldsAdded++)}for(let t of a){let n=e.datasets.find(e=>e.id===t.id)??e.datasets.find(e=>e.name===t.name);if(!n)e.datasets.push(t),r.datasetsAdded++;else{for(let e of t.rows){let t=n.rows.findIndex(t=>t._id===e._id);t>=0?n.rows[t]=e:n.rows.push(e)}n.updatedAt=c(),r.datasetsUpdated++}}return r}function ct(e,t=V(e)){let n=e=>{let t=e??``;return/[;"\r\n]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t},r=[`_label`,...t],i=[r.map(n).join(`;`)];for(let t of e.rows)i.push(r.map(e=>n(t[e])).join(`;`));return``+i.join(`\r
|
|
2
|
+
`)}function lt(e){e=e.replace(/^/,``);let t=e.split(/\r?\n/,1)[0]??``,n=e=>t.split(e).length-1,r=[`;`,`,`,` `].sort((e,t)=>n(t)-n(e))[0],i=[],a=[],o=``,s=!1;for(let t=0;t<e.length;t++){let n=e[t];s?n===`"`&&e[t+1]===`"`?(o+=`"`,t++):n===`"`?s=!1:o+=n:n===`"`?s=!0:n===r?(a.push(o),o=``):n===`
|
|
3
|
+
`||n===`\r`?(n===`\r`&&e[t+1]===`
|
|
4
|
+
`&&t++,a.push(o),i.push(a),a=[],o=``):o+=n}return(o!==``||a.length)&&(a.push(o),i.push(a)),i.filter(e=>e.some(e=>e.trim()!==``))}function ut(e,t){let n=lt(e);if(n.length<1)throw new K(`CSV boş.`);let r=n[0].map(e=>e.trim());if(r.filter(e=>e&&!e.startsWith(`_`)).length===0)throw new K(`CSV başlık satırında anahtar yok.`);return{id:s(),name:t,updatedAt:c(),rows:n.slice(1).map(e=>{let t={_id:s()};return r.forEach((n,r)=>{if(!n)return;let i=e[r]??``;n===`_label`||n.toLocaleLowerCase(`tr`)===`etiket`?t._label=i:n===`_id`?t._id=i||t._id:i!==``&&(t[n]=i)}),t})}}function dt(e,t,n=`application/json`){let r=new Blob([t],{type:`${n};charset=utf-8`}),i=document.createElement(`a`);i.href=URL.createObjectURL(r),i.download=e,document.body.appendChild(i),i.click(),setTimeout(()=>{URL.revokeObjectURL(i.href),i.remove()},0)}function J(e,t){let n=at(L(),e),r=new Date().toISOString().slice(0,10);dt(t??`otofill-${r}.json`,JSON.stringify(n,null,2))}function ft(e){let t=L().datasets.find(t=>t.id===e);t&&dt(`${t.name.replace(/[\\/:*?"<>|]+/g,`_`)}.csv`,ct(t),`text/csv`)}function pt(e,t,n=`veri.json`){let r,i=e.replace(/^/,``).trimStart();if(/\.csv$/i.test(n)||!(i.startsWith(`{`)||i.startsWith(`[`))){let t=n.replace(/\.[^.]+$/,``)||`CSV verisi`;r={format:G,version:1,exportedAt:c(),datasets:[ut(e,t)]}}else{let e;try{e=JSON.parse(i)}catch(e){throw new K(`JSON okunamadı: `+e.message)}r=ot(e)}let a=L(),o=st(a,r,t);return R(a),o}async function mt(e,t){return pt(await e.text(),t,e.name)}function Y(e){let t=[];return e.fieldsAdded&&t.push(`${e.fieldsAdded} alan eklendi`),e.fieldsUpdated&&t.push(`${e.fieldsUpdated} alan güncellendi`),e.datasetsAdded&&t.push(`${e.datasetsAdded} veri seti eklendi`),e.datasetsUpdated&&t.push(`${e.datasetsUpdated} veri seti güncellendi`),e.rows&&t.push(`${e.rows} satır`),t.join(`, `)||`Değişiklik yok`}function X(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&(e.startsWith(`on`)&&typeof n==`function`?r.addEventListener(e.slice(2).toLowerCase(),n):e===`class`?r.className=String(n):e===`value`?r.value=String(n):e===`checked`?r.checked=!!n:e===`style`&&typeof n==`object`?Object.assign(r.style,n):r.setAttribute(e,n===!0?``:String(n)));return ht(r,n),r}function ht(e,t){for(let n of t)n!=null&&n!==!1&&(Array.isArray(n)?ht(e,n):e.appendChild(typeof n==`object`?n:document.createTextNode(String(n))))}function gt(e){let t=e.toLowerCase().split(`+`).map(e=>e.trim()),n=t[t.length-1],r=/^[a-z]$/.test(n)?`Key${n.toUpperCase()}`:/^\d$/.test(n)?`Digit${n}`:n[0].toUpperCase()+n.slice(1);return{ctrl:t.includes(`ctrl`),shift:t.includes(`shift`),alt:t.includes(`alt`),meta:t.includes(`meta`)||t.includes(`cmd`),code:r}}function _t(e,t){return e.code===t.code&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.altKey===t.alt&&e.metaKey===t.meta}var vt=`
|
|
5
|
+
:host { all: initial; }
|
|
6
|
+
* { box-sizing: border-box; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
|
|
7
|
+
.panel {
|
|
8
|
+
position: fixed; top: 16px; right: 16px; width: 380px; max-height: calc(100vh - 32px);
|
|
9
|
+
display: flex; flex-direction: column; background: #fff; color: #1f2937; font-size: 13px; line-height: 1.4;
|
|
10
|
+
border: 1px solid #d1d5db; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.22); z-index: 2147483646; overflow: hidden;
|
|
11
|
+
}
|
|
12
|
+
.head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #111827; color: #fff; cursor: move; user-select: none; }
|
|
13
|
+
.head b { font-size: 13px; letter-spacing: .2px; }
|
|
14
|
+
.head .sub { color: #9ca3af; font-size: 11px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
15
|
+
.head button { background: transparent; border: 0; color: #d1d5db; font-size: 16px; cursor: pointer; padding: 0 4px; }
|
|
16
|
+
.tabs { display: flex; border-bottom: 1px solid #e5e7eb; background: #f9fafb; }
|
|
17
|
+
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 4px; cursor: pointer; font-size: 12px; color: #4b5563; border-bottom: 2px solid transparent; }
|
|
18
|
+
.tabs button.on { color: #111827; border-bottom-color: #2563eb; font-weight: 600; }
|
|
19
|
+
.body { overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
|
|
20
|
+
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
|
|
21
|
+
.muted { color: #6b7280; font-size: 12px; }
|
|
22
|
+
.sec { font-weight: 600; font-size: 12px; color: #374151; margin-top: 2px; }
|
|
23
|
+
button.btn { border: 1px solid #d1d5db; background: #fff; border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: 12px; color: #1f2937; }
|
|
24
|
+
button.btn:hover { background: #f3f4f6; }
|
|
25
|
+
button.pri { background: #2563eb; border-color: #2563eb; color: #fff; }
|
|
26
|
+
button.pri:hover { background: #1d4ed8; }
|
|
27
|
+
button.dng { color: #b91c1c; border-color: #fca5a5; }
|
|
28
|
+
button.sm { padding: 2px 6px; font-size: 11px; }
|
|
29
|
+
button:disabled { opacity: .5; cursor: default; }
|
|
30
|
+
input[type=text], select, textarea { border: 1px solid #d1d5db; border-radius: 6px; padding: 5px 7px; font-size: 12px; color: #111827; background: #fff; min-width: 0; }
|
|
31
|
+
input[type=text]:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: #2563eb; }
|
|
32
|
+
textarea { width: 100%; min-height: 70px; font-family: ui-monospace, Consolas, monospace; font-size: 11px; }
|
|
33
|
+
.grow { flex: 1; }
|
|
34
|
+
.list { display: flex; flex-direction: column; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }
|
|
35
|
+
.item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-top: 1px solid #f3f4f6; }
|
|
36
|
+
.item:first-child { border-top: 0; }
|
|
37
|
+
.item.click { cursor: pointer; }
|
|
38
|
+
.item.click:hover, .item.cur { background: #eff6ff; }
|
|
39
|
+
.num { min-width: 18px; height: 18px; border-radius: 4px; background: #e5e7eb; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; color: #374151; }
|
|
40
|
+
.key { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #1e40af; }
|
|
41
|
+
.ok { color: #15803d; } .bad { color: #b91c1c; } .warn { color: #b45309; }
|
|
42
|
+
.toast { padding: 7px 9px; border-radius: 6px; font-size: 12px; }
|
|
43
|
+
.toast.ok { background: #dcfce7; color: #14532d; } .toast.err { background: #fee2e2; color: #7f1d1d; }
|
|
44
|
+
.drop { border: 2px dashed #cbd5e1; border-radius: 8px; padding: 14px; text-align: center; color: #64748b; cursor: pointer; }
|
|
45
|
+
.drop.over { border-color: #2563eb; background: #eff6ff; }
|
|
46
|
+
.empty { padding: 14px; text-align: center; color: #6b7280; }
|
|
47
|
+
table { border-collapse: collapse; width: 100%; font-size: 11px; }
|
|
48
|
+
th, td { border-bottom: 1px solid #f3f4f6; padding: 3px 4px; text-align: left; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
49
|
+
th { color: #6b7280; font-weight: 600; }
|
|
50
|
+
label.opt { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }
|
|
51
|
+
.layer { position: fixed; inset: 0; pointer-events: none; z-index: 2147483645; }
|
|
52
|
+
.hl { position: fixed; border: 2px solid #2563eb; background: rgba(37,99,235,.08); border-radius: 4px; transition: opacity .4s; }
|
|
53
|
+
.hl.green { border-color: #16a34a; background: rgba(22,163,74,.12); }
|
|
54
|
+
.badge { position: fixed; transform: translateY(-100%); font: 600 10px/1.6 ui-monospace, Consolas, monospace; padding: 0 5px; border-radius: 4px 4px 4px 0; background: #16a34a; color: #fff; white-space: nowrap; }
|
|
55
|
+
.badge.free { background: #6b7280; }
|
|
56
|
+
.teachbar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #111827; color: #fff; padding: 8px 14px; border-radius: 20px; font-size: 13px; pointer-events: auto; display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
|
|
57
|
+
.teachbar button { background: #374151; color: #fff; border: 0; border-radius: 12px; padding: 3px 10px; cursor: pointer; }
|
|
58
|
+
.pop { position: fixed; width: 300px; background: #fff; border: 1px solid #d1d5db; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 10px; pointer-events: auto; display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: #1f2937; }
|
|
59
|
+
.pop .lbl { font-size: 11px; color: #6b7280; }
|
|
60
|
+
.pop input[type=text], .pop select { width: 100%; }
|
|
61
|
+
`,yt={text:`metin`,textarea:`çok satır`,select:`seçim`,checkbox:`onay kutusu`,radio:`seçenek grubu`,date:`tarih`,contenteditable:`zengin metin`,other:`diğer`},bt=class{constructor(e){this.opts=e,this.visible=!1,this.view=`fill`,this.result=null,this.lastFill=null,this.toastMsg=``,this.toastKind=`ok`,this.toastTimer=0,this.pattern=``,this.importMode=`merge`,this.inspecting=!1,this.teaching=!1,this.teachPop=null,this.freeSel=new Map,this.pos=null,this.raf=0,this.onKey=e=>{if(_t(e,this.opts.hotkey)){e.preventDefault(),e.stopPropagation(),this.toggle();return}if(e.key===`Escape`){this.teachPop?(this.closeTeachPop(),e.preventDefault()):this.teaching&&(this.stopTeach(),e.preventDefault());return}if(!this.visible||this.view!==`fill`||this.teaching)return;let t=this.root.activeElement??document.activeElement;if(t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)))return;let n=this.currentDataset();if(n){if(/^Digit[1-9]$/.test(e.code)&&!e.ctrlKey&&!e.altKey&&!e.metaKey){let t=Number(e.code.slice(5))-1;n.rows[t]&&(e.preventDefault(),this.fillWith(n,t))}else e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),this.fillNext(n))}},this.startDrag=e=>{if(e.target.tagName===`BUTTON`)return;let t=this.box.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=e=>{this.pos={left:Math.max(0,Math.min(window.innerWidth-60,e.clientX-n)),top:Math.max(0,Math.min(window.innerHeight-40,e.clientY-r))},Object.assign(this.box.style,{left:`${this.pos.left}px`,top:`${this.pos.top}px`,right:`auto`})},a=()=>{window.removeEventListener(`mousemove`,i,!0),window.removeEventListener(`mouseup`,a,!0)};window.addEventListener(`mousemove`,i,!0),window.addEventListener(`mouseup`,a,!0),e.preventDefault()},this.hoverEl=null,this.onViewport=()=>{(this.inspecting||this.hoverEl||this.teaching)&&(cancelAnimationFrame(this.raf),this.raf=requestAnimationFrame(()=>this.drawLayer()))},this.onTeachMove=e=>{if(this.fromPanel(e)||this.teachPop)return;let t=ae(e.composedPath()[0]);t!==this.hoverEl&&this.hover(t)},this.onTeachPointer=e=>{if(this.fromPanel(e)||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),e.type!==`click`))return;let t=ae(e.composedPath()[0]);t?this.openTeachPop(t):this.teachPop&&this.closeTeachPop()}}mount(){if(!this.host){this.host=document.createElement(g),this.host.setAttribute(`data-otofill-host`,``),this.root=this.host.attachShadow({mode:`open`}),this.root.appendChild(X(`style`,{},vt)),this.layer=X(`div`,{class:`layer`}),this.box=X(`div`,{class:`panel`,style:{display:`none`}}),this.root.append(this.layer,this.box),document.documentElement.appendChild(this.host);for(let e of[`keydown`,`keyup`,`keypress`])this.host.addEventListener(e,e=>e.stopPropagation());window.addEventListener(`keydown`,this.onKey,!0),window.addEventListener(`scroll`,this.onViewport,!0),window.addEventListener(`resize`,this.onViewport),qe(()=>this.visible&&this.refresh())}}show(){this.mount(),this.visible=!0,this.pattern||=d(),this.box.style.display=`flex`,this.refresh()}hide(){this.visible=!1,this.box.style.display=`none`,this.stopTeach(),this.inspecting=!1,this.drawLayer()}toggle(){this.visible?this.hide():this.show()}isOpen(){return this.visible}refresh(){this.result=H(),this.render(),this.drawLayer()}toast(e,t=`ok`){this.toastMsg=e,this.toastKind=t,clearTimeout(this.toastTimer),this.toastTimer=window.setTimeout(()=>{this.toastMsg=``,this.visible&&this.render()},5e3),this.visible&&this.render()}currentDataset(){let e=L(),t=this.pageKeys(),n=nt(e.datasets,t).filter(e=>e.overlap>0),r=this.dsId??e.prefs.lastDatasetId;return n.find(e=>e.ds.id===r)?.ds??n[0]?.ds}pageKeys(){return[...new Set((this.result?.matches??[]).map(e=>e.def.key))]}async fillWith(e,t){let n=e.rows[t];if(!n)return;z(n=>{n.prefs.lastDatasetId=e.id,n.prefs.cursor[e.id]=(t+1)%e.rows.length});let r=await U(n,{onFilled:e=>this.flash(e)});this.lastFill=r;let i=r.notFound.length+r.failed.length;L().prefs.closeAfterFill&&i===0?this.hide():this.toast(`"${W(n)}": ${r.filled.length} alan dolduruldu`+(i?`, ${i} sorunlu`:``),i?`err`:`ok`)}fillNext(e){let t=L().prefs.cursor[e.id]??0;return this.fillWith(e,t<e.rows.length?t:0)}fillRandom(e){return this.fillWith(e,Math.floor(Math.random()*e.rows.length))}render(){let e=this.result,t=X(`div`,{class:`head`,onMousedown:this.startDrag},X(`b`,{},`Otofill`),X(`span`,{class:`sub`},`${e.matches.length}/${e.defs.length} alan · ${location.host}`),X(`button`,{title:`Yeniden tara`,onClick:()=>this.refresh()},`⟳`),X(`button`,{title:`Kapat (Ctrl+Q)`,onClick:()=>this.hide()},`×`)),n=(e,t)=>X(`button`,{class:this.view===e?`on`:``,onClick:()=>{this.view=e,this.render(),this.drawLayer()}},t),r=X(`div`,{class:`tabs`},n(`fill`,`Doldur`),n(`fields`,`Alanlar`),n(`data`,`Veri`),n(`io`,`Aktar`)),i=X(`div`,{class:`body`});this.toastMsg&&i.appendChild(X(`div`,{class:`toast ${this.toastKind}`},this.toastMsg)),this.view===`fill`?this.renderFill(i):this.view===`fields`?this.renderFields(i):this.view===`data`?this.renderData(i):this.renderIo(i);let a=this.box.querySelector(`.body`)?.scrollTop??0;this.box.replaceChildren(t,r,i),i.scrollTop=a,this.pos&&Object.assign(this.box.style,{left:`${this.pos.left}px`,top:`${this.pos.top}px`,right:`auto`})}renderFill(e){let t=this.result,n=L();if(t.defs.length===0){e.append(X(`div`,{class:`empty`},`Bu sayfa için tanımlı alan yok.`,X(`br`),`Önce alanları tanıtın ya da tanımları içe aktarın.`),X(`div`,{class:`row`},X(`button`,{class:`btn pri grow`,onClick:()=>{this.view=`fields`,this.startTeach()}},`Tıklayarak alan tanıt`),X(`button`,{class:`btn grow`,onClick:()=>{this.view=`io`,this.render()}},`İçe aktar`)));return}let r=nt(n.datasets,this.pageKeys()).filter(e=>e.overlap>0);if(r.length===0){e.append(X(`div`,{class:`empty`},`${t.matches.length} alan tanındı ama bu alanlara uyan veri seti yok.`,X(`br`),`Veri sekmesinden sayfadaki değerleri kaydedin ya da veri içe aktarın.`),X(`div`,{class:`row`},X(`button`,{class:`btn grow`,onClick:()=>{this.view=`data`,this.render()}},`Veri sekmesi`)));return}let i=this.currentDataset(),a=this.pageKeys(),o=n.prefs.cursor[i.id]??0;e.append(X(`div`,{class:`row`},X(`select`,{class:`grow`,onChange:e=>{this.dsId=e.target.value,this.render()}},r.map(e=>X(`option`,{value:e.ds.id,selected:e.ds.id===i.id||void 0},`${e.ds.name} (${e.overlap} alan · ${e.ds.rows.length} satır)`)))),i.rows.length===0?X(`div`,{class:`empty`},`Bu veri setinde satır yok.`):X(`div`,{class:`list`},i.rows.map((e,t)=>X(`div`,{class:`item click`+(t===o?` cur`:``),title:`Bu satırla doldur`,onClick:()=>this.fillWith(i,t)},X(`span`,{class:`num`},t<9?String(t+1):`·`),X(`span`,{class:`grow`},W(e,a)),t===o?X(`span`,{class:`muted`},`sıradaki`):null))),X(`div`,{class:`row`},X(`button`,{class:`btn pri grow`,disabled:!i.rows.length||void 0,onClick:()=>this.fillNext(i)},`Sıradaki satır (Enter)`),X(`button`,{class:`btn`,disabled:!i.rows.length||void 0,onClick:()=>this.fillRandom(i)},`Rastgele`)),X(`label`,{class:`opt muted`},X(`input`,{type:`checkbox`,checked:n.prefs.closeAfterFill,onChange:e=>z(t=>{t.prefs.closeAfterFill=e.target.checked})}),`Sorunsuz doldurunca paneli kapat · 1-9: satır seç`));let s=this.lastFill;if(s){let t=(e,t,n)=>n.length?X(`div`,{class:e},`${t}: `,X(`span`,{class:`key`},n.join(`, `))):null;e.append(X(`div`,{},t(`ok`,`Dolduruldu`,s.filled),t(`bad`,`Sayfada bulunamadı`,s.notFound),t(`bad`,`Yazılamadı`,s.failed),t(`muted`,`Satırda değeri yok`,s.noValue)))}t.missing.length&&e.append(X(`div`,{class:`muted`},`Tanımlı ama bulunamayan: ${t.missing.map(e=>e.key).join(`, `)}`))}renderFields(e){let t=this.result,n=ee(),r=d();e.append(X(`div`,{class:`row`},X(`button`,{class:`btn pri grow`,onClick:()=>this.startTeach()},`Tıklayarak tanıt`),X(`button`,{class:`btn`+(this.inspecting?` pri`:``),onClick:()=>{this.inspecting=!this.inspecting,this.render(),this.drawLayer()}},this.inspecting?`Göstermeyi kapat`:`Sayfada göster`)),X(`div`,{class:`muted`},`Yeni tanımların geçerli olacağı adres (* joker):`),X(`div`,{class:`row`},X(`input`,{type:`text`,class:`grow`,value:this.pattern,onChange:e=>{this.pattern=e.target.value.trim()}}),X(`button`,{class:`btn sm`,title:r,onClick:()=>{this.pattern=r,this.render()}},`Bu sayfa`),X(`button`,{class:`btn sm`,title:n,onClick:()=>{this.pattern=n,this.render()}},`Tüm site`)),X(`div`,{class:`sec`},`Bu sayfadaki tanımlar (${t.defs.length})`)),t.defs.length===0?e.append(X(`div`,{class:`muted`},`Henüz yok.`)):e.append(X(`div`,{class:`list`},t.defs.map(e=>{let n=t.matches.find(t=>t.def.id===e.id);return X(`div`,{class:`item`,onMouseenter:()=>n&&this.hover(n.fp.el),onMouseleave:()=>this.hover(null)},X(`span`,{class:n?`ok`:`bad`,title:n?`puan ${n.score}`:`sayfada bulunamadı`},n?`●`:`○`),X(`span`,{class:`grow`},X(`span`,{class:`key`},e.key),e.title?X(`span`,{class:`muted`},` · ${e.title}`):null),X(`span`,{class:`muted`},n?String(n.score):`—`),X(`button`,{class:`btn sm dng`,title:`Tanımı sil`,onClick:()=>{confirm(`"${e.key}" tanımı silinsin mi?`)&&B(e.id)}},`Sil`))})));let i=new Set(t.defs.map(e=>e.key)),a=new Set;for(let e of t.free)if(!this.freeSel.has(e)){let t=o(e.label||e.name||e.placeholder||e.id)||`alan_${(e.index??0)+1}`,n=2,r=t;for(;i.has(t)||a.has(t);)t=`${r}_${n++}`;a.add(t),this.freeSel.set(e,{on:!1,key:t})}e.append(X(`div`,{class:`sec`},`Tanımsız alanlar (${t.free.length})`)),t.free.length===0?e.append(X(`div`,{class:`muted`},`Sayfadaki tüm görünür alanlar tanımlı.`)):e.append(X(`div`,{class:`list`},t.free.map(e=>{let t=this.freeSel.get(e);return X(`div`,{class:`item`,onMouseenter:()=>this.hover(e.el),onMouseleave:()=>this.hover(null)},X(`input`,{type:`checkbox`,checked:t.on,onChange:e=>{t.on=e.target.checked}}),X(`div`,{class:`grow`,style:{display:`flex`,flexDirection:`column`,gap:`2px`,minWidth:`0`}},X(`input`,{type:`text`,value:t.key,onInput:e=>{t.key=e.target.value.trim(),t.on=!0,e.target.parentElement.previousSibling.checked=!0}}),X(`span`,{class:`muted`},`${e.label||e.placeholder||e.name||`(etiketsiz)`} · ${yt[e.kind]}`)))})),X(`div`,{class:`row`},X(`button`,{class:`btn`,onClick:()=>{let e=[...this.freeSel.values()].every(e=>e.on);t.free.forEach(t=>this.freeSel.get(t).on=!e),this.render()}},`Tümünü seç / bırak`),X(`button`,{class:`btn pri grow`,onClick:()=>this.saveFree()},`Seçilenleri kaydet`)))}saveFree(){let e=this.result.free.filter(e=>this.freeSel.get(e)?.on&&this.freeSel.get(e).key);if(!e.length)return this.toast(`Kaydedilecek alan seçilmedi.`,`err`);z(t=>{for(let n of e)t.fields.push(this.defFrom(n,this.freeSel.get(n).key))}),e.forEach(e=>this.freeSel.delete(e)),this.toast(`${e.length} alan tanımlandı.`)}defFrom(e,t,n,r,i){return{id:i??s(),key:t,title:n??e.label,pages:r??[this.pattern||d()],kind:e.kind,match:me(e),updatedAt:c()}}renderData(e){let t=this.result,n=L(),r=this.pageKeys(),i=n.datasets.find(e=>e.id===(this.openDsId??n.prefs.lastDatasetId))?.id??n.datasets[0]?.id??`__new`,a=``,o=``;e.append(X(`div`,{class:`sec`},`Sayfadaki değerleri satır olarak kaydet`),X(`div`,{class:`muted`},r.length?`Tanınan ${r.length} alanın o anki değerleri okunur. Formu elle doldurup buradan kaydedebilirsiniz.`:`Önce bu sayfadaki alanları tanıtın.`),X(`div`,{class:`row`},X(`select`,{class:`grow`,onChange:e=>{i=e.target.value,s.style.display=i===`__new`?``:`none`}},n.datasets.map(e=>X(`option`,{value:e.id,selected:e.id===i||void 0},e.name)),X(`option`,{value:`__new`,selected:i===`__new`||void 0},`+ Yeni veri seti`))));let s=X(`input`,{type:`text`,placeholder:`Yeni veri setinin adı`,style:{display:i===`__new`?``:`none`},onInput:e=>{a=e.target.value}});e.append(s,X(`div`,{class:`row`},X(`input`,{type:`text`,class:`grow`,placeholder:`Satır adı (ör. "Bireysel - İstanbul")`,onInput:e=>{o=e.target.value}}),X(`button`,{class:`btn pri`,disabled:!r.length||void 0,onClick:()=>{let e=tt(t),n=i;i===`__new`&&(n=Xe(a.trim()||`Veri ${new Date().toLocaleDateString(`tr-TR`)}`).id),$e(n,{...e,...o.trim()?{_label:o.trim()}:{}}),this.openDsId=n,this.toast(`${Object.keys(e).length} değer satır olarak kaydedildi.`)}},`Kaydet`)),X(`div`,{class:`sec`},`Veri setleri (${n.datasets.length})`)),n.datasets.length?e.append(X(`div`,{class:`list`},n.datasets.map(e=>{let t=this.openDsId===e.id,n=(r.length?r.filter(t=>V(e).includes(t)):V(e)).slice(0,5);return X(`div`,{},X(`div`,{class:`item click`,onClick:()=>{this.openDsId=t?void 0:e.id,this.render()}},X(`span`,{},t?`▾`:`▸`),X(`span`,{class:`grow`},e.name),X(`span`,{class:`muted`},`${e.rows.length} satır`),X(`button`,{class:`btn sm`,title:`CSV indir`,onClick:t=>{t.stopPropagation(),ft(e.id)}},`CSV`),X(`button`,{class:`btn sm dng`,onClick:t=>{t.stopPropagation(),confirm(`"${e.name}" veri seti silinsin mi?`)&&Qe(e.id)}},`Sil`)),t?X(`div`,{style:{padding:`0 8px 8px`,overflowX:`auto`}},X(`table`,{},X(`tr`,{},X(`th`,{},`Satır`),n.map(e=>X(`th`,{title:e},e)),X(`th`,{})),e.rows.map(t=>X(`tr`,{},X(`td`,{title:W(t)},W(t)),n.map(e=>X(`td`,{title:t[e]??``},t[e]??``)),X(`td`,{},X(`button`,{class:`btn sm dng`,title:`Satırı sil`,onClick:()=>et(e.id,t._id)},`×`))))),X(`div`,{class:`muted`,style:{marginTop:`4px`}},`Ayrıntılı düzenleme için yönetim sayfasını kullanın.`)):null)}))):e.append(X(`div`,{class:`muted`},`Henüz veri seti yok. Yukarıdan kaydedin ya da Aktar sekmesinden içe aktarın.`))}renderIo(e){let t=L(),n=t.datasets[0]?.id,r=``,i=async e=>{try{this.toast(await e())}catch(e){this.toast(e instanceof K?e.message:`İçe aktarılamadı: `+e.message,`err`)}},a=X(`input`,{type:`file`,accept:`.json,.csv,application/json,text/csv`,multiple:!0,style:{display:`none`},onChange:e=>{let t=Array.from(e.target.files??[]);i(async()=>{let e=[];for(let n of t)e.push(`${n.name}: ${Y(await mt(n,this.importMode))}`);return e.join(` · `)})}}),o=X(`div`,{class:`drop`,onClick:()=>a.click(),onDragover:e=>{e.preventDefault(),o.classList.add(`over`)},onDragleave:()=>o.classList.remove(`over`),onDrop:e=>{e.preventDefault(),o.classList.remove(`over`);let t=Array.from(e.dataTransfer?.files??[]);i(async()=>{let e=[];for(let n of t)e.push(`${n.name}: ${Y(await mt(n,this.importMode))}`);return e.join(` · `)})}},`JSON / CSV dosyasını buraya bırakın ya da tıklayıp seçin`),s=(e,t,n)=>X(`label`,{class:`opt`},X(`input`,{type:`radio`,name:`mode`,checked:this.importMode===e,onChange:()=>{this.importMode=e}}),X(`span`,{},X(`b`,{},t),X(`span`,{class:`muted`},` · ${n}`)));e.append(X(`div`,{class:`sec`},`Dışa aktar`),X(`div`,{class:`row`},X(`button`,{class:`btn pri`,onClick:()=>J({fields:!0,datasets:!0})},`Hepsi (JSON)`),X(`button`,{class:`btn`,onClick:()=>J({fields:!0},`otofill-alanlar-${location.hostname}.json`)},`Alan tanımları`),X(`button`,{class:`btn`,onClick:()=>J({datasets:!0},`otofill-veri.json`)},`Veri setleri`)),t.datasets.length?X(`div`,{class:`row`},X(`select`,{class:`grow`,onChange:e=>{n=e.target.value}},t.datasets.map(e=>X(`option`,{value:e.id},e.name))),X(`button`,{class:`btn`,onClick:()=>n&&ft(n)},`CSV (Excel)`)):``,X(`div`,{class:`sec`},`İçe aktar`),s(`merge`,`Birleştir`,`aynı kayıtları günceller, yenileri ekler`),s(`replace`,`Üzerine yaz`,`dosyadaki bölümü tamamen değiştirir`),s(`copy`,`Kopya olarak ekle`,`hepsini yeni kayıt olarak ekler`),o,a,X(`textarea`,{placeholder:`ya da JSON / CSV metnini buraya yapıştırın`,onInput:e=>{r=e.target.value}}),X(`div`,{class:`row`},X(`button`,{class:`btn grow`,onClick:()=>i(()=>Y(pt(r,this.importMode,r.trimStart().startsWith(`{`)?`yapistirilan.json`:`Yapıştırılan ${new Date().toLocaleString(`tr-TR`)}.csv`)))},`Metinden içe aktar`)),X(`div`,{class:`sec`},`Depolama`),X(`div`,{class:`muted`},`Veriler yalnızca bu tarayıcıda, ${location.origin} için saklanır; hiçbir yere gönderilmez. ${t.fields.length} alan tanımı, ${t.datasets.length} veri seti. Sürüm 0.1.0.`),X(`div`,{class:`row`},X(`button`,{class:`btn dng`,onClick:()=>{confirm(`${location.origin} için kayıtlı tüm Otofill alanları ve verileri silinsin mi? Bu işlem geri alınamaz; önce dışa aktarmanız önerilir.`)&&(Je(),this.toast(`Tüm veriler silindi.`))}},`Bu sitedeki tüm verileri sil`)))}targetRectEl(e){return e.getClientRects().length&&e.getBoundingClientRect().width>2?e:e.closest(`label`)??e.parentElement??e}boxFor(e,t){let n=this.targetRectEl(e).getBoundingClientRect();return X(`div`,{class:`hl ${t}`,style:{left:`${n.left-3}px`,top:`${n.top-3}px`,width:`${n.width+6}px`,height:`${n.height+6}px`}})}hover(e){this.hoverEl=e,this.drawLayer()}flash(e){let t=this.boxFor(e,`green`);this.layer.appendChild(t),setTimeout(()=>t.style.opacity=`0`,700),setTimeout(()=>t.remove(),1200)}drawLayer(){let e=[...this.layer.querySelectorAll(`.pop, .teachbar`)];if(this.layer.replaceChildren(...e),!this.visible&&!this.teaching)return;let t=this.result;if(t&&(this.inspecting||this.teaching)){for(let e of t.matches){let t=this.targetRectEl(e.fp.el).getBoundingClientRect();t.bottom<0||t.top>window.innerHeight||this.layer.appendChild(X(`div`,{class:`badge`,style:{left:`${t.left}px`,top:`${t.top}px`}},`${e.def.key} · ${e.score}`))}if(this.inspecting)for(let e of t.free){let t=this.targetRectEl(e.el).getBoundingClientRect();t.bottom<0||t.top>window.innerHeight||this.layer.appendChild(X(`div`,{class:`badge free`,style:{left:`${t.left}px`,top:`${t.top}px`}},`? tanımsız`))}}this.hoverEl?.isConnected&&this.layer.appendChild(this.boxFor(this.hoverEl,``))}startTeach(){if(this.mount(),this.teaching)return;this.teaching=!0,this.pattern||=d(),this.visible||this.show(),this.result=H(),this.render();let e=X(`div`,{class:`teachbar`},X(`span`,{},`Tanıtma modu: bir alana tıklayın`),X(`button`,{onClick:()=>this.stopTeach()},`Bitir (Esc)`));this.layer.appendChild(e);for(let e of[`pointerdown`,`mousedown`,`mouseup`,`click`])document.addEventListener(e,this.onTeachPointer,!0);document.addEventListener(`mousemove`,this.onTeachMove,!0),this.drawLayer()}stopTeach(){if(this.teaching){this.teaching=!1,this.closeTeachPop(),this.layer.querySelector(`.teachbar`)?.remove();for(let e of[`pointerdown`,`mousedown`,`mouseup`,`click`])document.removeEventListener(e,this.onTeachPointer,!0);document.removeEventListener(`mousemove`,this.onTeachMove,!0),this.hoverEl=null,this.visible?this.refresh():this.drawLayer()}}fromPanel(e){return e.composedPath().includes(this.host)}closeTeachPop(){this.teachPop?.remove(),this.teachPop=null}openTeachPop(e){this.closeTeachPop();let t=v(e)===`radio`?C(e)[0]:e,n=E(document).find(e=>e.el===t);if(!n){this.toast(`Bu alan görünür değil ya da devre dışı.`,`err`);return}let r=L(),i=H();this.result=i;let a=i.matches.find(e=>e.fp.el===t)?.def,s=[...new Set([...r.fields.map(e=>e.key),...r.datasets.flatMap(V)])].sort(),c=`otofill-keys`,l=d(),u=ee(),f=a?.pages[0]??(this.pattern||l),p=X(`input`,{type:`text`,list:c,value:a?.key??(o(n.label||n.name||n.placeholder||n.id)||``),placeholder:`ör. musteri.tckn`}),m=X(`input`,{type:`text`,value:a?.title??n.label??``,placeholder:`Açıklama (isteğe bağlı)`}),h=X(`select`,{},X(`option`,{value:l,selected:f===l||void 0},`Bu sayfa`),X(`option`,{value:u,selected:f===u||void 0},`Tüm site`),f!==l&&f!==u?X(`option`,{value:f,selected:!0},f):null),g=()=>{let e=p.value.trim();if(!e){p.focus();return}let r=this.defFrom(n,e,m.value.trim()||void 0,[h.value],a?.id);z(e=>{let t=e.fields.findIndex(e=>e.id===r.id);t>=0?e.fields[t]=r:e.fields.push(r)}),this.closeTeachPop(),this.flash(t),this.toast(`"${e}" ${a?`güncellendi`:`tanımlandı`}.`)},_=this.targetRectEl(t).getBoundingClientRect(),te=_.bottom+8+230>window.innerHeight?Math.max(8,_.top-238):_.bottom+8,ne=Math.min(Math.max(8,_.left),window.innerWidth-310);this.teachPop=X(`div`,{class:`pop`,style:{left:`${ne}px`,top:`${te}px`},onKeydown:e=>{e.key===`Enter`&&g()}},X(`div`,{},X(`b`,{},a?`Alanı düzenle`:`Alan tanıt`),X(`span`,{class:`muted`},` · ${yt[n.kind]}${n.label?` · "${n.label}"`:``}`)),X(`span`,{class:`lbl`},`Anahtar (veri setindeki sütun adı)`),p,X(`datalist`,{id:c},s.map(e=>X(`option`,{value:e}))),X(`span`,{class:`lbl`},`Açıklama`),m,X(`span`,{class:`lbl`},`Geçerli olduğu yer`),h,X(`div`,{class:`row`},a?X(`button`,{class:`btn dng`,onClick:()=>{B(a.id),this.closeTeachPop(),this.toast(`"${a.key}" silindi.`)}},`Sil`):null,X(`span`,{class:`grow`}),X(`button`,{class:`btn`,onClick:()=>this.closeTeachPop()},`İptal`),X(`button`,{class:`btn pri`,onClick:g},`Kaydet`))),this.layer.appendChild(this.teachPop),p.focus(),p.select()}},xt=n({BUNDLE_FORMAT:()=>G,BUNDLE_VERSION:()=>1,THRESHOLD:()=>30,WEIGHTS:()=>Le,analyze:()=>H,close:()=>wt,fill:()=>Dt,fillElement:()=>Fe,fillRow:()=>U,fingerprint:()=>w,init:()=>Q,io:()=>it,labelOf:()=>le,matchFields:()=>Be,open:()=>Ct,readElement:()=>Ie,readRow:()=>tt,registerDriver:()=>Ne,scanPage:()=>E,score:()=>ze,setNativeValue:()=>k,store:()=>Ve,teach:()=>Et,toggle:()=>Tt,version:()=>St}),St=`0.1.0`,Z=null;function Q(e={}){if(Z||typeof document>`u`)return;Z=new bt({hotkey:gt(e.hotkey??`ctrl+q`)});let t=()=>Z.mount();document.body?t():document.addEventListener(`DOMContentLoaded`,t,{once:!0})}function Ct(){Q(),Z.show()}function wt(){Z?.hide()}function Tt(){Q(),Z.toggle()}function Et(){Q(),Z.startTeach()}async function Dt(e,t=0){let n=L().datasets.find(t=>t.id===e||t.name===e);if(!n)throw Error(`Veri seti bulunamadı: ${e}`);let r=typeof t==`number`?n.rows[t]:n.rows.find(e=>e._label===t||e._id===t);if(!r)throw Error(`Satır bulunamadı: ${t}`);return U(r)}var $=globalThis,Ot=document.currentScript;return $.__optonaOtofill?$.__optonaOtofill.open():($.__optonaOtofill=xt,Ot?.dataset.auto!==`false`&&Q({hotkey:Ot?.dataset.hotkey}),Ot?.dataset.open===`true`&&Ct()),e.BUNDLE_FORMAT=G,e.BUNDLE_VERSION=rt,e.THRESHOLD=Re,e.WEIGHTS=Le,e.analyze=H,e.close=wt,e.fill=Dt,e.fillElement=Fe,e.fillRow=U,e.fingerprint=w,e.init=Q,Object.defineProperty(e,"io",{enumerable:!0,get:function(){return it}}),e.labelOf=le,e.matchFields=Be,e.open=Ct,e.readElement=Ie,e.readRow=tt,e.registerDriver=Ne,e.scanPage=E,e.score=ze,e.setNativeValue=k,Object.defineProperty(e,"store",{enumerable:!0,get:function(){return Ve}}),e.teach=Et,e.toggle=Tt,e.version=St,e})({});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Driver } from './types';
|
|
2
|
+
import { setNativeValue } from './fill-utils';
|
|
3
|
+
export { setNativeValue };
|
|
4
|
+
export declare const truthy: (v: string) => boolean;
|
|
5
|
+
/** Özel sürücü kaydeder; yerleşik sürücülerden önce denenir. */
|
|
6
|
+
export declare function registerDriver(d: Driver): void;
|
|
7
|
+
export declare function driverFor(el: Element): Driver | undefined;
|
|
8
|
+
export declare function fillElement(el: Element, value: string): Promise<boolean>;
|
|
9
|
+
export declare function readElement(el: Element): string | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DataRow, DataSet, FieldDef } from './types';
|
|
2
|
+
import type { MatchResult } from './matcher';
|
|
3
|
+
/** Bulunulan sayfayı tarar ve kayıtlı tanımlarla eşler. */
|
|
4
|
+
export declare function analyze(defs?: FieldDef[], url?: string): MatchResult;
|
|
5
|
+
export interface FillResult {
|
|
6
|
+
filled: string[];
|
|
7
|
+
/** Tanımlı ama sayfada bulunamayan anahtarlar. */
|
|
8
|
+
notFound: string[];
|
|
9
|
+
/** Bulundu ama değer yazılamadı (ör. select'te seçenek yok). */
|
|
10
|
+
failed: string[];
|
|
11
|
+
/** Sayfada var ama satırda değeri olmayanlar. */
|
|
12
|
+
noValue: string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Satırı sayfaya yazar. Bağımlı alanlar (il → ilçe gibi) sonradan yüklenebildiği için
|
|
16
|
+
* yazılamayan ya da bulunamayan alanlar kısa aralıklarla yeniden denenir.
|
|
17
|
+
*/
|
|
18
|
+
export declare function fillRow(row: DataRow, opts?: {
|
|
19
|
+
retries?: number;
|
|
20
|
+
delay?: number;
|
|
21
|
+
onFilled?: (el: Element) => void;
|
|
22
|
+
}): Promise<FillResult>;
|
|
23
|
+
/** Sayfadaki tanımlı alanların o anki değerlerini satır olarak okur. */
|
|
24
|
+
export declare function readRow(result?: MatchResult): Omit<DataRow, '_id'>;
|
|
25
|
+
/** Sayfadaki anahtarlarla en çok örtüşen veri setleri önce. */
|
|
26
|
+
export declare function rankDatasets(datasets: DataSet[], pageKeys: string[]): {
|
|
27
|
+
ds: DataSet;
|
|
28
|
+
overlap: number;
|
|
29
|
+
}[];
|
|
30
|
+
export declare function rowTitle(row: DataRow, keys?: string[]): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ValueEl = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
|
|
2
|
+
export declare function fire(el: Element, type: string): void;
|
|
3
|
+
export declare function pressKey(el: Element, key: string): void;
|
|
4
|
+
/**
|
|
5
|
+
* Vue v-model (ve React) değeri `input` olayıyla okur; `el.value = x` tek başına yetmez.
|
|
6
|
+
* Değeri prototipteki native setter ile yazıp olayları tetikliyoruz.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setNativeValue(el: ValueEl, value: string): void;
|
|
9
|
+
export declare function isShown(el: Element | null | undefined): el is Element;
|
|
10
|
+
/** Koşul sağlanana kadar bekler; zaman aşımında null döner. */
|
|
11
|
+
export declare function waitFor<T>(fn: () => T | null | undefined | false, timeout?: number, step?: number): Promise<T | null>;
|
|
12
|
+
/** Seçenekler arasından metne göre en iyi eşleşmeyi bulur: tam, baş, benzer. */
|
|
13
|
+
export declare function pickByText<T extends Element>(items: T[], value: string, text?: (e: T) => string): T | undefined;
|
|
14
|
+
/** Çoklu değer ayırıcı: "Spor | Müzik" */
|
|
15
|
+
export declare const splitMulti: (v: string) => string[];
|
|
16
|
+
/** Bir tarihi farklı yazım biçimlerinde dener: girilen, ISO, 31.12.1990, 31/12/1990, 12/31/1990, 1990/12/31. */
|
|
17
|
+
export declare function dateCandidates(value: string): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Bileşen yazılan değeri aynen kabul etti mi? Gösterilen değerin sayıları yazılanla aynı sırada başlamalı
|
|
20
|
+
* ("09:15" → "09:15:00" olur). Sıra farklıysa bileşen başka biçimle okuyup gün/ayı karıştırmış olabilir.
|
|
21
|
+
*/
|
|
22
|
+
export declare function sameNumbers(shown: string, typed: string): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { analyze, fillRow, readRow } from './engine';
|
|
2
|
+
export declare const version: string;
|
|
3
|
+
export interface InitOptions {
|
|
4
|
+
/** Paneli açan kısayol. Varsayılan "ctrl+q". */
|
|
5
|
+
hotkey?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Kısayolu dinlemeye başlar. Birden fazla çağrılırsa ilk çağrı geçerlidir. */
|
|
8
|
+
export declare function init(opts?: InitOptions): void;
|
|
9
|
+
export declare function open(): void;
|
|
10
|
+
export declare function close(): void;
|
|
11
|
+
export declare function toggle(): void;
|
|
12
|
+
/** Tıklayarak alan tanıtma modunu başlatır. */
|
|
13
|
+
export declare function teach(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Programatik doldurma (testlerde, konsolda). Veri seti adı ya da id'si, satır sırası ya da _label verilir.
|
|
16
|
+
* Örn: Otofill.fill('Bireysel müşteriler', 0)
|
|
17
|
+
*/
|
|
18
|
+
export declare function fill(dataset: string, row?: number | string): Promise<import("./engine").FillResult>;
|
|
19
|
+
export { analyze, fillRow, readRow };
|
|
20
|
+
export { registerDriver, fillElement, readElement, setNativeValue } from './drivers';
|
|
21
|
+
export { scanPage, fingerprint, labelOf } from './scanner';
|
|
22
|
+
export { matchFields, score, THRESHOLD, WEIGHTS } from './matcher';
|
|
23
|
+
export * as store from './store';
|
|
24
|
+
export type { State, Prefs } from './store';
|
|
25
|
+
export * as io from './io';
|
|
26
|
+
export * from './types';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Bundle, DataSet, ImportMode } from './types';
|
|
2
|
+
import type { State } from './store';
|
|
3
|
+
export interface ExportOptions {
|
|
4
|
+
fields?: boolean;
|
|
5
|
+
/** true: hepsi, dizi: yalnızca bu id'ler, false: hiçbiri. */
|
|
6
|
+
datasets?: boolean | string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function makeBundle(state?: State, opts?: ExportOptions): Bundle;
|
|
9
|
+
export declare class ImportError extends Error {
|
|
10
|
+
}
|
|
11
|
+
/** Dosyayı doğrular, eksikleri tamamlar ve eski sürümleri günceller. Hatalıysa ImportError fırlatır. */
|
|
12
|
+
export declare function validateBundle(raw: unknown): Bundle;
|
|
13
|
+
export interface ImportSummary {
|
|
14
|
+
fieldsAdded: number;
|
|
15
|
+
fieldsUpdated: number;
|
|
16
|
+
datasetsAdded: number;
|
|
17
|
+
datasetsUpdated: number;
|
|
18
|
+
rows: number;
|
|
19
|
+
}
|
|
20
|
+
/** Paketi duruma uygular (kaydetmez). */
|
|
21
|
+
export declare function applyBundle(state: State, b: Bundle, mode: ImportMode): ImportSummary;
|
|
22
|
+
/** Excel (Türkçe) ile uyumlu olsun diye ; ayırıcı ve UTF-8 BOM kullanılır. */
|
|
23
|
+
export declare function datasetToCsv(ds: DataSet, keys?: string[]): string;
|
|
24
|
+
export declare function parseCsv(text: string): string[][];
|
|
25
|
+
/** CSV'den veri seti üretir. Başlık satırı anahtarlardır; "_label" (ya da "Etiket") sütunu satır adıdır. */
|
|
26
|
+
export declare function csvToDataset(text: string, name: string): DataSet;
|
|
27
|
+
export declare function download(filename: string, text: string, mime?: string): void;
|
|
28
|
+
export declare function exportJson(opts?: ExportOptions, filename?: string): void;
|
|
29
|
+
export declare function exportCsv(datasetId: string): void;
|
|
30
|
+
/** JSON ya da CSV metnini içe aktarır ve kaydeder. */
|
|
31
|
+
export declare function importText(text: string, mode: ImportMode, filename?: string): ImportSummary;
|
|
32
|
+
export declare function importFile(file: File, mode: ImportMode): Promise<ImportSummary>;
|
|
33
|
+
export declare function summaryText(s: ImportSummary): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FieldDef, Fingerprint } from './types';
|
|
2
|
+
/** Sinyal ağırlıkları. data-otofill eşleşmesi kesindir. */
|
|
3
|
+
export declare const WEIGHTS: {
|
|
4
|
+
otofill: number;
|
|
5
|
+
id: number;
|
|
6
|
+
name: number;
|
|
7
|
+
labelExact: number;
|
|
8
|
+
css: number;
|
|
9
|
+
labelFuzzy: number;
|
|
10
|
+
placeholder: number;
|
|
11
|
+
ariaLabel: number;
|
|
12
|
+
type: number;
|
|
13
|
+
index: number;
|
|
14
|
+
mismatch: number;
|
|
15
|
+
wrongTag: number;
|
|
16
|
+
wrongKind: number;
|
|
17
|
+
};
|
|
18
|
+
/** Bu puanın altındaki eşleşmeler kullanılmaz: yanlış alanı doldurmaktansa boş bırakmak iyidir. */
|
|
19
|
+
export declare const THRESHOLD = 30;
|
|
20
|
+
export declare function score(def: Pick<FieldDef, 'match' | 'kind'>, fp: Fingerprint): number;
|
|
21
|
+
export interface FieldMatch {
|
|
22
|
+
def: FieldDef;
|
|
23
|
+
fp: Fingerprint;
|
|
24
|
+
score: number;
|
|
25
|
+
}
|
|
26
|
+
export interface MatchResult {
|
|
27
|
+
/** Bu sayfaya uygulanan tanımlar. */
|
|
28
|
+
defs: FieldDef[];
|
|
29
|
+
matches: FieldMatch[];
|
|
30
|
+
/** Tanımlı ama sayfada bulunamayanlar. */
|
|
31
|
+
missing: FieldDef[];
|
|
32
|
+
/** Sayfada olup hiçbir tanıma uymayan alanlar. */
|
|
33
|
+
free: Fingerprint[];
|
|
34
|
+
}
|
|
35
|
+
/** Tanımları sayfadaki alanlarla eşler; en yüksek puandan başlayarak her alan en fazla bir kez kullanılır. */
|
|
36
|
+
export declare function matchFields(allDefs: FieldDef[], fps: Fingerprint[], url?: string): MatchResult;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Child = Node | string | number | null | undefined | false | Child[];
|
|
2
|
+
type Props = Record<string, unknown>;
|
|
3
|
+
/** Küçük DOM yardımcısı: h('button', { class: 'x', onClick }, 'Metin') */
|
|
4
|
+
export declare function h<K extends keyof HTMLElementTagNameMap>(tag: K, props?: Props, ...children: Child[]): HTMLElementTagNameMap[K];
|
|
5
|
+
export declare function append(el: Node, children: Child[]): void;
|
|
6
|
+
export interface Hotkey {
|
|
7
|
+
ctrl: boolean;
|
|
8
|
+
shift: boolean;
|
|
9
|
+
alt: boolean;
|
|
10
|
+
meta: boolean;
|
|
11
|
+
code: string;
|
|
12
|
+
}
|
|
13
|
+
/** "ctrl+q", "ctrl+shift+f" → Hotkey */
|
|
14
|
+
export declare function parseHotkey(s: string): Hotkey;
|
|
15
|
+
export declare function hotkeyMatches(e: KeyboardEvent, k: Hotkey): boolean;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Hotkey } from './dom';
|
|
2
|
+
export interface PanelOptions {
|
|
3
|
+
hotkey: Hotkey;
|
|
4
|
+
}
|
|
5
|
+
export declare class Panel {
|
|
6
|
+
private opts;
|
|
7
|
+
private host;
|
|
8
|
+
private root;
|
|
9
|
+
private box;
|
|
10
|
+
private layer;
|
|
11
|
+
private visible;
|
|
12
|
+
private view;
|
|
13
|
+
private result;
|
|
14
|
+
private lastFill;
|
|
15
|
+
private dsId?;
|
|
16
|
+
private openDsId?;
|
|
17
|
+
private toastMsg;
|
|
18
|
+
private toastKind;
|
|
19
|
+
private toastTimer;
|
|
20
|
+
private pattern;
|
|
21
|
+
private importMode;
|
|
22
|
+
private inspecting;
|
|
23
|
+
private teaching;
|
|
24
|
+
private teachPop;
|
|
25
|
+
private freeSel;
|
|
26
|
+
private pos;
|
|
27
|
+
private raf;
|
|
28
|
+
constructor(opts: PanelOptions);
|
|
29
|
+
mount(): void;
|
|
30
|
+
show(): void;
|
|
31
|
+
hide(): void;
|
|
32
|
+
toggle(): void;
|
|
33
|
+
isOpen(): boolean;
|
|
34
|
+
refresh(): void;
|
|
35
|
+
private toast;
|
|
36
|
+
private onKey;
|
|
37
|
+
private currentDataset;
|
|
38
|
+
private pageKeys;
|
|
39
|
+
private fillWith;
|
|
40
|
+
private fillNext;
|
|
41
|
+
private fillRandom;
|
|
42
|
+
private render;
|
|
43
|
+
private renderFill;
|
|
44
|
+
private renderFields;
|
|
45
|
+
private saveFree;
|
|
46
|
+
private defFrom;
|
|
47
|
+
private renderData;
|
|
48
|
+
private renderIo;
|
|
49
|
+
private startDrag;
|
|
50
|
+
private hoverEl;
|
|
51
|
+
private targetRectEl;
|
|
52
|
+
private boxFor;
|
|
53
|
+
private hover;
|
|
54
|
+
private flash;
|
|
55
|
+
private onViewport;
|
|
56
|
+
private drawLayer;
|
|
57
|
+
startTeach(): void;
|
|
58
|
+
stopTeach(): void;
|
|
59
|
+
private fromPanel;
|
|
60
|
+
private onTeachMove;
|
|
61
|
+
private onTeachPointer;
|
|
62
|
+
private closeTeachPop;
|
|
63
|
+
private openTeachPop;
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CSS = "\n:host { all: initial; }\n* { box-sizing: border-box; font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; }\n.panel {\n position: fixed; top: 16px; right: 16px; width: 380px; max-height: calc(100vh - 32px);\n display: flex; flex-direction: column; background: #fff; color: #1f2937; font-size: 13px; line-height: 1.4;\n border: 1px solid #d1d5db; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.22); z-index: 2147483646; overflow: hidden;\n}\n.head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #111827; color: #fff; cursor: move; user-select: none; }\n.head b { font-size: 13px; letter-spacing: .2px; }\n.head .sub { color: #9ca3af; font-size: 11px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.head button { background: transparent; border: 0; color: #d1d5db; font-size: 16px; cursor: pointer; padding: 0 4px; }\n.tabs { display: flex; border-bottom: 1px solid #e5e7eb; background: #f9fafb; }\n.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 4px; cursor: pointer; font-size: 12px; color: #4b5563; border-bottom: 2px solid transparent; }\n.tabs button.on { color: #111827; border-bottom-color: #2563eb; font-weight: 600; }\n.body { overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }\n.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }\n.muted { color: #6b7280; font-size: 12px; }\n.sec { font-weight: 600; font-size: 12px; color: #374151; margin-top: 2px; }\nbutton.btn { border: 1px solid #d1d5db; background: #fff; border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: 12px; color: #1f2937; }\nbutton.btn:hover { background: #f3f4f6; }\nbutton.pri { background: #2563eb; border-color: #2563eb; color: #fff; }\nbutton.pri:hover { background: #1d4ed8; }\nbutton.dng { color: #b91c1c; border-color: #fca5a5; }\nbutton.sm { padding: 2px 6px; font-size: 11px; }\nbutton:disabled { opacity: .5; cursor: default; }\ninput[type=text], select, textarea { border: 1px solid #d1d5db; border-radius: 6px; padding: 5px 7px; font-size: 12px; color: #111827; background: #fff; min-width: 0; }\ninput[type=text]:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: #2563eb; }\ntextarea { width: 100%; min-height: 70px; font-family: ui-monospace, Consolas, monospace; font-size: 11px; }\n.grow { flex: 1; }\n.list { display: flex; flex-direction: column; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }\n.item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-top: 1px solid #f3f4f6; }\n.item:first-child { border-top: 0; }\n.item.click { cursor: pointer; }\n.item.click:hover, .item.cur { background: #eff6ff; }\n.num { min-width: 18px; height: 18px; border-radius: 4px; background: #e5e7eb; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; color: #374151; }\n.key { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #1e40af; }\n.ok { color: #15803d; } .bad { color: #b91c1c; } .warn { color: #b45309; }\n.toast { padding: 7px 9px; border-radius: 6px; font-size: 12px; }\n.toast.ok { background: #dcfce7; color: #14532d; } .toast.err { background: #fee2e2; color: #7f1d1d; }\n.drop { border: 2px dashed #cbd5e1; border-radius: 8px; padding: 14px; text-align: center; color: #64748b; cursor: pointer; }\n.drop.over { border-color: #2563eb; background: #eff6ff; }\n.empty { padding: 14px; text-align: center; color: #6b7280; }\ntable { border-collapse: collapse; width: 100%; font-size: 11px; }\nth, td { border-bottom: 1px solid #f3f4f6; padding: 3px 4px; text-align: left; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\nth { color: #6b7280; font-weight: 600; }\nlabel.opt { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }\n.layer { position: fixed; inset: 0; pointer-events: none; z-index: 2147483645; }\n.hl { position: fixed; border: 2px solid #2563eb; background: rgba(37,99,235,.08); border-radius: 4px; transition: opacity .4s; }\n.hl.green { border-color: #16a34a; background: rgba(22,163,74,.12); }\n.badge { position: fixed; transform: translateY(-100%); font: 600 10px/1.6 ui-monospace, Consolas, monospace; padding: 0 5px; border-radius: 4px 4px 4px 0; background: #16a34a; color: #fff; white-space: nowrap; }\n.badge.free { background: #6b7280; }\n.teachbar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #111827; color: #fff; padding: 8px 14px; border-radius: 20px; font-size: 13px; pointer-events: auto; display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.3); }\n.teachbar button { background: #374151; color: #fff; border: 0; border-radius: 12px; padding: 3px 10px; cursor: pointer; }\n.pop { position: fixed; width: 300px; background: #fff; border: 1px solid #d1d5db; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 10px; pointer-events: auto; display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: #1f2937; }\n.pop .lbl { font-size: 11px; color: #6b7280; }\n.pop input[type=text], .pop select { width: 100%; }\n";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FieldKind, Fingerprint } from './types';
|
|
2
|
+
export declare const HOST_TAG = "optona-otofill";
|
|
3
|
+
export declare function kindOf(el: Element): FieldKind;
|
|
4
|
+
export declare function isFieldElement(el: Element | null): boolean;
|
|
5
|
+
/** Tıklanan düğümden ilgili alanı bulur (label'a tıklandıysa bağlı input). */
|
|
6
|
+
export declare function fieldFromTarget(target: Element | null): Element | null;
|
|
7
|
+
export declare function isVisible(el: Element): boolean;
|
|
8
|
+
/** Alanın etiketini bulur: aria-labelledby, label[for], saran label, aria-label, form-item etiketi, yakın metin. */
|
|
9
|
+
export declare function labelOf(el: Element): string;
|
|
10
|
+
/** Aynı gruptaki radio'lar (aynı name, aynı form). */
|
|
11
|
+
export declare function radioGroup(el: Element): HTMLInputElement[];
|
|
12
|
+
/** Tek bir radio/checkbox seçeneğinin kendi etiketi ("Kadın", "Erkek"). */
|
|
13
|
+
export declare function optionLabel(el: Element): string;
|
|
14
|
+
export declare function fingerprint(el: Element, index?: number): Fingerprint;
|
|
15
|
+
/** Sayfadaki görünür alanları tarar. Radio grupları tek alan sayılır (ilk seçenek temsil eder). */
|
|
16
|
+
export declare function scanPage(root?: Document): Fingerprint[];
|
|
17
|
+
/** Parmak izinden saklanacak ipuçlarını üretir (el hariç). */
|
|
18
|
+
export declare function hintsOf(fp: Fingerprint): {
|
|
19
|
+
otofill?: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
label?: string;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
ariaLabel?: string;
|
|
25
|
+
tag?: string;
|
|
26
|
+
type?: string;
|
|
27
|
+
css?: string;
|
|
28
|
+
formKey?: string;
|
|
29
|
+
index?: number;
|
|
30
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { DataRow, DataSet, FieldDef } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Veriler bulunulan sitenin (origin) localStorage'ında durur; kütüphane hiçbir yere istek atmaz.
|
|
4
|
+
* Kod güncellense de veri silinmez. Biçim değişirse migrate() eski veriyi yükseltir.
|
|
5
|
+
*/
|
|
6
|
+
export declare const STORAGE_KEY = "optona-otofill";
|
|
7
|
+
export declare const STATE_VERSION = 1;
|
|
8
|
+
export interface Prefs {
|
|
9
|
+
lastDatasetId?: string;
|
|
10
|
+
/** Veri seti başına "sıradaki satır" imleci. */
|
|
11
|
+
cursor: Record<string, number>;
|
|
12
|
+
closeAfterFill: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface State {
|
|
15
|
+
v: number;
|
|
16
|
+
fields: FieldDef[];
|
|
17
|
+
datasets: DataSet[];
|
|
18
|
+
prefs: Prefs;
|
|
19
|
+
}
|
|
20
|
+
type Listener = (s: State) => void;
|
|
21
|
+
/** Eski sürümlerin verisini güncel biçime taşır. Yeni biçim eklendiğinde buraya adım eklenir. */
|
|
22
|
+
export declare function migrate(raw: unknown): State;
|
|
23
|
+
export declare function load(): State;
|
|
24
|
+
export declare function save(s: State): void;
|
|
25
|
+
/** Durumu okuyup değiştirir ve kaydeder. */
|
|
26
|
+
export declare function update(fn: (s: State) => void): State;
|
|
27
|
+
export declare function subscribe(fn: Listener): () => void;
|
|
28
|
+
export declare function clearAll(): void;
|
|
29
|
+
export declare function upsertField(def: Omit<FieldDef, 'id'> & {
|
|
30
|
+
id?: string;
|
|
31
|
+
}): FieldDef;
|
|
32
|
+
export declare function removeField(id: string): void;
|
|
33
|
+
export declare function createDataset(name: string, rows?: DataRow[]): DataSet;
|
|
34
|
+
export declare function upsertDataset(ds: DataSet): void;
|
|
35
|
+
export declare function removeDataset(id: string): void;
|
|
36
|
+
export declare function addRow(datasetId: string, row: Omit<DataRow, '_id'> & {
|
|
37
|
+
_id?: string;
|
|
38
|
+
}): DataRow;
|
|
39
|
+
export declare function removeRow(datasetId: string, rowId: string): void;
|
|
40
|
+
/** Veri setindeki tüm anahtarlar (sütunlar), _id/_label hariç. */
|
|
41
|
+
export declare function datasetKeys(ds: DataSet): string[];
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Alanın türü: hangi sürücünün dolduracağına ve eşlemeye yardım eder. */
|
|
2
|
+
export type FieldKind = 'text' | 'textarea' | 'select' | 'checkbox' | 'radio' | 'date' | 'contenteditable' | 'other';
|
|
3
|
+
/** Bir alanı sayfada tanımak için saklanan ipuçları (parmak izi). */
|
|
4
|
+
export interface MatchHints {
|
|
5
|
+
/** data-otofill="..." attribute'u: varsa kesin eşleşme. */
|
|
6
|
+
otofill?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
ariaLabel?: string;
|
|
12
|
+
tag?: string;
|
|
13
|
+
type?: string;
|
|
14
|
+
/** Üretilmiş CSS seçici. */
|
|
15
|
+
css?: string;
|
|
16
|
+
/** İçinde bulunduğu formun id/name değeri. */
|
|
17
|
+
formKey?: string;
|
|
18
|
+
/** Sayfadaki alanlar arasındaki sırası. */
|
|
19
|
+
index?: number;
|
|
20
|
+
}
|
|
21
|
+
/** Kullanıcının tanıttığı alan: "bu input şu anahtardır". */
|
|
22
|
+
export interface FieldDef {
|
|
23
|
+
id: string;
|
|
24
|
+
/** Veri setlerindeki sütun adı, ör. "musteri.tckn". */
|
|
25
|
+
key: string;
|
|
26
|
+
title?: string;
|
|
27
|
+
/** Geçerli olduğu sayfa adresleri, * joker. Boşsa her sayfada. */
|
|
28
|
+
pages: string[];
|
|
29
|
+
kind?: FieldKind;
|
|
30
|
+
match: MatchHints;
|
|
31
|
+
updatedAt?: string;
|
|
32
|
+
}
|
|
33
|
+
/** Veri setindeki bir satır: anahtar → değer. Değerler her zaman metindir. */
|
|
34
|
+
export interface DataRow {
|
|
35
|
+
_id: string;
|
|
36
|
+
_label?: string;
|
|
37
|
+
[key: string]: string | undefined;
|
|
38
|
+
}
|
|
39
|
+
export interface DataSet {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
rows: DataRow[];
|
|
43
|
+
updatedAt?: string;
|
|
44
|
+
}
|
|
45
|
+
export declare const BUNDLE_FORMAT = "optona-otofill";
|
|
46
|
+
export declare const BUNDLE_VERSION = 1;
|
|
47
|
+
/** İçe/dışa aktarılan dosya. */
|
|
48
|
+
export interface Bundle {
|
|
49
|
+
format: typeof BUNDLE_FORMAT;
|
|
50
|
+
version: number;
|
|
51
|
+
exportedAt: string;
|
|
52
|
+
fields?: FieldDef[];
|
|
53
|
+
datasets?: DataSet[];
|
|
54
|
+
}
|
|
55
|
+
/** merge: aynı id'liyi güncelle, yeniyi ekle. replace: dosyadaki bölümü tamamen değiştir. copy: hepsini yeni kayıt olarak ekle. */
|
|
56
|
+
export type ImportMode = 'merge' | 'replace' | 'copy';
|
|
57
|
+
/** Sayfadaki bir alanın o anki parmak izi. */
|
|
58
|
+
export interface Fingerprint extends MatchHints {
|
|
59
|
+
el: Element;
|
|
60
|
+
kind: FieldKind;
|
|
61
|
+
}
|
|
62
|
+
/** Değeri alana yazan sürücü. Özel bileşenler (Element Plus select vb.) için kendi sürücünüzü kaydedebilirsiniz. */
|
|
63
|
+
export interface Driver {
|
|
64
|
+
name: string;
|
|
65
|
+
detect(el: Element): boolean;
|
|
66
|
+
/** Başarılıysa true döner; false dönerse kısa bir beklemeden sonra yeniden denenir. */
|
|
67
|
+
fill(el: Element, value: string): boolean | Promise<boolean>;
|
|
68
|
+
read?(el: Element): string | undefined;
|
|
69
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element Plus (2.x) sürücüleri. Gerçek input'lar gizli/salt okunur olduğu için değer, bileşenin
|
|
3
|
+
* kendi açılır listesinden tıklanarak seçilir. el-input, el-input-number, el-checkbox, el-radio,
|
|
4
|
+
* el-switch native sürücülerle çalışır; burada yalnızca özel davranışlı bileşenler var.
|
|
5
|
+
*/
|
|
6
|
+
import type { Driver } from '../types';
|
|
7
|
+
export declare const elementPlusDrivers: Driver[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Karşılaştırma için metni düzleştirir: Türkçe karakterler, büyük/küçük harf, noktalama. */
|
|
2
|
+
export declare function norm(s?: string | null): string;
|
|
3
|
+
/** İki metnin benzerliği (0..1), harf ikilileriyle Dice katsayısı. */
|
|
4
|
+
export declare function similarity(a: string, b: string): number;
|
|
5
|
+
/** Metinden anahtar önerisi: "Adı Soyadı" → "adi_soyadi". */
|
|
6
|
+
export declare function slug(s?: string | null): string;
|
|
7
|
+
export declare function uid(): string;
|
|
8
|
+
export declare function nowIso(): string;
|
|
9
|
+
export declare function globToRegExp(pattern: string): RegExp;
|
|
10
|
+
/** Alanın sayfa desenlerinden biri adrese uyuyor mu? Boş liste her sayfaya uyar. */
|
|
11
|
+
export declare function pageMatches(pages: string[] | undefined, url: string): boolean;
|
|
12
|
+
/** Bulunulan sayfa için önerilen desen: sayısal parçalar * olur. */
|
|
13
|
+
export declare function suggestPagePattern(loc?: Location): string;
|
|
14
|
+
export declare function sitePattern(loc?: Location): string;
|
|
15
|
+
/** Framework'lerin her render'da ürettiği kararsız id'ler (el-id-1234-5, :r3:, v-12 ...). */
|
|
16
|
+
export declare function isDynamicId(id: string): boolean;
|
|
17
|
+
declare function cssEsc(s: string): string;
|
|
18
|
+
/** Alan için kısa ve mümkün olduğunca kararlı bir CSS seçici üretir. */
|
|
19
|
+
export declare function cssPath(el: Element): string;
|
|
20
|
+
export { cssEsc };
|
|
21
|
+
export declare const sleep: (ms: number) => Promise<void>;
|